Skip to content

Instantly share code, notes, and snippets.

View wereHamster's full-sized avatar
🌍
Lower Your Eyelids To Die With The Sun

Tomáš Čarnecký wereHamster

🌍
Lower Your Eyelids To Die With The Sun
View GitHub Profile
#!/bin/sh
RELEASE="precise"
VOLUME="volume"
HOSTNAME="$1"
MIRROR="http://ipv6.archive.ubuntu.com/ubuntu"
if ! test -d "$VOLUME"; then
btrfs subvol create "$VOLUME"
debootstrap --verbose --arch=amd64 --include=apt,vim,ssh "$RELEASE" "$VOLUME" "$MIRROR"
brctl addbr lxc
ip link set brctl up
/etc/rc.d/radvd restart
/etc/rc.d/aiccu restart
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
package models
/* A scope defines what actions a user can perform. Each possible action is
* assigned a bit in a bitset (up to 64 different actions are possible in
* theory, though we only store a limited number of bits in the database).
*/
sealed case class Scope(value: Long) {
/* Combine two scopes. Does a bitwise or of the two bitsets and returns a
#!/bin/sh
# This script nukes the author (identity and time) of all commits since the
# given rev. This is useful if you want to disguise the true time when you
# wrote the commits, as a normal rebase will only reset the committer identity
# and time.
GIT_EDITOR="sed -i '' -e 's/pick/edit/g'" git rebase -i $1
while true; do
GIT_EDITOR=true git commit --amend --reset-author
#/usr/bin/bash
# Add ifndef/define/endif to headers which use pragma once. I used
# it to edit some C++ project which wouldn't compile because the
# compiler didn't understand pragma once. SunCC, I'm looking at you!
~/bin/ack -l 'pragma once' | while read file; do
f="${file//\//_}"
f="${f//./_}"
#!/usr/bin/env bash
# Do an octopus merge and select a strategy for each branch you
# want to merge.
STRATEGY="recursive"
HEADS=( $(git rev-parse HEAD) )
git checkout HEAD^{}
while [ $# -gt 0 ]; do
@wereHamster
wereHamster / pascal.hs
Created January 24, 2013 07:57
primitive pascal triangle code in haskell
reduce :: [Int] -> [Int]
reduce (x:rest@(y:z)) = (x + y) : (reduce rest)
reduce _ = []
pascal :: Int -> [Int]
pascal 1 = [1]
pascal 2 = [1,1]
pascal x = [1] ++ reduce (pascal (x - 1)) ++ [1]
main = do
reduce :: [Int] -> [Int]
reduce (x:rest@(y:z)) = (x + y) : (reduce rest)
reduce _ = []
pascal :: Int -> [Int]
pascal 1 = [1]
pascal 2 = [1,1]
pascal x = [1] ++ reduce (pascal (x - 1)) ++ [1]
center :: Int -> String -> String
@wereHamster
wereHamster / genpass.js
Created July 13, 2013 08:12
Generate a random password from as many keys as there are on a standard US layout keyboard.
#!/usr/bin/env node
var chars =
[ 'abcdefghijklmnopqrstuvwxyz'
, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
, '1234567890'
, '~!@#$%^&*()_a+'
, '`-='
, '[]{}o\'O",./<>?'
].join();