Skip to content

Instantly share code, notes, and snippets.

View adamzaninovich's full-sized avatar

Adam Zaninovich adamzaninovich

View GitHub Profile
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})
setup_jruby() {
export JRUBY_HOME=/usr/ruby/jruby9
export PATH=$PATH:$JRUBY_HOME/bin
export JAVA_HOME=/usr/java/java8
}
@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
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
require 'minitest/spec'
require 'minitest/autorun'
class Solve
attr_reader :expected, :numbers
def initialize expected, *numbers
@expected = expected
@numbers = numbers
end
_=$$/$$;__=_-_;@_=_+_;$_=@_+_;$-=@_+$_;$-_=$-*$_
@__ =''<<$-_*($-+$_)+@_
$___=''<<$-_*$--$-<<$-_*($-+@_)<<@__<<@__
@___=''<<$-_*$--$_*$_<<$-_*($-+$_)-$_<<@__<<@__
(___=->{$.+=_;$><<($.%$-_==__ ?$___+@___:$.%$_==__ ?$___:$.%
$-==__ ?@___:$.)<<(''<<$-*@_);$.<($-*@_)**@_?___[]:_})[]
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
Hello from vim!!!
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool is_vowel(char arg) {
int i;
char vowels[] = "aeiou";
if(arg < 91) arg += 32;
for (i = 0; i < strlen(vowels); ++i) {
if (arg == vowels[i]) return true;
@adamzaninovich
adamzaninovich / git.sh
Last active December 20, 2015 16:09
Some helpful git functions
# g: with no args: runs short status
# with args: acts as `git`
function g () {
if [[ $# > 0 ]]
then
git $@
else
git status -sb
fi
}