Skip to content

Instantly share code, notes, and snippets.

View shakkhar's full-sized avatar

Mashiat Shakkhar shakkhar

View GitHub Profile
@didip
didip / tornado-nginx-example.conf
Created January 30, 2011 05:19
Nginx config example for Tornado
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
@utaal
utaal / Makefile
Created September 5, 2011 16:42
webserver using libuv
webserver: webserver.c libuv/uv.a http-parser/http_parser.o
gcc -I libuv/include \
-lrt -lm -lpthread -o \
webserver webserver.c \
libuv/uv.a http-parser/http_parser.o
libuv/uv.a:
$(MAKE) -C libuv
http-parser/http_parser.o:
@sheffler
sheffler / ex1.py
Created September 22, 2011 19:53
Twisted11 Basic Auth using Password Dictionary
#!/usr/bin/env python
from zope.interface import implements
from twisted.cred import portal, checkers, credentials, error as credError
from twisted.internet import defer, reactor
from twisted.web import static, resource
from twisted.web.resource import IResource
from twisted.web.http import HTTPChannel
from twisted.web import server
from twisted.web.guard import HTTPAuthSessionWrapper
@btoone
btoone / curl.md
Last active June 19, 2024 12:54
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@jboner
jboner / latency.txt
Last active June 23, 2024 14:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@harperreed
harperreed / peter-thiels-cs183-startup-class-01-notes-essay.md
Created July 29, 2012 21:20
Notes Essays—Peter Thiel’s CS183: Startup—Stanford, Spring 2012

Here is an essay version of my class notes from Class 1 of CS183: Startup. Errors and omissions are my own. Credit for good stuff is Peter’s entirely.

CS183: Startup—Notes Essay—The Challenge of the Future

Purpose and Preamble

@lbolla
lbolla / futures_test.py
Last active April 24, 2023 17:59
Tornado and concurrent.futures
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
anonymous
anonymous / gist:5423293
Created April 19, 2013 21:16
class Dp:
my_attr = 'foo'
funs = []
for attr in ('my_attr', 'doesnt_exist', 'my_attr'):
funs.append(lambda obj: getattr(dp, attr))
dp = Dp()
for fun in funs:
print fun(dp)
@dwbuiten
dwbuiten / gist:5490255
Last active December 16, 2015 20:09
Hacky script for compiling dynamic MediaInfo
#!/bin/sh -e
# Replace with whatever versions you need
ZEN_VERSION=0.4.29
LIB_VERSION=0.7.63
MED_VERSION=0.7.63
PREFIX=/usr/local
wget http://mediaarea.net/download/source/libzen/${ZEN_VERSION}/libzen_${ZEN_VERSION}.tar.bz2
wget http://mediaarea.net/download/source/libmediainfo/${LIB_VERSION}/libmediainfo_${LIB_VERSION}.tar.bz2
@atenni
atenni / README.md
Last active June 20, 2024 22:30
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]