Skip to content

Instantly share code, notes, and snippets.

View stepper.py
from random import random
def busy_block(stepper):
res = None
while stepper is not None:
stepper, res = stepper()
print(res)
return res
View go_bus_seat_texture.glsl
float angle(vec2 uv) {
float a = atan(uv.y / uv.x);
if (uv.x < 0.) {
a += PI;
}
if (uv.x > 0. && uv.y < 0.) {
a += PI2;
}
return a;
}
View keylogger.c
#include <stdio.h>
#include <time.h>
#include <ApplicationServices/ApplicationServices.h> /* ApplicationServices.framework needed */
char *logFileName = "./keystroke.log";
FILE *logFile = NULL;
int counter = 0;
struct timespec prev_time;
View imperfect_tree.java
void setup() {
size(500, 500);
}
void tree(float x, float y, float length, float angle) {
if (length < 2) {
return;
}
float ny = y - length * sin(angle);
float nx = x + length * cos(angle);
View blobby.java
import java.awt.event.KeyEvent;
float drag = 0.9;
class Point {
float x, y, vx, vy;
Point(float x, float y) {
this.x = x;
this.y = y;
View imperfect_fractals.java
int count = 1;
void setup() {
size(500, 500);
}
void keyPressed() {
if (keyCode == UP) {
count += 1;
} else if (keyCode == DOWN) {
View parallel_merge.py
from random import shuffle
from math import log2, floor
def main():
A = list(range(15))
B = list(range(10))
print("Before:\t A =", A)
print("\t B =", B)
N = len(A)
P = 5 # Number of procs
View .emacs
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize) ;; You might already have this line
(require 'multiple-cursors)
@davidrusu
davidrusu / Dockerfile for nginx
Created Aug 16, 2015
docker and docker-compose
View Dockerfile for nginx
FROM tutum/nginx
RUN rm /etc/nginx/sites-enabled/default
ADD sites-enabled/ /etc/nginx/sites-enabled
ADD static/ /www/static
# the directory structure of the nginx component:
# ./nginx
# ├── Dockerfile
# ├── sites-enabled
# │ └── app
View hypothesis traceback
>>> import hypothesis
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python34\lib\site-packages\hypothesis\__init__.py", line 31, in <module>
from hypothesis.core import given, assume, find, example
File "c:\Python34\lib\site-packages\hypothesis\core.py", line 608, in <module>
load_entry_points()
File "c:\Python34\lib\site-packages\hypothesis\extra\__init__.py", line 30, in load_entry_points
package = entry_point.load() # pragma: no cover
File "c:\Python34\lib\site-packages\pkg_resources\__init__.py", line 2309, in load