Skip to content

Instantly share code, notes, and snippets.

View rickhull's full-sized avatar

Rick Hull rickhull

View GitHub Profile
rwh@dadtop:~$ sudo apt-get install carla
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libavahi-client3:i386 libavahi-common-data:i386 libavahi-common3:i386
libcapi20-3 libcapi20-3:i386 libcups2:i386 libgd2-xpm libgd2-xpm:i386
libgif4:i386 libgmp10:i386 libgnutls-deb0-28:i386 libgphoto2-2
libgphoto2-2:i386 libgphoto2-port0:i386 libgphoto2-port0
libgssapi-krb5-2:i386 libhogweed2:i386 libieee1284-3:i386 libk5crypto3:i386
[INFO]: LV2: Discovering 0 plugins
[INFO]: Loading menus from /etc/ardour3/ardour.menus
[INFO]: Loaded mixer bindings from /etc/ardour3/mixer.bindings
[INFO]: Loading bindings from /etc/ardour3/mnemonic-us.bindings
Loading 87 MIDI patches from /home/rwh/.config/ardour3/patchfiles:/usr/share/ardour3/patchfiles
[INFO]: Loading history from /home/rwh/Ardour/test/test.history
@rickhull
rickhull / ruby-prof-1
Last active August 29, 2015 14:10
ruby-prof output for `conway_deathmatch -s0 -n400 --silent`
Thread ID: 14553840
Fiber ID: 16483340
Total: 345.224791
Sort by: self_time
%self total self wait child calls name
17.34 101.392 59.853 0.000 41.539 22359774 Range#include?
16.32 246.807 56.332 0.000 190.475 11228000 ConwayDeathmatch::BoardState#alive?
12.03 41.539 41.539 0.000 0.000 44588115 Fixnum#<=>
10.93 139.138 37.746 0.000 101.392 11228007 ConwayDeathmatch::BoardState#in_bounds?
@rickhull
rickhull / output
Created December 3, 2014 22:47
minitest BenchSpec bench_range problems
rwh@dadtop:~/minitest$ bundle exec ruby test.rb
test.rb:5:in `block in <main>': undefined method `bench_range' for #<Class:0x000000027d4d60> (NoMethodError)
from /var/lib/gems/2.1.0/gems/minitest-5.4.3/lib/minitest/spec.rb:69:in `class_eval'
from /var/lib/gems/2.1.0/gems/minitest-5.4.3/lib/minitest/spec.rb:69:in `describe'
from test.rb:4:in `<main>'
rwh@dadtop:~/minitest$ cat test.rb
require 'minitest/autorun'
require 'minitest/benchmark'
@rickhull
rickhull / conway.ex
Created December 19, 2014 18:10
help with organization / design / partial function application
defmodule Conway
# generate tuple of tuples with values according to fun.(x, y)
def new_grid(x_len, y_len, fun) when is_function(fun) and is_integer(x_len) and is_integer(y_len) and x_len > 0 and y_len > 0 do
for y <- 0..(y_len - 1) do
for x <- 0..(x_len - 1) do
fun.(x, y)
end
end |> Enum.map(&List.to_tuple/1) |> List.to_tuple
end
end
@rickhull
rickhull / conway_deathmatch.ex
Created December 19, 2014 18:42
actual impl
defmodule ConwayDeathmatch do
def new(x_len, y_len) when is_integer(x_len) and x_len > 0 and is_integer(y_len) and y_len > 0 do
new_grid(x_len, y_len, fn(_, _) -> 0 end)
end
def dim(grid) when is_tuple(grid) do
{grid |> tuple_size, grid |> elem(0) |> tuple_size}
end
def cell(grid, x, y) do
@rickhull
rickhull / majority.ex
Created December 22, 2014 03:22
given a list of items (with repeats), which one has the highest frequency?
defp majority(list) do
largest = 0
maj = []
list |> Enum.group_by(&(&1)) |> Enum.each(fn {val,lst} ->
case length(list) do
cnt when cnt > largest ->
largest = cnt
maj = [val]
cnt when cnt == largest ->
maj = [val | maj]
@rickhull
rickhull / conway.rb
Created December 22, 2014 20:11
simple parse, 3 tokens at a time
# parse a string like "acorn 12 22 block 5 0 p 1 2 p 3 4 p 56 78"
# add known shapes
def self.add(board, str, val = BoardState::ALIVE)
tokens = str.split
points = []
classic = self.classic
while !tokens.empty?
shape = tokens.shift.downcase
raise "no coordinates for #{shape}" if tokens.length < 2
defmodule ConwayDeathmatch.Mixfile do
use Mix.Project
def project do
[app: :conway_deathmatch,
version: "0.0.1",
elixir: "~> 1.0",
escript: [main_module: ConwayDeathmatch.CLI],
consolidate_protocols: true,
elixirc_paths: elixirc_paths(Mix.env),
@rickhull
rickhull / session.sh
Created January 17, 2015 09:47
erlang project wants to report semver to erlixir mix
rwh@dadtop:~/src/conway_deathmatch (elixir)$ cat mix.lock
%{"eflame": {:git, "git://github.com/rickhull/eflame.git", "aa1e0c363eee7ef77d71ba7595cc7528193c53e5", [tag: "0.1.0"]},
"exprintf": {:hex, :exprintf, "0.1.5"},
"exprof": {:hex, :exprof, "0.1.3"}}
rwh@dadtop:~/src/conway_deathmatch (elixir)$ mix test
Unchecked dependencies for environment perf:
* eflame (git://github.com/rickhull/eflame.git)
the dependency is not available, run `mix deps.get`
** (Mix) Can't continue due to errors on dependencies