Skip to content

Instantly share code, notes, and snippets.

View oubiwann's full-sized avatar
💭
🌌

Duncan McGreggor oubiwann

💭
🌌
View GitHub Profile
@oubiwann
oubiwann / setup.hy
Last active August 29, 2015 13:56
A setup.hy for Hy Lang projects
;; This can be called like so to build your Hy-based project:
;; $ hy setup.hy build
;;
(import
[setuptools
[setup find_packages]]
[hyhop
[meta]])
@oubiwann
oubiwann / 01-maps.erl
Last active August 29, 2015 13:57
Multi-language Maps Comparison
%% create a new map
A = #{key1 => Val1, key2 => Val2, ...}
%% pattern match a map
#{key1 := Pattern1, key2 := Pattern2, ...} = VarContainingAMap
%% updating a map with new key/value pairs
NewX = X#{ key1 => Val1, ... KeyN => ValN, ...}
%% updating a map with new values for keys that already exist
@oubiwann
oubiwann / 01-maps.erl
Last active August 29, 2015 13:58
Thought Experiment in Maps Syntax for LFE
A = #{key1 => Val1, key2 => Val2, ...}
> (: io write (java.lang.System:getProperty '"java.io.tmpdir"))
=INFO REPORT==== 7-Apr-2014::15:22:31 ===
Process <0.0.1139> exited abnormally without links/monitors
exit reason was: {badarg,[{lfe_io_pretty,print1,["/var/folders/c8/2cl5l5_102b1qq8bh05t7xw40000gn/T/"],[{file,"lfe_io_pretty.erl"},{line,-1}]},{lfe_io_pretty,print1_tail_max,5,[{file,"lfe_io_pretty.erl"},{line,156}]},{lfe_io_pretty,print1,4,[{file,"lfe_io_pretty.erl"},{line,62}]},{lfe_lib,'-format_stacktrace/3-fun-0-',1,[{file,"lfe_lib.erl"},{line,335}]},{lists,map,3,[]},{lfe_lib,format_stacktrace,3,[{file,"lfe_lib.erl"},{line,341}]},{lfe_lib,format_exception,6,[{file,"lfe_lib.erl"},{line,325}]},{lfe_shell,server_loop,1,[{file,"lfe_shell.erl"},{line,105}]}]}
java trace: erjang.ErlangError: {badarg,[{lfe_io_pretty,print1,["/var/folders/c8/2cl5l5_102b1qq8bh05t7xw40000gn/T/"],[{file,"lfe_io_pretty.erl"},{line,-1}]},{lfe_io_pretty,print1_tail_max,5,[{file,"lfe_io_pretty.erl"},{line,156}]},{lfe_io_pretty,print1,4,[{file,"lfe_io_pretty.erl"},{line,62}]
Debug print 1 (lfe_io_pretty.erl):
print1([Car|_]=List, D, I, L) ->
%% Handle printable lists specially.
case io_lib:printable_list(List) of
true ->
%% XXX debug
io:format("Made it here: 'print1([Car|_]=List, D, I, L case true' ...~n"),
io:format("Processing: ~w ...~n", [List]),
lfe_io:print1_string(List, $"); %"
@oubiwann
oubiwann / maps.lfe
Created April 11, 2014 16:46
Erlang 17.0 Maps in LFE
Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
LFE Shell V6.0 (abort with ^G)
> (maps:new)
#{}
> (maps:put '"dog" '"winston" (maps:new))
#{[100,111,103]=>[119,105,110,115,116,111,110]}
> (set pets (maps:put '"fish" '"mrs.blurb" (maps:put '"dog" '"winston" (maps:new))))
#{[100,111,103]=>[119,105,110,115,116,111,110],[102,105,115,104]=>[109,114,115,46,98,108,117,114,98]}
@oubiwann
oubiwann / debug1.erl
Last active August 29, 2015 13:59
Still Debugging LFE + Erjang
print1([Car|_]=List, D, I, L) ->
%% Handle printable lists specially.
case io_lib:printable_list(List) of
true ->
% DEBUG
io:format("Yup, it's a printable list.~n"),
"";
false ->
...
@oubiwann
oubiwann / test-output.txt
Created April 20, 2014 00:43
lfe with lfunit in new stdlib
$ make check
lfetool tests unit
Removing old tests ...
rm -rf ./.eunit
Compiling tests ...
find: ./deps: No such file or directory
./test/testing[-_]*.lfe:none: no such file or directory
Successfully compiled testing support modules.
find: ./deps: No such file or directory
./test/unit/unit-lfunit-tests.lfe:84: Warning: this expression will fail with a 'badarith' exception
@oubiwann
oubiwann / Preferences.sublime
Created April 22, 2014 04:24
Sublime Text 3 Prefs
{
"color_scheme": "Packages/Theme - Vim Blackboard/VimBlackboard.tmtheme",
"default_line_ending": "linux",
"drag_text": false,
"ensure_newline_at_eof_on_save": true,
"ignored_packages":
[
""
],
"rulers":
@oubiwann
oubiwann / .bashrc
Last active August 29, 2015 14:00
Bash RC
[ -z "$PS1" ] && return
export HISTCONTROL=ignoreboth
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes