Skip to content

Instantly share code, notes, and snippets.

@dry
dry / exec.md
Created January 29, 2016 17:45 — forked from omarkj/exec.md
Exec
exec([fun fun1/3, fun fun2/4, fun fun3/1], [Arg1, Arg2, Arg2]).

fun1(Arg1, Arg2, Arg3) ->
  P = proplists:get_value(p, Arg1),
  {ok, [P, Arg1, Arg2, Arg3]}.

fun2(P, Arg1, Arg2, Arg3) ->
  do_stuff(P, Arg1, Arg2),
 {ok, [Arg3]}.
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.
@dry
dry / rc.lua
Created March 5, 2014 23:12
Awesome WM Simple Battery Widget
batterywidget = wibox.widget.textbox()
batterywidget:set_text(" | Battery | ")
batterywidgettimer = timer({ timeout = 5})
batterywidgettimer:connect_signal("timeout",
function()
fh = assert(io.popen("acpi | cut -d, -f 2,3 -", "r"))
batterywidget:set_text(" |" .. fh:read("*.l") .. " | ")
fh:close()
end
)
@dry
dry / .Xresources
Created March 1, 2014 10:29
URxvt Solarized for Awesome WM
URxvt.depth: 32
#URxvt.geometry: 90x30
URxvt.background: rgba:4444/4444/4444/9999
URxvt.scrollBar: false
URxvt.font: xft:Source Code Pro:size=7
URxvt.letterSpace: -2
URxvt.foreground: rgb:bbbb/bbbb/bbbb
Xft.dpi: 144
Xft.antialias: true
import unittest, os, os.path, sys, urllib
import tornado.database
import tornado.options
from tornado.options import options
from tornado.testing import AsyncHTTPTestCase
# add application root to sys.path
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
@dry
dry / .bashenv
Last active September 7, 2016 16:00
Set/unset per directory environment variables for development projects
SHOPIFY_CLIENT_ID "123456789"
@dry
dry / update
Created October 9, 2013 22:32
Update all git repositories in a directory
#!/usr/bin/env escript
%%! -smp enable -sname update
main([Path]) ->
SPath = string:strip(Path, right, $/),
{ok, Dirs} = file:list_dir(SPath),
[files(SPath ++ "/" ++ Dir) || Dir <- Dirs];
main(_) ->
io:format("Usage: update [path/to/directory]~n").
@dry
dry / gist:6636840
Last active December 23, 2015 12:39
Remove show message redirect from Cookie Consent module
<?php
// ... rest of module stuff
/**
* Set the 'cookies_allowed' cookie
*
* @access public
* @return string
*
@dry
dry / gist:6144045
Created August 2, 2013 22:40
Erlang - extract beam function attributes.
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]).
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
@dry
dry / gist:6007806
Created July 16, 2013 11:09
Emacs dired quick access key map
(define-key evil-normal-state-map ",f" (lambda ()
(interactive)
(dired default-directory)
))