Skip to content

Instantly share code, notes, and snippets.

@gausby
gausby / index.js
Created October 22, 2014 12:44
requirebin sketch
var test = require('tape');
// this is safe cycles taken from Bunyan
function safeCycles() {
var seen = [];
return function (key, val) {
if (!val || typeof (val) !== 'object') {
return val;
}
if (seen.indexOf(val) !== -1) {
@gausby
gausby / gist:9000befc6e84380ac88d
Created January 13, 2015 09:40
Awesome comment technique for really sloppy hacking
// observe!
/**/ /*/ /**/
// then look at this:
/** / /*/ /**/
// you can use it to switch between to blocks of code, in this case test is equal to 'foo'
/**/
var test = 'foo'
/*/
@gausby
gausby / gist:79076ec8809fb4d808b7
Last active August 29, 2015 14:20
CphEx on meetup.com

I started CphEx back in October 2014. I created a Twitter account (https://twitter.com/cph_ex) and a GitHub organisation (https://github.com/cphex/), made some initial noise on the internet about it, planned a formal meet up at a café, and went there not knowing if anyone else would show up. Luckly some did, and since then we have had a meet up every month. We have grown the community and we are now around eight people partaking in the monthly meet ups and our events are now hosted at venues kindly offered by companies located in greater Copenhagen, with projectors and sometimes snacks.

We have had some discussions whether or not we should be on a meet up site of some sort, meetup.com, lanyrd.com, Facebook groups, etc., but personally I have spoken against it for the following reason: They are not inclusive as they force a notion of a structure, and they rise the barrier of participation without giving much back.

My initial strategy with the Github repo was: If you are interested in Elixir and you want to o

@gausby
gausby / validator.ex
Created August 12, 2015 20:39
Collectable, Copenhagen Elixir, August 2015
defmodule Validator.Result do
defstruct errors: [], warnings: [], runs: 0, passes: 0
end
defmodule Validator do
alias Validator.Result
def run do
tests = [
&file_should_exist/0,
&file_should_have_a_title/0,

Important KoldskålsConf 2015 Announcement

TLDR; due to my fault the excitement about the KoldskålsConf did not last long, and as one of the initiators I really do not know where we stand with this thing; so I guess it is better to cancel it.

Hi, I am Martin, and I am the guy who started the talk about doing a conference about a Danish dessert called Koldskål and weird tech; KoldskålsConf—a Danish/Copenhagen pendant to the legendary bay area conference called TacoConf.

But mistakes were made and they were made by me.

The concept had a ton of excitement in the beginning, but I did not manage to keep that excitement going. Excitement about a thing like this is important, because it was supposed to be organized in a way where everyone who wanted to help out could help out, and make it an actual thing.

defmodule Name do
use GenServer
def start_link(data) do
GenServer.start_link(__MODULE__, data, name: via_name(data))
end
# do what ever you need to do with data
defp via_name(data),
do: {:via, :gproc, gproc_name(data)}
@gausby
gausby / gravatar.ex
Last active November 11, 2015 17:40
An Elixir port of the node.js module 'gravatar-url'. People often ask «where are the packages for Elixir?» Often the answer is «they are baked in; for anything else try out Hex.pm»
defmodule Gravatar do
@base_url "https://secure.gravatar.com/avatar/"
@doc """
Will get the corresponding gravatar url for a given email address. Options
can be passed in using a keyword list or a map.
iex> Gravatar.url("[email protected]", size: 200)
https://secure.gravatar.com/avatar/0e6a9f19e77fa18bf6f185258f2507d6?size=200
defmodule Counter do
def start_link do
Agent.start_link(fn -> 0 end)
end
def set(pid, value) do
Agent.update(pid, fn _ -> value end)
end
def increment(pid) do
defmodule Store do
def start_link do
Agent.start_link(fn -> %{} end)
end
def set(pid, key, value) do
Agent.update(pid, fn state ->
Map.put(state, key, value)
end)
end
[1,0,1,1,1] |> Enum.reduce(0, fn
1, acc -> acc * 2 + 1
0, acc -> acc * 2
end)