Skip to content

Instantly share code, notes, and snippets.

View adamzaninovich's full-sized avatar

Adam Zaninovich adamzaninovich

View GitHub Profile
module ImmutableContentFor
def immutable_content_for label, &block
content_for label, &block unless content_for? label
end
def cached_immutable_content_for key, label, &block
Rails.cache.write key, block.call unless content_for? label
immutable_content_for label, &block
end
_=$$/$$;__=_-_;@_=_+_;$_=@_+_;$-=@_+$_;$-_=$-*$_
@__ =''<<$-_*($-+$_)+@_
$___=''<<$-_*$--$-<<$-_*($-+@_)<<@__<<@__
@___=''<<$-_*$--$_*$_<<$-_*($-+$_)-$_<<@__<<@__
(___=->{$.+=_;$><<($.%$-_==__ ?$___+@___:$.%$_==__ ?$___:$.%
$-==__ ?@___:$.)<<(''<<$-*@_);$.<($-*@_)**@_?___[]:_})[]
require 'minitest/spec'
require 'minitest/autorun'
class Solve
attr_reader :expected, :numbers
def initialize expected, *numbers
@expected = expected
@numbers = numbers
end
defmodule Sequence do
def fib(0), do: 1
def fib(1), do: 1
def fib(n), do: fib(n-2) + fib(n-1)
def map([],_f), do: []
def map([head|tail], f) do
[f.(head) | map(tail,f)]
end
@adamzaninovich
adamzaninovich / neovim-setup.md
Last active January 18, 2025 07:36
How to get an awesome neovim setup that runs tests asynchronously in a neoterm split

How to get an awesome neovim setup that runs tests asynchronously in a neoterm split

Example

Installing neovim

brew install neovim/neovim/neovim
setup_jruby() {
export JRUBY_HOME=/usr/ruby/jruby9
export PATH=$PATH:$JRUBY_HOME/bin
export JAVA_HOME=/usr/java/java8
}
defmodule FlattenedMap do
def flatten(%{} = map) do
map |> Enum.map(&merge/1) |> List.flatten |> Enum.into(%{})
end
defp merge({prefix, %{} = map}), do: Enum.map(map, &do_merge(prefix, &1))
defp merge(flat), do: flat
defp do_merge(prefix, {key, val}), do: merge({merge_keys(prefix, key), val})
@adamzaninovich
adamzaninovich / material-red-yakyak-theme.css
Last active March 6, 2017 23:57
This is a theme tweak for YakYak
html.material {
--white: #202B31;
--ghostwhite: #2d3d46;
--lightgrey: #28353B;
--altgrey: #2B3E41;
--grey: #303F47;
--darkgrey: #617E8A;
--lightblack: #455a64;
--black: #99B1B7;
--green: #900F3C;
defmodule MyApp.Redis do
@moduledoc "State management using redis for persistence"
alias MyApp.Redis.Connection
@doc "Starts the redis conection and registers the process"
def start_link(redis_connection_string \\ "redis://localhost") do
Redix.start_link(redis_connection_string, name: MyApp.Redis.Connection)
end
@doc "Sets a value to a key in redis"