Skip to content

Instantly share code, notes, and snippets.

View omegahm's full-sized avatar

Mads Ohm Larsen omegahm

View GitHub Profile
@omegahm
omegahm / check_methods.rb
Last active August 29, 2015 14:22
Find unused Ruby methods in current project
skip_methods = %w(new create edit update destroy index show initialize to_s call as_json page per_page build up down change)
output = `grep -hir "^\s*def\s" *`
methods = output.split("\n")
puts "Found #{methods.size} methods."
ununsed_methods = []
methods.each_with_index do |line, i|
line = line.gsub(/^\s*/, '')
@omegahm
omegahm / output
Created May 28, 2015 09:28
Weird Spec behaviour
..
Finished in 9.18 seconds (files took 8.21 seconds to load)
2 examples, 0 failures
@omegahm
omegahm / Output
Created May 21, 2015 16:49
4d9 > 6d6
Matches: 101640
4d9 wins: 55948
4d9 wins %: 0.550452577725305
6d6 wins: 40641
6d6 wins %: 0.3998524203069658
Draws: 5051
@omegahm
omegahm / README.md
Created May 21, 2015 13:48
Couch Presentation
@omegahm
omegahm / fizzbuzz.rb
Last active November 9, 2015 13:53
Fizzbuzz in Ruby
class Fiznum
attr_accessor :num
def initialize(num)
self.num = num
end
def fizzbuzz?
num % 15 == 0
end
@omegahm
omegahm / fizzbuzz.ex
Created May 19, 2015 16:23
FizzBuzz in Elixir
defmodule FizzBuzz do
def fizzbuzz(n) do
whichfizz(rem(n, 3), rem(n, 5), n)
end
defp whichfizz(0, 0, _), do: "FizzBuzz"
defp whichfizz(0, _, _), do: "Fizz"
defp whichfizz(_, 0, _), do: "Buzz"
defp whichfizz(_, _, n), do: n
end
\documentclass[a4paper,10pt]{article}
\usepackage[top=2.5cm, bottom=3cm, left=3cm, right=3cm]{geometry}
% Standard preamble
\usepackage[danish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[sc]{mathpazo}
\linespread{1.05} % Palatino needs more leading (space between lines)
\usepackage[T1]{fontenc}
@omegahm
omegahm / reddit.css
Created April 8, 2015 17:08
Reddit minimal style
@font-face {
font-family: 'Nunito';
font-style: normal;
font-weight: 300;
src: local('Nunito-Light'), url(http://fonts.gstatic.com/s/nunito/v7/1TiHc9yag0wq3lDO9cw0vpBw1xU1rKptJj_0jans920.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Nunito';
@omegahm
omegahm / create_labels.sh
Created April 7, 2015 19:00
Create Gtihub labels from Bash
#!/usr/bin/env bash
# Colours picked from https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues/
###
# Label definitions
###
declare -A LABELS
# Platform
@omegahm
omegahm / graph.rb
Last active June 8, 2020 12:41
Generate nice Dependency Hierarchy Graph of Gems
#!/usr/bin/env ruby
require 'json'
gemfile = ARGV[0] || 'Gemfile.lock'
gems = {}
last_gem = ''
name = ''
File.readlines(gemfile).each do |line|