Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍
Lower Your Eyelids To Die With The Sun

Tomas Carnecky wereHamster

🌍
Lower Your Eyelids To Die With The Sun
View GitHub Profile
View pascal.hs
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 / pascal.hs
Created Jan 24, 2013
primitive pascal triangle code in haskell
View pascal.hs
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
View stack-test.cabal
name: stack-test
version: 0.0.1
author: Tomas Carnecky
maintainer: tomas.carnecky@gmail.com
build-type: Simple
cabal-version: >= 1.10
View git-mm.sh
#!/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
View wrap-headers
#/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//./_}"
View git-nuke-author.sh
#!/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
View scope.scala
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
View gist:3058536
#!/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"
View setup-container-host
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
View mail-archiver.rb
#!/usr/bin/env ruby
require 'pathname'
require 'mail'
class Archiver
attr_reader :maildir, :time
def initialize(maildir)
@maildir = maildir