Skip to content

Instantly share code, notes, and snippets.

@ntlk
ntlk / grep.py
Last active August 1, 2021 18:59
grep made bad in python
import sys
import re
pattern = re.compile(sys.argv[1])
last = int(len(sys.argv)) - 1
reverse = True if sys.argv[last] == '-v' else False
lines = sys.stdin.readlines()
for line in lines:
if bool(pattern.search(line)) != reverse:
sys.stdout.write(line)
@ntlk
ntlk / sort.py
Last active December 25, 2015 11:18
sort tool imagined in python
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-r', action='store_const', const=True, required=False)
args = parser.parse_args()
lines = sys.stdin.readlines()
lines.sort(reverse = args.r)
for line in lines:
@ntlk
ntlk / uniq_uniq.py
Last active December 25, 2015 09:29
actually unique uniq implemented in python
import sys
import argparse
import collections
parser = argparse.ArgumentParser()
parser.add_argument('-c', action='store_const', const=True, required=False)
args = parser.parse_args()
lines = sys.stdin.readlines()
counter = collections.Counter(lines)
@ntlk
ntlk / uniq.py
Last active August 1, 2021 18:59
uniq implemented in python
import sys
last_line = None
for line in sys.stdin.readlines():
if line != last_line:
sys.stdout.write(line)
last_line = line
/*------- Grid -------*/
$total-columns: 8; // 8 columns
$column-width: 4.5em; // columns are 4.5em wide
$gutter-width: 2em; // with 2em gutters
$grid-padding: 1em; // and 1em padding on the grid container
$container-style: magic;
.wrapper__inner {
@include clearfix();
@ntlk
ntlk / PHP on Pow - config.ru
Last active December 11, 2015 07:09 — forked from brookr/config.ru
Run any site on pow instead of apache
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson ([email protected])
# clearly this could be cleaner, but it does work
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
# patch Php from rack-legacy to substitute the original request so
# WP's redirect_canonical doesn't do an infinite redirect of /
@ntlk
ntlk / pygments.css
Created December 4, 2012 13:40 — forked from zmanji/pygments.css
Solarized Pygments Dark CSS
.highlight{background-color:#073642;color:#93a1a1}.highlight .c{color:#586e75 !important;font-style:italic !important}.highlight .cm{color:#586e75 !important;font-style:italic !important}.highlight .cp{color:#586e75 !important;font-style:italic !important}.highlight .c1{color:#586e75 !important;font-style:italic !important}.highlight .cs{color:#586e75 !important;font-weight:bold !important;font-style:italic !important}.highlight .err{color:#dc322f !important;background:none !important}.highlight .k{color:#cb4b16 !important}.highlight .o{color:#93a1a1 !important;font-weight:bold !important}.highlight .p{color:#93a1a1 !important}.highlight .ow{color:#2aa198 !important;font-weight:bold !important}.highlight .gd{color:#93a1a1 !important;background-color:#372c34 !important;display:inline-block}.highlight .gd .x{color:#93a1a1 !important;background-color:#4d2d33 !important;display:inline-block}.highlight .ge{color:#93a1a1 !important;font-style:italic !important}.highlight .gr{color:#aa0000}.highlight .gh{color:#586e
@ntlk
ntlk / gist:2843580
Created May 31, 2012 13:58
Arduino Theremin
/**
* A simple theremin
* Developed by the random bit
* http://therandombit.wordpress.com/2011/11/21/light-controlled-ldr-theremin/
*
*/
int val = 0;
void setup() {
@ntlk
ntlk / dabblet.css
Created April 27, 2012 10:32
Flying a plane
/**
* Flying a plane
*/
#fly {
width: 300px;
background: #cacaca;
position: fixed;
right: -300px;
animation: fly 8s ease-in;
@ntlk
ntlk / dabblet.css
Created April 21, 2012 19:42
Sea waves
/**
* Sea waves
*/
#sky {
width: 100%;
height: 600px;
position: fixed; }
#sea {