This file contains 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
#################################### | |
# BASIC REQUIREMENTS | |
# http://graphite.wikidot.com/installation | |
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/ | |
#################################### | |
sudo apt-get update | |
wget http://launchpad.net/graphite/1.0/0.9.8/+download/graphite-web-0.9.8.tar.gz | |
wget http://launchpad.net/graphite/1.0/0.9.8/+download/carbon-0.9.8.tar.gz | |
wget http://launchpad.net/graphite/1.0/0.9.8/+download/whisper-0.9.8.tar.gz |
This file contains 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
# How beautiful and simple it is to store relationships in redis | |
# Think - I have 4 friends, you have 4 friends, but how many friends | |
# do we have in common? And did I tell you it handles sorted sets? | |
# Sorted sets are like sets but with a score. The score provides sorting | |
# and ranking capabilities | |
redis 127.0.0.1:6379> sadd friends:leto ghanima paul chani jessica | |
(integer) 4 | |
redis 127.0.0.1:6379> sadd friends:duncan paul jessica alia | |
(integer) 3 |
This file contains 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
def resize(img, box, fit, out): | |
'''Downsample the image. | |
@param img: Image - an Image-object | |
@param box: tuple(x, y) - the bounding box of the result image | |
@param fix: boolean - crop the image to fill the box | |
@param out: file-like-object - save the image into the output stream | |
''' | |
#preresize image with factor 2, 4, 8 and fast algorithm | |
factor = 1 | |
while img.size[0]/factor > 2*box[0] and img.size[1]*2/factor > 2*box[1]: |
This file contains 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
/* | |
* http://necenzurat.net/2010/05/26/clean-up-and-url-like-wordpress-does.dev | |
* Create a slug for friendly URL's a-la wordpress | |
*/ | |
function clean_url($str) { | |
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $str); | |
$clean = strtolower(trim($clean, '-')); | |
$clean = preg_replace("/[\/_|+ -]+/", '-', $clean); | |
return $clean; |
This file contains 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
// http://blog.jgc.org/2010/06/1010-code.html | |
var alphabet = 'ABCDEFGHJKMNPQRVWXY0123456789'; | |
var base = alphabet.length; | |
function calculate_tt(lat, lon) { | |
lat += 90.0; | |
lon += 180.0; | |
lat *= 10000.0; | |
lon *= 10000.0; |
This file contains 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
www: | |
requirements: | |
- faye | |
- jade |
This file contains 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
# http://amix.dk/blog/post/19588?source=google | |
from math import sqrt | |
def _confidence(ups, downs): | |
n = ups + downs | |
if n == 0: | |
return 0 | |
z = 1.0 #1.0 = 85%, 1.6 = 95% |
This file contains 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
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
This file contains 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
require 'fileutils' | |
start_time = Time.now | |
SOURCE_DB = { | |
:name => 'db_name', | |
:user => 'db_user', | |
:password => 'db_pass', | |
:host => 'localhost' |
This file contains 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
using System; | |
using System.IO; | |
using System.Text; | |
using Amazon; | |
using Amazon.S3; | |
using Amazon.S3.Model; | |
namespace AWSUploadTest | |
{ |