Archive | June, 2013

Sublime 3 Licensed version

28 Jun

Installing on MacOS

  • Download the file from this link:
  • http://d.pr/f/QE3d
  • MD5: 59bab8f71f8c096cd3f72cd73851515d
  • Rename it to: Sublime Text
  • Make it executable with: chmod u+x Sublime\ Text
  • Replace it with: Sublime Text.app => Contents => MacOS => "Sublime Text"
  • Enjoy

Flipkart Discount

Installing on Windows x64

  • Download from here:
  • http://d.pr/f/60RQ
  • MD5: 6ddaa1fb63c6d7d4eae9ec39f1fa5d76
  • Rename it to: sublime_text.exe
  • Replace it with the one in your installation folder: e.g. [Installation Folder]/sublime_text.exe
  • Enjoy

Flipkart Discount

Installing on Windows x86

  • Download from here:
  • http://d.pr/f/1HIj
  • MD5: 8569b2cfa26677d72f322c8358f349c0
  • Rename it to: sublime_text.exe
  • Replace it with the one in your installation folder: e.g. [Installation Folder]/sublime_text.exe
  • You will paste a license key for this something like:
---BEGIN LICENSE---
Love Science
Unlimited User License
EA7E-18848
........................
.._____.................
.|  __ \      | |       
.| |  | | __ _| |_ __ _ 
.| |  | |/ _` | __/ _` |
.| |__| | (_| | || (_| |
.|_____/ \__,_|\__\__,_|
........................
---END LICENSE---

or write your own key.

Enjoy

Installing on Linux x64

  • Download from here:
  • http://d.pr/f/VCta
  • MD5: 552726c06917c711f9950e2eda6c928f
  • Rename it to: sublime_text
  • Make it executable with: chmod u+x sublime_text
  • Replace it with the one in your installation folder: e.g. [Installation Folder]/sublime_text
  • DONE
  • Installing on Linux x86
  • Download from here:
  • http://d.pr/f/x3B6
  • MD5: 98dbbcf51e7768f973f0afaf4424cfef
  • Rename it to: sublime_text
  • Make it executable with: chmod u+x sublime_text
  • Replace it with the one in your installation folder: e.g. [Installation Folder]/sublime_text
  • DONE

Alternative Link

This is alternative link due to droplr limitations: http://cl.ly/3H2O2E3v233t

 

 

Flipkart Discount
Donate Button

SSH Connection TIme-limit Settings

28 Jun

Hi,

Sometimes you get irritated when ssh connection times out and you have to connect to ssh again.

Method 1:-

Open /etc/ssh/ssh_config on your (client) computer. Add the following line:

ServerAliveInterval 180

 

Method 2:-

ssh -o ConnectTimeout=100 <host>

Where 100 is the number of seconds

The os module python (Part 1)

26 Jun

Hi,Today i will give you some information about OS Module in python which provides method to perform various operating system functions.

This module can be imported like this

import os

To check the methods inside the os module do this:-

dir(os)

It will give you an idea that what all you can perform via OS module.

Using OS.rename and OS.path.exists

OS.Rename is Used to RENAME files and OS.path.exists is used to Check if the file is present at path or not.

Renaming shobhit.txt to mygola.txt
First Check if the file exists on the path

os.path.exists('shobhit.txt') # Will either return true or False
>>>true

os.rename('shobhit.txt','mygola.txt')

##Checking Again##
os.path.exists('shobhit.txt') # Will either return true or False
>>>false

os.path.exists('mygola.txt') # Will either return true or False
>>>true

Working with directories
The os module also contains a number of functions that work on entire directories.
The listdir function returns a list of all filenames in a given directory. The current and parent directory
markers used on Unix and Windows (. and ..) are not included in this list. Example: Using the os module to list the files in a directory

import os
for file in os.listdir("Documents"):
    print file

## OR just list everything on the current path ##
os.listdir('./')    #It will return array of files on that current path

The getcwd and chdir functions are used to get and set the current directory:
Using the os module to change the working directory

import os
cwd = os.getcwd() #Current Path
os.chdir("Documents") #Change the Directory to Documents/
os.chdir(os.pardir) #Going back to parent Directory

The makedirs and removedirs functions are used to create and remove directory hierarchies.
Using the os module to create and remove multiple directory levels

import os
os.makedirs("shobhit/mygola/developer") #Making Nested Directories
fp = open("shobhit/mygola/developer/test", "w") #Opening a File in Nested folder
fp.write("Hello world") #Writing a text to the file
fp.close() #Closing the file handle
os.remove("shobhit/mygola/developer/test") #remove the file</pre>
os.removedirs("shobhit/mygola/developer") # Will remove all these directories

Cheers 🙂

If you guys find this post useful .Please make this poll.

Change the type of EC2 Instance on Amazon

26 Jun
  1. Login to aws.amazon.com
  2. Go to EC2 Console
  3. Select the instance you want to change the type of
  4. Click Actions(on the top)
  5. Select Stop from the dropdown list
  6. After the instance gets stopped, Click the Action again.
  7. Click Change Instance Type
  8. Select the Type of the instance you want to change
  9. Start the Instance

Note: If you have assigned Elastic IP to the Instance then it will gets dis-associated so click elastic ip option and  Associate the IP to the instance. 

Add to the PATH on Mac OS X

25 Jun
  • Open up Terminal.
  • Run the following command:
  • sudo vim /etc/paths
  • Enter your password, when prompted.
  • Go to the bottom of the file, and enter the path you wish to add.
  • Now type :wq to save the file

That’s it!  To test it, in new terminal window, type:

  • echo $PATH
  • Shobhit:~ apple$ echo $PATH
    /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin

Change Username for Whole Mac

25 Jun

Sometimes you change the username in user and Account Settings and it still shows old username.so this is what you need to do

System Preferences->Sharing->Computer Name

OR

sudo hostname your_hostname

If that doesn’t work, try this:

sudo scutil --set HostName your_hostname

mysql_config not found on easy_install mysql_python

25 Jun

Hi , 

Sometimes on your mac whenever you do , easy_install mysql-python . you get 
 
Environment Error: mysql_config not found
 
It is a simple fix.
 
export $ PATH=/usr/local/mysql/bin:$PATH
NOW sudo easy_install mysql_python
Just check your mysql bin path , it might be different

You should see these type of logs while installing mysql-python

Searching for mysql-python
Reading http://pypi.python.org/simple/mysql-python/
Best match: MySQL-python 1.2.4
Downloading http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.4.zip#md5=ddf2386daf10a97af115ffad2ed4a9a0
Processing MySQL-python-1.2.4.zip
Running MySQL-python-1.2.4/setup.py -q bdist_egg –dist-dir /tmp/easy_install-SJMVBl/MySQL-python-1.2.4/egg-dist-tmp-mm1dBM
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Extracting in /tmp/easy_install-SJMVBl/MySQL-python-1.2.4/temp/tmpwLUyDi
Now working in /tmp/easy_install-SJMVBl/MySQL-python-1.2.4/temp/tmpwLUyDi/distribute-0.6.28
Building a Distribute egg in /private/tmp/easy_install-SJMVBl/MySQL-python-1.2.4
Adding MySQL-python 1.2.4 to easy-install.pth file
Installed /Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.8-intel.egg
Processing dependencies for mysql-python

 

Enjoy Coding..

Node Version Manager (NVM)

24 Jun

Install script

To install you could use the install script (requires Git) using cURL:

curl https://raw.github.com/creationix/nvm/master/install.sh | sh

or Wget:

wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh

The script clones the Nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile or ~/.profile).

Manual install

For manual install create a folder somewhere in your filesystem with the nvm.sh file inside it. I put mine in a folder called nvm.

Or if you have git installed, then just clone it:

git clone git://github.com/creationix/nvm.git ~/.nvm

To activate nvm, you need to source it from your bash shell

source ~/.nvm/nvm.sh

I always add this line to my ~/.bashrc or ~/.profile file to have it automatically sourced upon login.
Often I also put in a line to use a specific version of node.

Usage

To download, compile, and install the latest v0.10.x release of node, do this:

nvm install 0.10

And then in any new shell just use the installed version:

nvm use 0.10

Or you can just run it:

nvm run 0.10

If you want to see what versions are installed:

nvm ls

If you want to see what versions are available to install:

nvm ls-remote

To restore your PATH, you can deactivate it.

nvm deactivate

To set a default Node version to be used in any new shell, use the alias ‘default’:

nvm alias default 0.10

Time in Python

19 Jun
CURRENT TIME IN PYTHON

import time
print time.time()

#Print as a Single Value
print int(time.time())

EPOCH TO HUMAN READABLE DATE

import time
time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime(time.time()))
#Replace time.localtime with time.gmtime for GMT time

Installing Node.js

17 Jun

Installing Node.js via package manager

The packages on this page are maintained and supported by their respective packagers, not the node.js core team. Please report any issues you encounter to the package maintainer. If it turns out your issue is a bug in node.js itself, the maintainer will report the issue upstream.

Gentoo

Node.js is available in official gentoo portage tree. You have to unmask it.

# emerge -aqv --autounmask-write nodejs
# etc-update
# emerge -aqv nodejs

Debian, LMDE

Node.js is available in official repo for Debian Sid(unstable).

For Debian Wheezy, your best bet is to compile node by yourself:

sudo apt-get install python g++ make checkinstall
mkdir ~/src && cd $_
wget -N http://nodejs.org/dist/node-latest.tar.gz
tar xzvf node-latest.tar.gz && cd node-v*
./configure
checkinstall #(remove the "v" in front of the version number in the dialog)
sudo dpkg -i node_*

Uninstall:

sudo dpkg -r node

Ubuntu, Mint

Example install:

sudo apt-get update
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

It installs current stable Node on the current stable Ubuntu. Quantal (12.10) users may need to install the software-properties-commonpackage for the add-apt-repository command to work: sudo apt-get install software-properties-common

As of Node.js v0.10.0, the nodejs package from Chris Lea‘s repo includes both npm and nodejs-dev.

There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed fromnode to nodejs. You’ll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.

openSUSE & SLE

Node.js stable repos list. Also node.js is available in openSUSE:Factory repository.

Available RPM packages for: openSUSE 11.4, 12.1, Factory and Tumbleweed; SLE 11 (with SP1 and SP2 variations).

Example install on openSUSE 12.1:

sudo zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_12.1/ NodeJSBuildService 
sudo zypper in nodejs nodejs-devel

Fedora

Node.js and npm are available in Fedora 18 and later. Just use your favorite graphical package manager or run this on a terminal to install both npm and node:

sudo yum install npm

RHEL/CentOS/Scientific Linux 6

Node.js and npm are available from the Fedora Extra Packages for Enterprise Linux (EPEL) repository. If you haven’t already done so, first enable EPEL and then run the following command to install node and npm:

su -c 'yum install npm'

Arch Linux

Node.js is available in the Community Repository.

pacman -S nodejs

FreeBSD and OpenBSD

Node.js is available through the ports system.

/usr/ports/www/node

Development versions are also available using ports

cd /usr/ports/www/node-devel/ && make install clean

or packages on FreeBSD

pkg_add -r node-devel

OSX

Using a package

Simply download Macintosh Installer.

Using homebrew:

brew install node

Using macports:

port install nodejs  

Windows

Using a package

Simply download Windows Installer.

Using chocolatey to install Node:

cinst nodejs  

or for full install with NPM:

cinst nodejs.install