Skip to content

Instantly share code, notes, and snippets.

@Frost
Frost / mix-format-inline-pipe.md
Created December 1, 2017 12:35
mix format inline pipe?

When I run mix format on this code:

defmodule FormatExample do
  @some_module_attribute %{}

  def format_this do
    foo = @some_module_attribute |> Map.put("bar", "blargh") |> some_function([{"baz", [:something_long_enough]}])
  end
end
@Frost
Frost / .zshrc
Created June 7, 2017 09:15
ZSH expand alias on enter
zplug "momo-lab/zsh-abbrev-alias"
zplug load
expand-alias-and-accept-line() {
__abbrev_alias::magic_abbrev_expand
zle .backward-delete-char # this prevets a ^M character from ending up as part of the command
zle .accept-line
}
@Frost
Frost / hash_default_fun.rb
Last active November 22, 2016 15:35
Fun with ruby's Hash default
class Thing < ActiveRecord::Base
enum group: {
group_1: 0,
group_2: 1,
group_3: 2,
group_4: 3,
group_5: 4,
...
}
end
@Frost
Frost / ag files without matches
Created September 7, 2016 09:05
ag --files-without-matches
$ echo "foo" > foo.txt
$ echo "bar" > bar.txt
$ echo "
foo
bar
" > foobar.txt
$ ag -l foo
foo.txt
foobar.txt
$ ./configure
< lots of output >
$ make
< lots of other output >
$ make distcheck
< lots of output with passing tests>
===========================================
rcm-1.3.0 archives ready for distribution:
rcm-1.3.0.tar.gz
===========================================
@Frost
Frost / 38.hs
Created September 14, 2015 20:42
38.hs
-- 38 is the sum of the squares of the first three primes
-- 38 is 83 backwards
-- 83 is the sum of the squares of the first three odd primes
main = do
let primes = [2,3,5,7]
putStrLn $ show . sum . map square $ take 3 primes
putStrLn $ reverse . show . sum . map square $ drop 1 primes
where
square n = n * n
@Frost
Frost / dnsmasq-and-nginx-can-achieve-pow.cx-like-functionality.md
Last active February 16, 2017 16:18
Getting some equivalent of pow.cx using nginx and dnsmasq on non-Apple *NIX

Install nginx and dnsmasq

Using apt-get/dnf/pkg_add/ports/rpm/pacman/whatever...

Add necessary config files

/etc/dnsmasq.d/dev

# /etc/dnsmasq.d/dev
@Frost
Frost / compile output
Created August 13, 2015 08:27
toniq/eredis/eunit compile failure
0|frost inanna >> git clone [email protected]:joakimk/toniq.git && cd toniq && mix deps.get && mix test ~/c/g/joakimk
Cloning into 'toniq'...
remote: Counting objects: 874, done.
remote: Total 874 (delta 0), reused 0 (delta 0), pack-reused 874
Receiving objects: 100% (874/874), 103.62 KiB | 0 bytes/s, done.
Resolving deltas: 100% (536/536), done.
Checking connectivity... done.
Running dependency resolution
* Getting exredis (Hex package)
Checking package (https://s3.amazonaws.com/s3.hex.pm/tarballs/exredis-0.1.3.tar)
@Frost
Frost / error-report.txt
Created August 10, 2015 19:35
`mix test` crash when upgrading postgrex from 0.8 -> 0.9.1
=ERROR REPORT==== 10-Aug-2015::21:33:01 ===
** Generic server <0.876.0> terminating
** Last message in was {tcp,#Port<0.44223>,
<<82,0,0,0,8,0,0,0,0,83,0,0,0,22,97,112,112,108,
105,99,97,116,105,111,110,95,110,97,109,101,0,0,
83,0,0,0,25,99,108,105,101,110,116,95,101,110,
99,111,100,105,110,103,0,85,84,70,56,0,83,0,0,0,
23,68,97,116,101,83,116,121,108,101,0,73,83,79,
44,32,77,68,89,0,83,0,0,0,25,105,110,116,101,
103,101,114,95,100,97,116,101,116,105,109,101,
@Frost
Frost / fizzbuzz.rb
Created May 26, 2015 07:40
FizzBuzz in ruby without modulo or integer division
class Cycle
def initialize(array = [])
@array = array
end
def call
result = @array.first
@array = @array.rotate
result
end
end