View ip.sh
1 2 3 4 5 6 7 8
# Install: place this in your `~/bin/` and call it `ip` for example.
#
# Usage:
# $ ip
# 192.168.1.42
# 242.242.42.89
ipconfig getifaddr en0
curl ipecho.net/plain;echo
View email_with_name.rb
1 2 3 4 5 6 7 8 9 10
# lib/email_with_name.rb
module EmailWithName
def email_with_name(email, name)
name = name.gsub(/"<>/, '')
"#{name} <#{email}>"
end
end
 
# app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
View bmark.rb
1 2 3 4 5 6 7 8 9 10
require 'benchmark'
 
def bmark(iterations, benches)
size = benches.keys.map(&:length).sort.last
Benchmark.bm(size) do |x|
benches.each do |key, value|
x.report(key) do
iterations.times { value.call }
end
end
View jbuilder_prettify.rb
1 2 3 4 5 6 7 8 9 10
require "jbuilder"
 
# Enable prettification in your `.jbuilder` files
# Via https://github.com/rails/jbuilder/issues/195#issuecomment-44440569
#
# Example:
# json.prettify! if params[:pretty] == "1"
#
class Jbuilder
# Enable or disable prettification
View currency_by_ip.rb
1 2 3 4 5 6 7 8 9 10
# Detect currency by IP address.
#
# Requires the GeoIP gem and a `lib/geo/GeoIP.dat` file with geographic info.
# See https://github.com/cjheath/geoip
#
# Example:
#
# require "geoip"
# CurrencyByIP.new("78.193.246.42").currency => "EUR"
#
View meuh.rb
1 2 3 4 5 6 7 8 9 10
# coding: utf-8
require "cinch"
require "rspec"
 
module Meuh
# Artificial intelligence
class Brain
attr_accessor :botname
 
def initialize(botname: nil)
View iso
1 2 3 4 5 6 7 8 9 10
#!/bin/sh
# Create disk images
#
# Put this in ~/bin/iso and add ~/bin/ to your $PATH, then run `iso`.
 
set -e
 
if [ "$1" ] && [ "$2" ]; then
diskutil unmountDisk "$1"
echo "Creating image at $2. Press ctrl-t to see progress."
View application_helper.rb
1 2 3 4 5 6 7 8 9 10
module ApplicationHelper
# Add ?show_translation_keys=1 to URLs to let your team members
# know the name of the translation keys beeing used on the current
# page.
def t(key, options = {})
if params[:show_translation_keys]
scope_key_by_partial(key)
else
super
end
View .gitconfig
1 2 3 4 5 6 7 8 9 10
# See https://www.kernel.org/pub/software/scm/git/docs/git-config.html
 
[user]
email = sunny@sunfox.org
name = Sunny Ripert
 
[github]
user = sunny
 
[core]
View clock.coffee
1 2 3 4 5 6 7 8 9 10
# Via http://html5demos.com/svg-clock
# Usage:
# new Clock()
class Clock
SECONDS_HAND_SIZE = 0.95
MINUTES_HAND_SIZE = 0.85
HOURS_HAND_SIZE = 0.55
CIRCLE_SELECTOR = "#circle"
SECONDHAND_SELECTOR = "#secondhand"
MINUTEHAND_SELECTOR = "#minutehand"
Something went wrong with that request. Please try again.