Skip to content

Instantly share code, notes, and snippets.

View dreid's full-sized avatar
💭
Archived

dreid dreid

💭
Archived
View GitHub Profile

Keybase proof

I hereby claim:

  • I am dreid on github.
  • I am dreid (https://keybase.io/dreid) on keybase.
  • I have a public key whose fingerprint is 0F83 CC87 B32F 482B C726 B58A 9FBF D8F4 DA89 6D74

To claim this, I am signing this object:

#!/usr/bin/env escript
%% -*- erlang -*-
main(_) ->
code:add_path("effigy/src"),
io:format("-- Before --~n~p~n", [hello:module_info()]),
{ok, _Cover} = cover:start(),
{ok, CoverModule} = cover:compile("hello.erl"),
(defun add-to-PATH (dir)
"Add the specified path element to the Emacs PATH"
(interactive "DEnter directory to be added to PATH: ")
(if (file-directory-p dir)
(setenv "PATH"
(concat (expand-file-name dir)
path-separator
(getenv "PATH")))))
(defun activate-virtualenv (dir)
@dreid
dreid / blogger2blogofile.py
Created January 21, 2011 09:45
Import an atom feed to blogofile markdown files.
#!/usr/bin/env python
import os
import re
import sys
import urllib
import datetime
from xml.etree import ElementTree as ET
MARKDOWN_TEMPLATE="""
---
<li>
<a href="{{link}}">
{{title}} &mdash; {{author_name}}
</a>
</li>
@dreid
dreid / stub_mochiweb_request.erl
Created March 11, 2011 22:14
Manually construct a parameterized module… the advantage here is multiple new functions and other static functions which do not take a module argument.
%% @author David Reid <dreid@mochimedia.com>
%% @copyright 2011 Mochi Media, Inc.
%% @doc Stub MochiWeb HTTP Request module implementation for testing.
-module(stub_mochiweb_request).
-record(stub_mochiweb_request, {options, headers, response_pid}).
%% Constructors and static method exports
@dreid
dreid / multiple_expect_results.erl
Created April 11, 2011 18:05
A rather convoluted mechanism for getting subsequent calls to a mecked function to return different results.
-module(multiple_expect_results).
-include_lib("eunit/include/eunit.hrl").
multiple_results_test() ->
ok = meck:new(some_mod),
meck:expect(some_mod, get_pid, fun() -> self() end),
meck:expect(some_mod, some_fun,
fun() ->
receive
@dreid
dreid / gist:1111000
Created July 28, 2011 05:08
SpiderOak apparently uses twisted.
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted/internet/_sigchld.so
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted/internet
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted/protocols/_c_urlarg.so
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted/protocols
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted/python/_initgroups.so
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted/python
SpiderOak.app//Contents/Resources/lib/python2.7/lib-dynload/twisted
@dreid
dreid / bstrip.erl
Created August 26, 2011 20:34
Efficient binary strip?
-module(bstrip).
-export([bstrip/1, bstrip/2]).
bstrip(Bin) ->
bstrip(Bin, both).
bstrip(Bin, left) ->
blstrip(Bin);
@dreid
dreid / blah.erl
Created August 27, 2011 00:13
proper:quickcheck eunit integration using a test generator to have one line of output per property.
proper_test_() ->
Properties = lists:filter(fun({F, _}) ->
case atom_to_list(F) of
"prop_" ++ _Rest ->
true;
_ ->
false
end
end,
bstrip_props:module_info(exports)),