Skip to content

Instantly share code, notes, and snippets.

== Rebar.config:
{erlydtl_opts,[{translation_fun, {agigo_util, translate}}]}.
== Error:
DEBUG: Worker compilation failed: {{error,
{'EXIT',
{badarg,
@wardbekker
wardbekker / leetcode.erl
Created December 24, 2014 10:16
Finding the Minimum Window in S which Contains All Elements from T
-module(leetcode).
-export([min_window/0]).
%% Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
%% For example,
%% S = "ADOBECODEBANC"
%% T = "ABC"
%% Minimum window is "BANC".
@wardbekker
wardbekker / cloudflare_ips.sh
Created April 21, 2015 09:22
Cloudflare ipv4 iptable rules
for i in `curl https://www.cloudflare.com/ips-v4`; do iptables -I INPUT -p tcp -s $i -m multiport --dports http,https -j ACCEPT; done
iptables -A INPUT -p tcp --dport http -j DROP
iptables -A INPUT -p tcp --dport https -j DROP
iptables-save > /etc/iptables/rules.v4
# web cluster nodes
# in this setup we have three local application servers
upstream web-cluster {
server a4.mzstatic.com;
#server 10.0.0.12;
#server 10.0.0.13;
}
# force redirect of http to https
# application will be available only over https
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() ->