Skip to content

Instantly share code, notes, and snippets.

View aerosol's full-sized avatar
👐
You're absolutely right!

Adam Rutkowski aerosol

👐
You're absolutely right!
View GitHub Profile
@aerosol
aerosol / log4otp_formatters.erl
Created May 24, 2011 08:15
Erlang & strings - can't hate them
iso_8601_fmt(DateTime) ->
{{Year,Month,Day},{Hour,Min,Sec}} = DateTime,
io_lib:format("~4.10.0B-~2.10.0B-~2.10.0B ~2.10.0B:~2.10.0B:~2.10.0B",
[Year, Month, Day, Hour, Min, Sec]).
ts() ->
io_lib:format("~s", [iso_8601_fmt(erlang:localtime())]).
@aerosol
aerosol / inet_drv.c.patch
Created August 11, 2011 12:56
erlang R14B03 patch - makes SCTP work on OSX
--- inet_drv.c.orig 2011-08-11 14:46:15.000000000 +0200
+++ inet_drv.c 2011-08-11 14:48:13.000000000 +0200
@@ -3453,9 +3453,11 @@
/* Check the size of SCTP AssocID -- currently both this driver and the
Erlang part require 32 bit: */
ASSERT(sizeof(sctp_assoc_t)==ASSOC_ID_LEN);
-# ifndef LIBSCTP
-# error LIBSCTP not defined
-# endif
+/*# ifndef LIBSCTP*/
@aerosol
aerosol / procport.py
Created August 23, 2011 17:11
Stdin pipe wrapper
#!/usr/bin/env python
import sys
import time
import os
import resource
import subprocess
def spawn(proc):
kw = {
{deps, [
{binpp, ".*", {git, "git://github.com/aerosol/binpp.git", "master"}}
]}.
@aerosol
aerosol / gist:1293679
Created October 17, 2011 20:20
Dynamic compilation
validate_rules() ->
?SYS_INFO("Validating common rules configuration..."),
case compile:file(?PRIV("common_rules.erl"), [strong_validation, report, return, {i, ?PRIV("../include")}]) of
{ok, _, _} ->
?SYS_DEBUG("File common_rules.erl validated successfully"),
ok;
{ok, _, _, Warnings} ->
ok;
{ok, _, _, Warnings} ->
case Warnings of
-module(rules).
-compile([export_all]).
%% quick n dirty sketch
%%
%% example:
%%
%% rules.txt
%%
%% route foo_backend when recipient matches "[0-9]{4}"
+---------------------------------------------------+
| The following takes place between 03:00 and 04:30 |
+---------------------------------------------------+
03:00 * toxik snickers
03:02 < toxik> [in #php]
03:02 < toxik> <@toxik> PHP -- one of few languages where a string can be false
without being empty.
03:02 < toxik> <@toxik> And that's a god damn feature. :-)
03:02 < toxik> < Seph> a string should be neither true nor false, it should be
" Undo & history {{{
set history=1000
set undolevels=1000
" make sure tmp dir is created
silent execute '!mkdir ~/.vim/tmp > /dev/null 2>&1'
" delete junk older than 3 days
silent execute '!find ~/.vim/tmp/ -type f -mtime +3 -exec rm {} \;'
set undofile
set undodir=~/.vim/tmp
set backup
unconsult(File, L) ->
{ok, S} = file:open(File, write),
lists:foreach(fun(X) -> io:format(S, "~p.~n",[X]) end, L),
file:close(S).
#!/bin/bash
echo "Number of commits per author:"
git --no-pager shortlog -sn --all
AUTHORS=$( git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
OVERALL_ADDED=0
OVERALL_DELETED=0
OVERALL_CHANGED=0
for a in $AUTHORS
do
echo "Statistics for: $a"