Skip to content

Instantly share code, notes, and snippets.

View supersimple's full-sized avatar
☠️
Mostly Available

Todd Resudek supersimple

☠️
Mostly Available
View GitHub Profile

Keybase proof

I hereby claim:

  • I am supersimple on github.
  • I am supersimple (https://keybase.io/supersimple) on keybase.
  • I have a public key ASCtr8jm-HKtUdu96MUKexbw-UjojwK3mdljan-v1bcK6Ao

To claim this, I am signing this object:

iex> Version.match?("2.0.0", "> 1.0.0")
true
iex> Version.match?("2.0.0", "== 1.0.0")
false
iex(17)> {:ok, requirement} = Version.parse_requirement("== 2.0.1")
{:ok, #Version.Requirement<== 2.0.1>}
iex(9)> v = Version.parse!("1.0.0-alpha.3+20130417140000")
#Version<1.0.0-alpha.3+20130417140000>
iex(10)> v.build
"20130417140000"
iex(11)> v.pre
["alpha", 3]
iex(12)> v.patch
iex(4)> Version.parse!("2.3.4")
#Version<2.3.4>
iex(5)> Version.parse!("0.09")
** (Version.InvalidVersionError) invalid version: "0.09"
if Version.compare(System.version(), "1.4.0") == :lt do
def enum_split_with(enum, fun), do: Enum.partition(enum, fun)
else
def enum_split_with(enum, fun), do: Enum.split_with(enum, fun)
end
@supersimple
supersimple / Fib.rb
Created January 14, 2018 01:54
Some ways to handle a fibonacci sequence in Ruby
# This prints out the nth member of the sequence
def fib(n)
last_two = [0,1]
3.upto(n) do
last_two = last_two[1], last_two.inject(:+)
end
puts last_two.last
end
defmodule Wordcount do
@moduledoc """
Documentation for Wordcount.
"""
@spec count(String.t) :: map
def count(sentence) do
sentence
|> String.downcase
|> String.replace(~r/[,\.&:!@\$%\^]+/, "")
@supersimple
supersimple / day4.exs
Created December 8, 2017 04:58
Day 4
defmodule Day do
@spec count_valid() :: number()
def count_valid do
pwds = String.split(input(), "\n")
Enum.count(pwds, fn(ln) -> line_valid?(ln) end)
end
@spec line_valid?(string) :: boolean()
defp line_valid?(line) do
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros