Skip to content

Instantly share code, notes, and snippets.

@bradfordw
bradfordw / hardwork.sh
Last active November 4, 2015 21:46 — forked from robertoaloi/hardwork.sh
Count the number of lines of an Erlang application (excluding comments, type specs, empty lines).
# for osx users
find . -type f \( -name "*.erl" -or -name "*.hrl" -or -name "*.app.src" \) -exec cat {} \; | sed '/^\s*$/d;/^\s*\%\%/d;/^\-spec*/d' | wc -l
-module(exp_parser).
-export([parse/1]).
% Parse simple math expressions.
% Currently works (for certain definitions of "works")
% for addition, subtraction and multiplication.
% Eventually it should handle a unary negation operator (~)
% The goal is to do the following:
% parse("(2 + 3)") => {plus, {num, 2}, {num, 3}}
@bradfordw
bradfordw / gist:599482
Created September 27, 2010 17:52 — forked from jbynum/gist:599440
$text = $tweet->title;
$text = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $text);
$text = preg_replace("#(^|[\n ])([a-z]+:\/\/\S+[^ \.{1,3}$])#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $text);
$text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $text);
# mongo_template.rb
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842)
#
# To use:
# rails project_name -m http://gist.github.com/gists/219223.txt
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
-module(histo).
-compile(export_all).
-define(WORDS,[ "a", "at", "red", "green", "dog"]).
parse_input(Input) ->
lists:foldl(fun(Letter, D) -> dict:update(Letter, fun(N) -> N + 1 end, 1, D)
end, dict:new(),
[L || L <- Input]).
start_find(InputHisto) ->
@bradfordw
bradfordw / rlsp.rb
Created November 9, 2009 14:07 — forked from h0rs3r4dish/rlsp.rb
#!/usr/bin/ruby
RLSP_VERSION = "1.4.1"
class Lambda
attr_accessor :args, :body
def initialize(args=[],body="")
@args = (args.class == Array) ? args : [args]
@body = body
end
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char** argv) {
char protein[4] = "ACGT";
int size = atoi(argv[1]);
int i = 0;
int pos = 0;
for(i; i < size; ++i) {