Skip to content

Instantly share code, notes, and snippets.

View samof76's full-sized avatar
🐒
Swinging branches

Samuel Vijaykumar M samof76

🐒
Swinging branches
View GitHub Profile
class Client_Twitter(models.Model):
user = models.OneToOneField('Client')
twitter_id = models.DecimalField(max_digits=20, decimal_places=0,null=True)
access_token = models.CharField(max_length=200,null=True)
access_token_secret = models.CharField(max_length=200,null=True)
twitter_username = models.CharField(max_length=200,null=True)
def __unicode__(self):
return self.user.user.username
import oauth2 as oauth
def twitter_connect(request):
twitter_consumer_key = settings.TWITTER_CONSUMER_KEY
twitter_consumer_secret = settings.TWITTER_CONSUMER_SECRET
request_token_url = 'http://twitter.com/oauth/request_token'
access_token_url = 'http://twitter.com/oauth/access_token'
authorize_url = 'http://twitter.com/oauth/authorize'
consumer = oauth.Consumer(twitter_consumer_key,twitter_consumer_secret)
elif(request.GET['oauth_verifier'] != "" ):
oauth_verifier = request.GET['oauth_verifier']
token = oauth.Token(request.session.get('roauth_token', None),request.session.get('roauth_token_secret', None))
token.set_verifier(oauth_verifier)
client = oauth.Client(consumer, token)
resp, content = client.request(access_token_url, "POST")
access_token = dict(urlparse.parse_qsl(content))
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@dideler
dideler / 0-startup-overview.md
Last active May 3, 2024 11:03
Startup Engineering notes
@denji
denji / nginx-tuning.md
Last active June 1, 2024 17:44
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@yoav-steinberg
yoav-steinberg / rediff.py
Created April 13, 2014 15:48
rediff - the redis diff script
import urlparse
import argparse
import redis
import sys
from multiprocessing import Pool
import signal
def parse_redis_url(s):
url = urlparse.urlparse(s)
if not url.scheme:
@johanstenberg92
johanstenberg92 / install-pcp.sh
Created July 2, 2015 19:11
Install Performance Co-Pilot on Amazon Linux AMI
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "Sorry, you are not root."
exit 1
fi
if !(type pcp 2>/dev/null;) then
yum -y install git bison flex gcc-c++ perl-Tk-devel libmicrohttpd-devel
git clone git://git.pcp.io/pcp
@cwest
cwest / cf-mvp.sh
Last active March 21, 2016 09:34
#!/usr/bin/env bash
set -ex
# ____ _ _ _____ _ __ ____ ______
# / ___| | ___ _ _ __| | ___|__ _ _ _ __ __| |_ __ _ _ | \/ \ \ / / _ \
# | | | |/ _ \| | | |/ _` | |_ / _ \| | | | '_ \ / _` | '__| | | | | |\/| |\ \ / /| |_) |
# | |___| | (_) | |_| | (_| | _| (_) | |_| | | | | (_| | | | |_| | | | | | \ V / | __/
# \____|_|\___/ \__,_|\__,_|_| \___/ \__,_|_| |_|\__,_|_| \__, | |_| |_| \_/ |_|
# |___/