An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
worker_processes 2; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
use epoll; | |
} |
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: |
#!/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 |
An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
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 |
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
from concurrent.futures import ThreadPoolExecutor | |
from functools import partial, wraps | |
import time | |
import tornado.ioloop | |
import tornado.web | |
EXECUTOR = ThreadPoolExecutor(max_workers=4) |
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) |
#!/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 |
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]