Skip to content

Instantly share code, notes, and snippets.

View Supernats's full-sized avatar

Nathan Seither Supernats

View GitHub Profile
module Refinements::StringNumericalConversions
refine String do
def to_integer
Integer(self)
rescue ArgumentError
nil
end end
refine NilClass do
def to_integer; end
setw -g mode-keys vi
bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'
set-option -g default-command "reattach-to-user-namespace -l bash"
setw -g aggressive-resize on
bind p paste-buffer
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
# show battery level
describe "pronoun swapping" do
context "by themselves" do
let(:from) { 'I' }
let(:to) { 'You' }
it "switches 'I' to 'You'" do
expect(WordPlay.switch_pronouns("#{from} computer")).to eq("#{to} computer")
end
  • Embiggen your bash history: Tired of forgetting important commands because they've dropped out of you history? DON'T BE ANYMORE. You can set your history to follow as many commands as you'd like. I like a million, because it is big and has lots of 0s.

    Put this in your bashrc/bash_profile

    MILLION=1000000

export HISTFILESIZE=$MILLION

require 'json'
module GitHelper
def get_tag(steps: 1)
tag = `git tag -l`.split("\n")[-steps]
end
def the_goods since: get_tag
`git shortlog #{since}..HEAD`
end
set backupdir=~/vimtemp
set directory=~/vimtemp
execute pathogen#infect()
set runtimepath^=~/.vim/bundle/ctrlp.vim
highlight Error ctermbg=red ctermfg=white guibg=#592929
match Error /\%81v.\+/
au VimEnter * RainbowParenthesesToggle
command -nargs=1 MS :mksession ~/vimsessions/<args>.vim
command -nargs=1 SS :mksession! ~/vimsessions/<args>.vim
command -nargs=1 LS :source ~/vimsessions/<args>.vim
command LL :source ~/vimsessions/last.vim
class ActiveRecord::Base
def self.sample(n = 1)
case n <=> 1
when -1
puts "don't be a shit"
nil
when 0
chosen_rand = rand(self.count) + 1
self.find(chosen_rand)
when 1
@Supernats
Supernats / attr_wtf.rb
Created June 10, 2014 21:40
attr_accessor and def cannot team up
class AttrFirst
attr_reader :age
attr_accessor :name
def initialize(age = 0)
@age = age
end
def name
make_name(5)
@Supernats
Supernats / attr_wtf.rb
Created June 10, 2014 21:19
attr_accessor and def cannot team up
class AttrFirst
attr_reader :age
attr_accessor :name
def initialize(age = 0)
@age = age
end
def name
make_name(5)