virtualenv -p /usr/bin/python2.6 /provide/path/to/new/virtualenv/
Where python2.6 is the python version which can be changed to anything and virtualenv path is the folder created by you to install virtualenv in it
virtualenv -p /usr/bin/python2.6 /provide/path/to/new/virtualenv/
Where python2.6 is the python version which can be changed to anything and virtualenv path is the folder created by you to install virtualenv in it
def ngrams(sequence, n, pad_left=False, pad_right=False, pad_symbol=None): if pad_left: sequence = chain((pad_symbol,) * (n-1), sequence) if pad_right: sequence = chain(sequence, (pad_symbol,) * (n-1)) sequence = list(sequence) count = max(0, len(sequence) - n + 1) return [tuple(sequence[i:i+n]) for i in range(count)]
Now lets get Started:
1) Bigrams: sequence = [1,2,3,4,5] n=2 ngrams(sequence,n) [(1,2),(2,3),(3,4),(4,5)]
For Trigrams n=3 and so on..
If you want a left or right padding when the numbers are odd then mention the left Padding or right padding variable
Enjoy.
Here is the function to use:
import gzip import StringIO import zlib def decode (page): encoding = page.info().get("Content-Encoding") if encoding in ('gzip', 'x-gzip', 'deflate'): content = page.read() if encoding == 'deflate': data = StringIO.StringIO(zlib.decompress(content)) else: data = gzip.GzipFile('', 'rb', 9, StringIO.StringIO(content)) page = data.read() return page
import urllib import base64 import httplib</code></pre> CONSUMER_KEY = 'my_key' CONSUMER_SECRET = 'my_secret' encoded_CONSUMER_KEY = urllib.quote(CONSUMER_KEY) encoded_CONSUMER_SECRET = urllib.quote(CONSUMER_SECRET) concat_consumer_url = encoded_CONSUMER_KEY + ":" + encoded_CONSUMER_SECRET host = 'api.twitter.com' url = '/oauth2/token/' params = urllib.urlencode({'grant_type' : 'client_credentials'}) req = httplib.HTTPSConnection(host) req.putrequest("POST", url) req.putheader("Host", host) req.putheader("User-Agent", "My Twitter 1.1") req.putheader("Authorization", "Basic %s" % base64.b64encode(concat_consumer_url)) req.putheader("Content-Type" ,"application/x-www-form-urlencoded;charset=UTF-8") req.putheader("Content-Length", "29") req.putheader("Accept-Encoding", "utf-8") req.endheaders() req.send(params) resp = req.getresponse() print resp.status, resp.reason print resp.read()
import sys # used for the storage class import pycurl # used for curling import base64 # used for encoding string import urllib # used for enconding import cStringIO # used for curl buffer grabbing import json # used for decoding json token import time # used for stuff to do with the rate limiting from time import sleep # used for rate limiting from time import gmtime, strftime # used for gathering time def get_bearer_token(consumer_key,consumer_secret): # enconde consumer key consumer_key = urllib.quote(consumer_key) # encode consumer secret consumer_secret = urllib.quote(consumer_secret) # create bearer token bearer_token = consumer_key+':'+consumer_secret # base64 encode the token base64_encoded_bearer_token = base64.b64encode(bearer_token) # set headers headers = [ "POST /oauth2/token HTTP/1.1", "Host: api.twitter.com", "User-Agent: shobhit Twitter Application-only OAuth App Python v.1", "Authorization: Basic "+base64_encoded_bearer_token+"", "Content-Type: application/x-www-form-urlencoded;charset=UTF-8", "Content-Length: 29"] token_url = "https://api.twitter.com/oauth2/token" buf = cStringIO.StringIO() access_token = '' pycurl_connect = pycurl.Curl() pycurl_connect.setopt(pycurl_connect.URL, token_url) # used to tell which url to go to pycurl_connect.setopt(pycurl_connect.WRITEFUNCTION, buf.write) # used for generating output pycurl_connect.setopt(pycurl_connect.HTTPHEADER, headers) # sends the customer headers above pycurl_connect.setopt(pycurl_connect.POSTFIELDS, 'grant_type=client_credentials') pycurl_connect.perform() # perform the curl access_token = buf.getvalue() # grab the data pycurl_connect.close() # stop the curl x = json.loads(access_token) bearer = x['access_token'] return bearer
Try making this symbolic link and it should work
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
#################################################################################
PS: Check the libmysqlclient path which can be done via locate libmysqlclient
If you deactivate your account, your timeline disappears from the Facebook service immediately. People on Facebook won’t be able to search for you, though some info, like messages you sent, may still be visible to others. We also save your timeline information (ex: friends, photos, interests, etc.) in case you want to come back.
If you don’t think you’ll use Facebook again, you can request to have your account permanently deleted. Please keep in mind that you won’t be able to reactivate your account or retrieve anything you’ve added. Before you do this, you may want to download a copy of your info from Facebook. Then, if you’d like your account permanently deleted with no option for recovery, log into your account and fill out this form.
If you can’t log in to your account, you’ll need to reset your password first. To do this, go to http://www.facebook.com and click the Forgot your password? link below the password field. Once you’ve followed the instructions to reset your password and can log into your account, you can deactivate or delete your account using the steps outlined above.
This is the method to connect ssh without password because sometimes it becomes irritating.
Open your terminal and type
shobhit@mac :~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory ‘/home/a/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 shobhit@mac
Now login to ssh using your password.
shobhit@vpc mkdir -p .ssh
shobhit@vpc vim .ssh/authorized_keys
Now type :wq to create a Blank File
Now at your Terminal. This is the last time you will be using your password
shobhit@mac:~> cat .ssh/id_rsa.pub | ssh shobhit@vpc ‘cat >> .ssh/authorized_keys’
shobhit@mac’s password:
From now on you can log into B as b from A as a without password:
shobhit@mac:~> ssh shobhit@vpc hostname
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
Put the public key in .ssh/authorized_keys2
Change the permissions of .ssh to 700
Change the permissions of .ssh/authorized_keys2 to 640