Skip to content

Instantly share code, notes, and snippets.

View cobalamin's full-sized avatar
👾

Simon Welker cobalamin

👾
View GitHub Profile
@cobalamin
cobalamin / gist:3517d051c3cb8b5a7dc5
Created July 15, 2014 20:14
Tomorrow Palette SVG
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
@cobalamin
cobalamin / private.xml
Last active August 29, 2015 14:15 — forked from carwin/private.xml
Programmer's Shift Keys: Remapping shift keys + modifiers to parens, brackets and braces.
<?xml version="1.0"?>
<root>
<item>
<name>Programmer's Shift Keys</name>
<!--
Author: Carwin Young (@carwin)
Edited by Simon Welker (@chipf0rk)
Last Updated: 2015-02-18
v.1.2
@cobalamin
cobalamin / xcape-shiftparens.md
Last active August 29, 2015 14:16
xcape shiftparens on Fedora 21

Clone the xcape repo, install its dependencies:

yum install gcc make libX11-devel libXtst-devel libXi-devel

then make, and move xcape to /usr/local/bin.

Create/Edit /etc/gdm/PostLogin/Default, with the minimum content of:

@cobalamin
cobalamin / myps1.md
Last active August 29, 2015 14:16
PS1 with cwd + username-based coloured lambda

Preview

# Enable 256 colors!
export TERM=xterm-256color
# PS1
USERCOLOR=`whoami | md5sum | cut -c1-6 | xargs python /home/chipf0rk/dev/lib/colortrans.py`
PS1='\[\e[0m\]\[\e[00;36m\]\W\[\e[0m\]\[$USERCOLOR\]λ\[\e[0m\] '
@cobalamin
cobalamin / 256colors.md
Created February 28, 2015 12:34
Make the terminal a 256color terminal, e.g. for Emacs themes
# Colors!
export TERM=xterm-256color
@cobalamin
cobalamin / lcg-deadlocks.clj
Created March 7, 2015 16:02
A little bit of LCG analysis fun in Clojure
(defn rng [conf]
(let [{:keys [a b m]} conf]
(fn [x]
(mod (+ (* a x) b) m))))
(defn recurredly [f seed]
(lazy-seq
(let [res (f seed)]
(cons res
(recurredly f res)))))
@cobalamin
cobalamin / do-if.clj
Created May 3, 2015 10:59
do-if macro in Clojure
;; A small macro that enables if-else syntax without explicit do-blocks.
;; Example usage:
(comment
(do-if (= slang :british)
(println "oh bloody hell mate")
:posh-face
:else
(println "f*** dude")
:angry-face))
@cobalamin
cobalamin / MonkeyBananaPeel.swift
Last active August 29, 2015 14:20
Swift Optional chaining == flatMap
// An (admittedly silly) demonstration of how optional chains in Swift
// are equivalent to flatMapping over each optional.
//
// You can, in your mind, replace every `?.x` by a `flatMap { $0.x }` call.
class Peel {
var color: String
init(color: String) { self.color = color }
}
class Banana {
@cobalamin
cobalamin / gtgteq.swift
Last active March 15, 2021 14:07
>>=, the "monad" bind operator, in Swift
infix operator >>= {
associativity left
precedence 160
}
func >>=<S: SequenceType, T>(source: S, transform: S.Generator.Element -> [T]) -> [T] {
return flatMap(source, transform)
}
func >>=<C : CollectionType, T>(source: C, transform: (C.Generator.Element) -> [T]) -> [T] {
return flatMap(source, transform)
@cobalamin
cobalamin / nasa-img-of-the-day.js
Created May 20, 2015 08:27
Fetch all available/listed NASA images of the day. Can be run through cron, executed by node.
var rss_url = 'http://www.nasa.gov/rss/dyn/lg_image_of_the_day.rss';
var directory = '?';
var FeedParser = require('feedparser'),
request = require('request'),
fs = require('fs'),
path = require('path');
var feedparser = new FeedParser(),
req = request(rss_url);