This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Note: I'm currently taking a break from this course to focus on my studies so I can finally graduate
Moved to git repository: https://github.com/denji/nginx-tuning
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ex | |
# ____ _ _ _____ _ __ ____ ______ | |
# / ___| | ___ _ _ __| | ___|__ _ _ _ __ __| |_ __ _ _ | \/ \ \ / / _ \ | |
# | | | |/ _ \| | | |/ _` | |_ / _ \| | | | '_ \ / _` | '__| | | | | |\/| |\ \ / /| |_) | | |
# | |___| | (_) | |_| | (_| | _| (_) | |_| | | | | (_| | | | |_| | | | | | \ V / | __/ | |
# \____|_|\___/ \__,_|\__,_|_| \___/ \__,_|_| |_|\__,_|_| \__, | |_| |_| \_/ |_| | |
# |___/ |
OlderNewer