Skip to content

Instantly share code, notes, and snippets.

map_osm = folium.Map(location=[45.5236, -122.6750], zoom_start=12)
map_osm
@auselen
auselen / ftpput.py
Created December 13, 2015 23:03
Simple ftp upload client using ftplib
import os
import sys
from ftplib import FTP
# python ftpput.py [server] [dir_on_server] [local_dir]
ftp = FTP(sys.argv[1])
ftp.login()
ftp.cwd(sys.argv[2])
@auselen
auselen / http_response_codes.json
Created January 21, 2016 12:17
simple http response codes dictionary / json - scrapped from https://github.com/for-GET/know-your-http-well
{"1xx":"**Informational**",
"100":"Continue",
"101":"Switching Protocols",
"2xx":"**Successful**",
"200":"OK",
"201":"Created",
"202":"Accepted",
"203":"Non-Authoritative Information",
"204":"No Content",
"205":"Reset Content",
@auselen
auselen / AWK_Sphere.md
Created February 13, 2017 16:28
Rendering a sphere with AWK

Rendering a sphere with AWK

Sphere

sphere.gif

Code

LC_ALL=ISO-8859-1 awk 'BEGIN{ \
  pi=atan2(0,-1); r=128; \
  for (j=0; j<360; j+=10) { \
    lx=cos(pi/180*j); ly=sin(pi/180*j); lz=2; lm=sqrt(lx*lx+ly*ly+lz*lz); \
 print "P6"; print r*2,r*2; print "255"; \
@auselen
auselen / π.md
Last active March 24, 2017 15:23

Code

 awk 'BEGIN{srand(); while (++i) {pi += ((rand()**2+rand()**2) <= 1); if ((i%10e5) == 0) printf "%f\n",4*pi/i;}}'

Result

3.140352
3.139892
@auselen
auselen / ♡.md
Last active August 28, 2023 21:43
Drawing a heart with AWK

Drawing a heart with AWK

Heart

Math

  • t = 0 → 2𝜋
  • x = 16 sin³(t)
  • y = 13 cos(t) - 5 cos(2 t) - 2 cos(3 t) - cos(4 t)

Code

@auselen
auselen / mandelbrot.md
Last active March 24, 2017 15:17
Drawing Mandelbrot with AWK

Drawing Mandelbrot with AWK

Mandelbrot

Code

$ LC_ALL=ISO-8859-1 awk 'BEGIN { \
 max=256; \
@auselen
auselen / pi.py
Created March 14, 2017 12:51
Pi approximation
from random import random
l = lambda (a, b), c: (a + c, b + 1)
g = (1 if random()**2 + random()**2 <= 1 else 0 for i in range(10**6))
r, t = reduce(l, g, (0.0, 0))
print r / t * 4
@auselen
auselen / pi.py
Created March 16, 2017 14:11
Shorter Pi approximation
from random import random
print 4 * reduce(lambda a, (c, d): (a * (d - 1) + c) / d, ((1.0 if random()**2 + random()**2 <= 1 else 0, i) for i in range(1, 10**6)), 0)

TR Map

Map

Code

curl -s http://download.maxmind.com/download/worldcities/worldcitiespop.txt.gz \