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
#!/usr/bin/env python3.0 | |
import sys, array, tempfile, heapq | |
assert array.array('i').itemsize == 4 | |
def intsfromfile(f): | |
while True: | |
a = array.array('i') | |
a.fromstring(f.read(4000)) | |
if not a: |
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 "tokyocabinet" | |
require "benchmark" | |
include TokyoCabinet | |
records = 1000000 | |
hdb = HDB::new # Hash database; acts as a key value store | |
hdb.open("casket.hdb", HDB::OWRITER | HDB::OCREAT) | |
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
import socket | |
def sockrecv(sock): | |
d = '' | |
while not d or d[-1] != '\n': | |
d += sock.recv(8192) | |
return d | |
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
# Build an inverted index for a full-text search engine with Redis. | |
# Copyright (C) 2009 Salvatore Sanfilippo. Under the BSD License. | |
# USAGE: | |
# | |
# ruby invertedindex.rb add somedir/*.c | |
# ruby invertedindex.rb add somedir/*.txt | |
# ruby search your query string | |
require 'rubygems' | |
require 'redis' |
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 "luarocks.require" | |
require "pack" | |
require "socket" | |
require "md5" | |
Growl = {version = 1, registration = 0, notification = 1} | |
function Growl.new(hostname, appname) | |
local mysock = assert(socket.udp()) |
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
from redis import Redis | |
import simplejson | |
class Resque(object): | |
"""Dirt simple Resque client in Python. Can be used to create jobs.""" | |
redis_server = 'localhost:6379' | |
def __init__(self): | |
host, port = self.redis_server.split(':') | |
self.redis = Redis(host=host, port=int(port)) |
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
#!/usr/bin/env python | |
def application(environ, start_response): | |
start_response("200 OK", [("Content-Type", "text/html; charset=utf-8")]) | |
return ["Hello, World!"] | |
if __name__ == "__main__": | |
from gevent.wsgi import WSGIServer | |
address = "localhost", 8080 |
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
puts <<ASCII | |
/´¯/) | |
,/¯ / | |
/ / | |
/´¯/' '/´¯¯`·¸ | |
/'/ / / /¨¯\\ | |
('( ´ ´ ¯~/' ') | |
\\ ' / | |
'' \\ _ ·´ | |
\\ ( |
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
#!/bin/sh | |
# | |
# redis - this script starts and stops the redis-server daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Redis is a persistent key-value database | |
# processname: redis-server | |
# config: /etc/redis/redis.conf | |
# config: /etc/sysconfig/redis | |
# pidfile: /var/run/redis.pid |
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
import tweepy | |
auth = tweepy.OAuthHandler(consumer_token, consumer_secret) | |
auth.get_xauth_access_token(username, password) | |
# you can then use this for API access... | |
api = tweepy.API(auth) | |
api.update_status("hello") | |
# to get the access token object for storing... |
OlderNewer