running redis as daemon on osx

10 Sep
sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist

Paste in the following contents and modify it to point it to wherever you’ve got redis-server installed and optionally pass the location of a config file to it (delete the redis.conf line if you’re not using one):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>io.redis.redis-server</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/redis-server</string>
        <string>/usr/local/etc/redis.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Make sure that you actually have a redis.conf file at the location above. If you’ve installed it with homebrew that should be the correct location.

You’ll then need to load the file (one time) into launchd with launchctl:

sudo launchctl load /Library/LaunchDaemons/io.redis.redis-server.plist

Redis will now automatically be started after every boot. You can manually start it without rebooting with:

sudo launchctl start io.redis.redis-server

You can also shut down the server with

sudo launchctl stop io.redis.redis-server

Or you could add these aliases to your bash/zsh rc file:

  • alias redisstart=’sudo launchctl start io.redis.redis-server’
  • alias redisstop=’sudo launchctl stop io.redis.redis-server’

If you’re having some sort of error (or just want to watch the logs), you can just fire up Console.app to watch the redis logs to see what’s going on.

ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes

31 Jul

If Any field is greater than 255 eg varchar(256) then reduce them to 255 and it should work.It seems 255 is the limitation.

Mongodb process terminated with status 100

13 May

It is generally happened due to locking issues on the system

so rm /var/lib/mongodb/mongod.lock

should work .

Configure HTTPs on Localhost for testing purposes on MAC OS

11 Apr

Step 1: Generate a Private Key

 openssl genrsa -des3 -out ssl.key 1024

Step 2: Generate a CSR 

openssl req -new -key ssl.key -out ssl.csr

Step 3: Remove Passphrase from key

cp ssl.key ssl.key.org
openssl rsa -in ssl.key.org -out ssl.key

Step 4: Generating a Self-Signed Certificate

openssl x509 -req -days 365 -in ssl.csr -signkey ssl.key -out ssl.crt

Step 5: 

   OPEN /private/etc/apache2/httpd.conf

   UNCOMMENT the line LoadModule ssl_module libexec/apache2/mod_ssl.so by removing # in front of it

   UNCOMMENT the line Include /private/etc/apache2/extra/httpd-ssl.conf

   OPEN  /private/etc/apache2/extra/httpd-ssl.conf

   UPDATE  DocumentRoot to your website path

   UPDATE ServerName to Localhost

   COMMENT SSLCACertificatePath‘ and ‘SSLCARevocationPath’ if there,

   MAKE A FOLDER in /private/etc/apache2/ with name ssl

   COPY ssl.crt and ssl.key in ssl folder

   UPDATE SSLCertificateFile with  /private/etc/apache2/ssl/ssl.crt

   UPDATE SSLCertificateKeyFile with  “/private/etc/apache2/ssl/ssl.key”

   THEN sudo apachectl restart

 

Enjoy

Changing Document Root of Apache on mac OS (10.8)

11 Apr
  1. Go to /etc/private/httpd.conf
  2. sudo vim httpd.conf (Cannot edit in Readonly mode)
  3. Type /DocumentRoot to find Document Root in the file
  4. Change the file path to what you need
  5. save the file by :wq if you have vim
  6. sudo apachectl restart
  7. Go to localhost/index.html or any file on the given path

Announcing Portia, the open source visual web scraper!

2 Apr

awesomeness

[Accessibility]Missing contentDescription attribute on image

26 Feb

Resolved this warning by setting attribute android:contentDescription for my ImageView

android:contentDescription=”@string/desc”

this link for explanation: http://developer.android.com/guide/practices/design/accessibility.html

 

 

 

 
Shobhit Jain

Installing Nginx on Mac using Brew

20 Feb

Install Using Brew . ( Don’t have brew ?? go Here )

  • Brew install nginx 
  • Nginx will be installed and started by brew itself
  • If not then type sudo nginx
  • Test nginx by opening this url in browser : – http://localhost:8080

 

 

 

Import CSV to mysql

23 Oct

To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV file.

You can then import it into a MySQL table by running:

load data local infile 'uniq.csv' into table tblUniq fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(uniqName, uniqCity, uniqComments)

 

 

 

 

Remove python2.7 and rollback to python2.6

21 Oct
sudo ln -f /usr/bin/python2.6 /usr/local/bin/python