Skip to content

Instantly share code, notes, and snippets.

@davidblitz
davidblitz / script.sh
Created May 2, 2017 21:45
Minimal Webserver in bash using netcat
#!/bin/bash
while $true
do
{ echo -ne "HTTP/1.0 200 OK\r\nContent-Length: $(wc -c <"$1")\r\n\r\n"; cat "$1"; } | nc -l 8080
#echo -n -> do not output the trailing newline
#echo -e -> enable interpretation of backslash escape
#nc -l -> listen for an incoming connection instead of initiating one
#IS IT POSSIBLE TO SEND A WRONG HTTP REQUEST TO PORT 8080 AND STILL GET THE STANDARD RESPONSE?
#-->test with curl!
@davidblitz
davidblitz / ten-lessons-notes.md
Created May 2, 2017 21:50
Excerpts of a paper by Gian-Carlo Rota on work as a mathematician

Excerpts of "Ten Lessons I Wish I Had Been Taught" by Gian-Carlo Rota

"The advice we give others is the advice that we ourselves need. Since it is too late for me to learn these lessons, I will discharge my unfulfilled duty by dishing them out to you. They will be stated in order of increasing controversiality."

Lecturing

###Lesson 1: Every lecture should only one main point.

@davidblitz
davidblitz / main.c
Last active July 11, 2017 20:33
Mandelbrot Fractal in Terminal with Zoom
int main() {
double z_factor = 2; //zoom factor
double center_x = -0.5; //x coordinate of zoom center
double center_y = 0; //y coordinate of zoom center
double width = 128;
double height = 40;
int k = 0;
double i, j, r, x, y = -height/2;
while(puts(""), y++ < height/2 + 1) {
for(x = 0; x++<width;) {
@davidblitz
davidblitz / 10PRINT 'tunnel-rosette'.pde
Last active September 30, 2017 19:04 — forked from mutterer/10PRINT 'rosette'.pde
// 10PRINT tunnel-rosette Processing 3 code, thanks to @shiffman and @jmutterer!
// 10PRINT rosette Processing 3 code
// thanks to @shiffman and @jmutterer!
static float r=30;
static float s=10;
int i, j;
static int maxI = 60;
static int maxJ = 25;
@davidblitz
davidblitz / sorting-animation.pde
Created October 8, 2017 20:39
Sorting animation for processing (Java)
#insert filename of any image
String fname = "../sample-images/earth.jpg";
#insert width and height of image
int imgWidth = 256;
int imgHeight = 256;
PImage img;
void settings() {
size(imgWidth, imgHeight);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.