Skip to content

Instantly share code, notes, and snippets.

View MetroWind's full-sized avatar
🐱
Setting status…

Metro Wind MetroWind

🐱
Setting status…
View GitHub Profile
@MetroWind
MetroWind / convert.sh
Last active October 13, 2021 09:19
High-pass filter + binarize in Imagemagick
# convert -bias 50% -morphology Convolve DoG:0,0,10 -threshold 40% source.png result.png
convert input.jpg \( -clone 0 -blur 0x100 \) \( -clone 0 -clone 1 +swap -compose mathematics -set option:compose:args "0,1,-1,0.5" -composite \) -delete 0,1 -threshold 40% result.png
@MetroWind
MetroWind / halftone.pde
Created January 20, 2017 02:32
Processing program to generate "halftone" pattern.
void setup() {
size(4096, 2048);
// The background image must be the same size as the parameters
// into the size() method. In this program, the size of the image
// is 640 x 360 pixels.
background(0);
noStroke();
noLoop();
}
@MetroWind
MetroWind / test.py
Last active December 7, 2016 00:55
Emacs python-mode docstring fill bug. Emacs fills the 1st line of a docstring incorrectly. The fill width is counted from the """, where for the rest of the lines, the fill is counted from the beginning of the line. See bugs https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20860 and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=21254
# -*- fill-column: 40; -*-
def f():
"""a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a a
a a a a a
"""
def f():
"""a a a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a
a a a a a a a
@MetroWind
MetroWind / start.sh
Created March 17, 2016 02:53
Raspberry Pi video streaming
#!/usr/bin/env bash
Width=1296
Height=972
Fps=15
Bitrate=2000 # In Kb/s
BitrateRaw=$((${Bitrate} * 1024))
raspivid -t 0 -w ${Width} -h ${Height} -b ${BitrateRaw} -fps ${Fps} -ih -n -o - | \
cvlc stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
@MetroWind
MetroWind / .py
Last active March 2, 2016 17:08
Make multiprocessing work with methods #python
# Make multiprocessing work with methods. Add this to the beginning of file.
if sys.version_info.major == 2:
import copy_reg as CReg
else:
import copyreg as CReg
import types
def _reduce_method(m):
if m.im_self is None:
return getattr, (m.im_class, m.im_func.func_name)
@MetroWind
MetroWind / .py
Created March 2, 2016 16:55
Iterator over a set while removing elements #python
myset = set([3,4,5,6,2])
while myset:
myset.pop()
print myset
@MetroWind
MetroWind / MakeCurve.py
Created December 4, 2015 05:15
Create a curve in Blender.
import bpy
import math
import numpy
from mathutils import Vector
w = 1 # weight
Scale = 0.03
def readCoords(filename):
with open(filename, 'r') as File:
@MetroWind
MetroWind / lorenz.nb
Created December 4, 2015 05:11
Mathematica code that calculate the Lorenz attractor.
Clear[Evaluate[Context[] <> "*"]];
SetDirectory[NotebookDirectory[]];
sigma = 10;
rho = 28;
beta = 8/3;
tMax = 50;
s = NDSolve[{x'[t] == sigma*(y[t] - x[t]),
y'[t] == x[t]*(rho - z[t]) - y[t], z'[t] == x[t]*y[t] - beta*z[t],
x[0] == 1, y[0] == 1, z[0] == 1}, {x, y, z}, {t, 0, tMax},
AccuracyGoal -> 20, PrecisionGoal -> 20, WorkingPrecision -> 40,
@MetroWind
MetroWind / Sudoku.py
Created November 24, 2015 03:37
A library to work with Sudokus.
import copy
class Sudoku(object):
"""The Sudoku class. Zero means blank."""
Numbers = set(range(1, 10))
def __init__(self, sudoku=None):
if sudoku:
self.Data = copy.deepcopy(sudoku.Data)
else:

Keybase proof

I hereby claim:

  • I am MetroWind on github.
  • I am metrowind (https://keybase.io/metrowind) on keybase.
  • I have a public key whose fingerprint is 53D7 9D02 1875 A1EE 25DC 8897 535C FE44 3159 73CE

To claim this, I am signing this object: