Skip to content

Instantly share code, notes, and snippets.

module Foo where
import System.IO
-- define fold
myfold :: (Num b) => [(t, b)] -> b
myfold ((t,b):xs) = foldr (\(t,b) x -> x + b) 0 ((t,b):xs)
-- define writing results to file
@wardbekker
wardbekker / .emacs
Created December 2, 2010 10:18
My configuration to open files in an ssh session and opening them in a local emacs with Tramp
(setq server-socket-dir "~/.emacs.d/server")
(server-start)
@wardbekker
wardbekker / search_and_replace.rb
Created December 10, 2010 09:42
search_and_replace.rb search_keyword replacement
#!/usr/bin/env ruby
puts `find -type f -name '*.php' | xargs perl -pi -w -e 's/#{ARGV[0]}/#{ARGV[1]}/g;'`
@wardbekker
wardbekker / node.hs
Created December 10, 2010 22:28
start worker node with 'node worker' and start commander with 'node commander'. The commander will send a msg to the worker and the worker will respond with "tnx for the fish!". The worker will wait for new commander msg's indefinitely, so stop with CTRL-
{-# LANGUAGE OverloadedStrings #-}
import qualified System.ZMQ as ZMQ
import Data.Binary
import Data.Binary.Put
import Data.Binary.Get
import Data.ByteString.Lazy as LZ
import Data.ByteString as STR
import Data.Bson
import Data.Bson.Binary
@wardbekker
wardbekker / gist:848945
Created March 1, 2011 10:24
Turn of space switching animation in OSX Spaces
defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock
@wardbekker
wardbekker / main.erl
Created April 13, 2011 22:45
A very basic word occurence counter using map/reduce
-module(main).
-export([map/1]).
-export([main/0]).
-export([reducer_wrapper/1]).
-export([reducer/2]).
-define(NUMBER_OF_PARTITIONS, 100).
main() ->
@wardbekker
wardbekker / gist:964146
Created May 10, 2011 09:16
Naive parallel import of Compressed MYSQL dump file
# Split MYSQL dump file
zcat dump.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{print >"out" n ".sql" }'
# Parallel import using GNU Parallel http://www.gnu.org/software/parallel/
ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<"
@wardbekker
wardbekker / gist:978613
Created May 18, 2011 13:58
destruct never called
<?php
// watch how the destructor is never called
set_time_limit(1);
class Foobar {
public function doIt() {
while(true) {
@wardbekker
wardbekker / .travis.yml
Created July 30, 2011 07:33
Travis.yml erlang proposal
# https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
target: erlang
use_rebar: true
erlang_otp:
- R14B03
- R14B02
- R14B01
- R14B
- R14A
- R13B04
Hi,
Travis is an open, distributed build system for the Ruby community.
See http://travis-ci.org/. With the help of the Travis developers I
was able to add Erlang as a build target. Some examples:
Etorrent: http://staging.travis-ci.org/#!/wardbekker/etorrent/builds/3023
Proper: http://staging.travis-ci.org/#!/wardbekker/proper
Zotonic: http://staging.travis-ci.org/#!/wardbekker/zotonic/builds/3107