This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(coinchange). | |
-export([coinchange/2]). | |
coinchange(_, {sorted, []}) -> | |
[]; | |
coinchange(A, {sorted, [C | CS]}) when A < C -> | |
coinchange(A, {sorted, CS}); | |
coinchange(A, {sorted, [C | CS]}) -> | |
[C | [coinchange(A-C, {sorted, [C | CS]}) ]]; | |
coinchange(A, C) -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% filename clashes with erlang module btree! | |
-module(btree). | |
-export([find/2, min/1, max/1, insert/1, insert/2, print/1, print/2]). | |
-record(node, {val, left = nil, right = nil}). | |
%% find a specific value in a tree, or not_found | |
find(Value, Node) when Value == Node#node.val -> | |
{ok, Node}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% First try at making a small IRC bot. | |
%% Dedicated to ThordenM. | |
%% | |
%% Rune Juhl Jacobsen, 2012 | |
-module(irc). | |
-compile(export_all). | |
-define(NICK, "lolcat"). | |
-define(USERNAME, "lolcatzz"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(boss_db_sql). | |
-compile(export_all). | |
%% Much more elaborate version -- and with comments! | |
%% Drop in src/lib/ to be able to use it from anywhere in CB. | |
%% Return just the values from an executed SQL query. | |
sql(S) -> | |
{ok, ColNames, Values} = boss_db:execute(S), | |
Values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4> T = tag:new(id, "erlang", false). | |
{tag,id,"erlang",false} | |
5> T:save(). | |
{error,{error,error,<<"23505">>, | |
<<"duplicate key value violates unique constraint \"tags_name_key\"">>, | |
[{detail,<<"Key (name)=(erlang) already exists.">>}]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i, j; | |
for (i = 0; i < array.lenght(); i++) { | |
if ((j = array[i] * 2) > 10) | |
j = j % 10 + 1; | |
array[i] = j; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{boss, [ | |
{path, "/home/runejuhl/projects/dependencies/erlang/ChicagoBoss"}, | |
{vm_cookie, "lollo"}, | |
{applications, [runejerl, cb_admin]}, | |
{db_host, "localhost"}, | |
{db_database, "runejerl"}, | |
{db_port, 5432}, | |
{db_username, "runejerl"}, | |
{db_password, "nah"}, | |
{db_adapter, pgsql}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Edit this file and copy it as userChrome.css into your | |
* profile-directory/chrome/ | |
*/ | |
/* | |
* This file can be used to customize the look of Mozilla's user interface | |
* You should consider using !important on rules which you want to | |
* override default settings. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for i in `seq 1 10`; do make > /dev/null && yams buenos initprog=[disk]sleep | tail -n 3 | grep -v kHz| grep --color=never -oE '[0-9]+.[0-9]+' | python -c "import sys | |
lines = [x.strip() for x in sys.stdin.readlines()] | |
print str(float(lines[0])/float(lines[1])) + ' seconds'"; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import subprocess | |
import re | |
import os.path | |
def main(): | |
if len(sys.argv) < 2: | |
print('Missing argument') | |
sys.exit(-1) |
OlderNewer