Skip to content

Instantly share code, notes, and snippets.

View wende's full-sized avatar

Krzysztof Wende wende

  • Neon Tree Solutions Ltd.
  • Gdańsk, Poland
View GitHub Profile
defmodule SomeProtocol do
@on_load :start_agent
def start_actor() do
{result, pid} = Agent.start_link(fn -> 0 end)
result
end
def __using__() do
quote do
module.exports.aliasImportRegex = /???/
module.exports.iterate = (match) ->
@wende
wende / .tmux.conf
Last active December 21, 2015 18:29 — forked from anonymous/.tmux.conf
My tmux config
# Use reattach-to-user-namespace so pbcopy/pbpaste work again.
# Use 256 color terminal
set-option -g default-terminal screen-256color
# Use C-t as my tmux prefix key
# set-option -g prefix C-t
# Other keybindings.
bind-key k kill-pane
@wende
wende / Day2.ex
Last active December 15, 2015 19:18
Enum.take_while( IO.stream(:stdio, :line), fn
"\n" -> false
_ -> true
end)
|> Enum.map(fn line ->
String.split(line, "x")
|> Enum.map(&Integer.parse/1)
|> (fn [{a,_},{b,_},{c,_}] ->
mkdir Backup
cd $1
pwd
ls > $3
wc < $3 -w
cp $3 ../Backup/test
cd ..
mv $1 Backup
@wende
wende / prime.hs
Created September 28, 2015 14:48
let pgen (p:xs) = p : pgen [x|x <- xs, x `mod` p > 0]
let nPrimes x = x `take` pgen [2..]
=ERROR REPORT==== 25-Sep-2015::15:46:40 ===
Error in process <0.1104.0> on node 'test@krzysztof-SVT13' with exit value: {{badmatch,{error,enoent}},[{katt_blueprint,file,1,[{file,"src/katt_blueprint.erl"},{line,25}]},{katt_blueprint_parse,file,1,[{file,"src/katt_blueprint_parse.erl"},{line,56}]},{katt,run,4,[{file,"src/katt.erl"},{line,77}]}]}
*** CT Error Notification 2015-09-25 13:46:40.629 ***
Error detected: {badmatch,{error,enoent}}
Full error description and stacktrace
def sum_list([], acc), do: acc
def sum_list([head | tail], acc // 0) do
sum_list(tail, head + acc)
end
def is_prime(x), do: (2..x |> Enum.filter(fn a -> rem(x, a) == 0) |> length()) == 1
def prime(n), do: Stream.interval(1) |> Stream.drop(2) |> Stream.filter(&is_prime/1) |> Enum.take(n)
@wende
wende / prime.ex
Last active August 11, 2016 17:55
def n_primes(n), do: prime(n, 2)
def is_prime(x), do: (2..x |> Enum.filter(fn a -> rem(x, a) == 0 end) |> length()) == 1
def prime(n, n), do: []
def prime(n, acc) do
case is_prime(acc) do
true -> [acc | prime(n, acc + 1)]
false -> prime(n, acc + 1)
end
end