Skip to content

Instantly share code, notes, and snippets.

View omnikron's full-sized avatar
🐋
💨

Oli Barnett omnikron

🐋
💨
  • DE-NRW
  • 23:53 (UTC +02:00)
View GitHub Profile
@omnikron
omnikron / commit-msg
Created January 18, 2012 10:39 — forked from henrik/commit-msg
# Outdated, view updated version at https://github.com/omnikron/stagecoach/tree/master/lib/githooks # Git commit-msg hook that works in tandem with the redmine_stagecoach gem to automatically add your branch's associated github issue number to your commit
#!/usr/bin/env ruby
#
# Git commit-msg hook adapted from Henrik Nyh's <http://henrik.nyh.se> original version
# <https://gist.github.com/184711>
#
# Works in tandem with the redmine_stagecoach gem to automatically add your
# branch's associated github issue number to your commit message.
#
# If you include "#noref" in the commit message, nothing will be added to
# the commit message, and the "#noref" itself will be stripped.
@omnikron
omnikron / Bill.rb
Last active December 16, 2015 03:39
For recurring billing.
# Calculates billable day-of-month numbers at the end
# of a month with fewer than 31 days.
#
# eg. billable_days Date.new(2012, 02, 29) => 29, 30, 31
#
def billable_days(date = Date.today)
if date.day == date.end_of_month.day
(date.day..31)
else
date.day
java -jar /usr/local/Cellar/selenium-server-standalone-grid/2.32.0/selenium-server-standalone-2.32.0.jar -p 4444 -role hub
@omnikron
omnikron / gist:5858909
Created June 25, 2013 14:30
jQuery - live update while typing (just like Angular)
# Show euro total when editing account payment plans
$(".input .integer[id^='account_payment_plans_attributes']").each ->
value = $(@).attr('value') / 100 / 1000
$(@).parent().next('.euros').html(" = €#{$(@).attr('value') / 100 / 1000 }")
$(".input .integer[id^='account_payment_plans_attributes']").on 'keyup', ->
$(@).parent().next('.euros').html(" = €#{$(@).attr('value') / 100 / 1000 }")
@omnikron
omnikron / vimrc
Created September 19, 2013 11:03
" Oli new stuff
" ====================================
" Press space in normal mode to enter a command
nnoremap <Space> :
" Pretty lines
set fillchars=vert:\
" make backspace work like most other apps
set backspace=2
@omnikron
omnikron / oli.rb
Last active August 29, 2015 13:56 — forked from bjjb/monty.rb
#!/usr/bin/env ruby
# Monty Hall problem proof http://en.wikipedia.org/wiki/Monty_Hall_problem
module Monty
PLAYERS_WITH_POLICY = { jimmy: :switch, jasper: :stick, johnson: :random }
DOORS = [:goat, :goat, :ferrari]
COUNT = Integer(ARGV[0] || 100000)
class << self
def win?(policy)
doors = DOORS.dup.shuffle
@omnikron
omnikron / elegant_log.rb
Created June 9, 2016 12:22
Elegantly logs rails params in aligned `key: value` form
module ElegantLog
extend ActiveSupport::Concern
def elegant_log(params, display_name = nil)
return if params.blank?
spacer
Rails.logger.info display_name || params.delete(:controller).titleize
longest_length = params.keys.sort {|k1, k2| k2.length <=> k1.length}.first.length
@omnikron
omnikron / gist:3b21a2f838939c5d697ec185587d1e94
Created October 11, 2017 06:32
targets.vim error on `ci'`
Error detected while processing function targets#o[8]..<SNR>67_findTarget[8]..<SNR>67_findRawTarget[15]..<SNR>67_quoteDir:
line 7:
E121: Undefined variable: col:
E15: Invalid expression: line[col:]
line 12:
E121: Undefined variable: right
E116: Invalid arguments for function s:count(s:opening, right)
E15: Invalid expression: s:count(s:opening, right)
line 16:
E121: Undefined variable: rc
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 19 2015 14:48:49)
MacOS X (unix) version
Included patches: 1-922
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
{
"presets": ["react-native", "flow", "react-native-dotenv"],
"plugins": [
"react-hot-loader/babel",
[
"module-resolver",
{
"root": ["../../"],
"alias": {
"src": "./src"