Skip to content

Instantly share code, notes, and snippets.

View jferris's full-sized avatar

Joe Ferris jferris

  • thoughtbot, inc.
  • Cambridge, MA
View GitHub Profile
@jferris
jferris / clean_indent
Last active August 29, 2015 13:56
Copy a range from Vim as rich text for pasting into Keynote
#!/usr/bin/env ruby
# Save this somewhere on your path and make it executable
lines = STDIN.readlines
min_indent = lines.inject 100 do |result, line|
if line.strip.length == 0
result
else
@jferris
jferris / .ruby-version
Created March 26, 2014 19:44
Cocaine PATH issue
2.0.0-p353
@jferris
jferris / OUTPUT
Created June 11, 2014 19:04
Gem env
% gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.3.0
- RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/jferris/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /Users/jferris/.rbenv/versions/2.1.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jferris/.rbenv/versions/2.1.2/bin
- SPEC CACHE DIRECTORY: /Users/jferris/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jferris/.rbenv/versions/2.1.2/etc
- RUBYGEMS PLATFORMS:
@jferris
jferris / coffee.txt
Created September 2, 2014 17:45
Flow chart: how should I take my coffee?
Do you like the taste of coffee?
| |
Yes No
| |
Do you like the taste of coffee without cream? Stop drinking coffee.
| |
No Yes ---------------------\
| | |
| Do you like the taste of coffee without sugar? |
| | | |
@jferris
jferris / Output
Last active August 29, 2015 14:06
Demonstrate Capybara finders
% ruby capybara.rb
Testing #find
"Element 1"
Testing #all
[]
Testing #all with minimum
["Element 1", "Element 2", "Element 3", "Element 4", "Element 5"]
@jferris
jferris / notify-send-status
Created September 19, 2014 17:40
Send time, battery, and Wifi status to libnotify
#!/usr/bin/zsh
time_status=$(date +%l:%M%p | sed "s/^ *//")
date_status=$(date +%A,\ %B\ %e)
battery_status=$(acpi | head -n1 | sed "s/^[^,]*, //" | sed "s/,.*//")
wifi_status=$(iwconfig wlp3s0 | grep ESSID | sed "s/^.*://" | tr -d '"')
notify-send -t 3000 "$time_status" "$date_status\nBattery: $battery_status\nConnected to $wifi_status"
@jferris
jferris / haskell.vim
Created September 22, 2014 20:51
Hoogle for keyword under cursor
function! Hoogle(function)
call system("chromium \"http://www.haskell.org/hoogle/?hoogle=" . a:function . "\"")
endfunction
" Search for the current word using Hoogle
nmap <Leader>H :call Hoogle("<C-R><C-W>")<CR>
@jferris
jferris / Hello.hs
Created October 10, 2014 18:04
DOM Manipulation with ghcjs
module Main (main) where
import Control.Applicative ((<$>))
import GHCJS.DOM (runWebGUI, webViewGetDomDocument)
import GHCJS.DOM.Document (documentGetBody, documentCreateElement)
import GHCJS.DOM.Types (castToHTMLDivElement)
import GHCJS.DOM.Node (nodeAppendChild)
import GHCJS.DOM.HTMLElement (htmlElementSetInnerText)
main :: IO ()
@jferris
jferris / compose.rb
Created October 29, 2014 18:32
Compose Functions in Ruby
class String
def blank?
self == ""
end
end
class Symbol
def *(other)
lambda { |instance| instance.__send__(other).__send__(self) }
end
@jferris
jferris / PKGBUILD
Last active August 29, 2015 14:08
Package build for ruby-build 20141113
# Maintainer: Vincent Demeester <vincent@sbr.io>
# Contributer: Alex Ogier <alex.ogier@gmail.com>
pkgname=ruby-build
pkgver=20141113
pkgrel=1
pkgdesc="Compile and install Ruby"
arch=('any')
url="http://github.com/sstephenson/ruby-build"
license=('MIT')
optdepends=('git: install ruby from git')