Skip to content

Instantly share code, notes, and snippets.

@glacjay
glacjay / tun-ping-linux.py
Created September 18, 2010 04:49
Reading/writing Linux's TUN/TAP device using Python.
import fcntl
import os
import struct
import subprocess
# Some constants used to ioctl the device file. I got them by a simple C
# program.
TUNSETIFF = 0x400454ca
TUNSETOWNER = TUNSETIFF + 2
@bowsersenior
bowsersenior / stooge_loader.rb
Created May 18, 2011 23:18
A demo of YAML anchors, references and nested values
require 'rubygems'
require 'yaml'
# A demonstration of YAML anchors, references and handling of nested values
# For more info, see:
# http://atechie.net/2009/07/merging-hashes-in-yaml-conf-files/
stooges = YAML::load( File.read('stooges.yml') )
# => {
# "default" => {
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@amaxwell01
amaxwell01 / interviewitems.MD
Created September 15, 2012 14:17
My answers to over 100 Google interview questions

##Google Interview Questions: Product Marketing Manager

  • Why do you want to join Google? -- Because I want to create tools for others to learn, for free. I didn't have a lot of money when growing up so I didn't get access to the same books, computers and resources that others had which caused money, I want to help ensure that others can learn on the same playing field regardless of their families wealth status or location.
  • What do you know about Google’s product and technology? -- A lot actually, I am a beta tester for numerous products, I use most of the Google tools such as: Search, Gmaill, Drive, Reader, Calendar, G+, YouTube, Web Master Tools, Keyword tools, Analytics etc.
  • If you are Product Manager for Google’s Adwords, how do you plan to market this?
  • What would you say during an AdWords or AdSense product seminar?
  • Who are Google’s competitors, and how does Google compete with them? -- Google competes on numerous fields: --- Search: Baidu, Bing, Duck Duck Go
/* fix_fft.c - Fixed-point in-place Fast Fourier Transform */
/*
All data are fixed-point short integers, in which -32768
to +32768 represent -1.0 to +1.0 respectively. Integer
arithmetic is used for speed, instead of the more natural
floating-point.
For the forward FFT (time -> freq), fixed scaling is
performed to prevent arithmetic overflow, and to map a 0dB
sine/cosine wave (i.e. amplitude = 32767) to two -6dB freq
@zeha
zeha / dsl.py
Created February 16, 2013 02:04
Quick DSL example for Python
from __future__ import print_function
from contextlib import contextmanager
class DslRunner(object):
"""Runs Python code in the context of a class.
Public methods will be exposed to the DSL code.
"""
@jrenner
jrenner / box2d_air_resistance.java
Last active January 14, 2022 04:30
box2d air resistance
float dragForce;
Vector2 appliedDrag = new Vector2();
float dragAngle;
float p, A, Cd, v; // elements of the formula see wikipedia entry for Drag (physics)
/*
ρ is the density of the fluid,
v is the speed of the object relative to the fluid,
A is the cross-sectional area
Cd is the drag coefficient – a dimensionless number.
sample drag co-efficients (http://en.wikipedia.org/wiki/Drag_coefficient)
@roxlu
roxlu / Spline.h
Created December 4, 2013 17:35
Catmull Rom spline interpolation
#ifndef ROXLU_SPLINEH
#define ROXLU_SPLINEH
#include <vector>
/**
* Catmull Rom interpolation.
* --------------------------
* Catmull Rom interpolation works with 4 points, there the
* local "t" value is used to interpolate between points B and C. The
@napsternxg
napsternxg / linearReg.py
Created July 31, 2015 16:22
Implementing linear regression in keras
"""
Author: Shubhanshu Mishra
Posted this on the keras issue tracker at: https://github.com/fchollet/keras/issues/108
Implementing a linear regression using Keras.
"""
from keras.models import Sequential
from keras.layers.core import Dense, Activation
model = Sequential()
@ssarangi
ssarangi / llvmlite_fpm.py
Created August 23, 2015 08:26
LLVMLite Function Pass manager example
__author__ = 'sarangis'
from ctypes import CFUNCTYPE, c_int
import sys
import llvmlite.ir as ll
import llvmlite.binding as llvm
llvm.initialize()
llvm.initialize_native_target()