person = Person.new('Jo', 'Bloggs')
HumanName.new(person).full_name
> "Joe Bloggs"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
trap Terminate SIGINT SIGTERM SIGQUIT SIGKILL | |
Start () { | |
echo "Starting rack..." | |
rackup $@ & | |
echo $! > /tmp/rerackup.pid | |
} | |
Stop () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
require 'will_paginate/collection' | |
require 'ostruct' | |
class GoogleCustomSearch | |
include HTTParty | |
base_uri 'https://www.googleapis.com/customsearch/v1' | |
format :json | |
default_params :cx => 'google-costom-searck-id', :key => 'google-api-key' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds ng-model attrs to all formatastic inputs | |
# based on ActiveModel naming conventions | |
class AngularFormBuilder < Formtastic::FormBuilder | |
# Almost exact dupilicate of the formtastic input method | |
# but thhe magick is in the extends :) (Line 13) | |
def input(method, options = {}) | |
method = method.to_sym if method.is_a?(String) | |
options = options.dup | |
options[:as] ||= default_input_type(method, options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#Wrapper for mpc including host | |
export MPD_HOST=`cat /etc/mpdhost` | |
/usr/bin/mpc $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.tmuxinator/music.yml | |
project_name: Musix | |
project_root: ~/Music | |
pre: mopidy -q &> ~/.mopidy.log & | |
tabs: | |
- interface: ncmpcpp | |
- radio: bbcradio | |
- mixer: alsamixer | |
- mopodiy: tail -f ~/.mopidy.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def months_til_renewal | |
months = 0 | |
date_to_check = Date.current | |
while(date_to_check < current_period_ends_at.to_date) do | |
date_to_check = date_to_check.next_month | |
months += 1 | |
end | |
months | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def temp_password | |
@temp_password ||= ((0..9).to_a.sample(2) + ('a'..'z').to_a.sample(6)).shuffle.join | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './sequel_config' | |
require './tumblr_config' | |
desc 'Export posts to Tumblr' | |
task :export_to_tumblr do | |
client = Tumblr::Client.new | |
Post.order(:published_at).each do |p| | |
begin | |
resp = client.text('some_tumblog',{ | |
title: p.title, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
font-size: 14px; | |
line-height: 1.6; | |
font-family: helvetica,arial,freesans,clean,sans-serif; | |
color: black; | |
} | |
h1 { | |
margin: 15px 0; | |
padding-bottom: 2px; | |
font-size: 24px; |