This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# A complete URL-shortening web application, written in Ruby/Sinatra. Run it | |
# from the command line, and then visit http://localhost:4567/ | |
# | |
# Or to run it under apache/passenger, you'll need a config.ru file with the | |
# following contents: | |
# | |
# require 'tinyurl' | |
# run Sinatra::Application |
This file contains hidden or 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
post_data = {} | |
post_data[:name] = 'Title for my link' | |
post_data[:link] = 'http://path.to/my/link' | |
post_data[:caption] = 'A caption' | |
post_data[:description] = 'A description' | |
post_data[:picture] = 'http://path.to/myimage.jpg' | |
post_data[:actions] = { :name => 'My site name', :link => 'http://link.to/my/site'}.to_json | |
client.post("feed", nil, post_data) |
This file contains hidden or 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
--- | |
BUNDLE_WITHOUT: "" |
This file contains hidden or 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
# method to evaluate the block for a default value if the | |
# conversion to date fails | |
# string.to_date return nil if the string is blank | |
# so we yield to get the default value from the block there | |
# or on a parse error | |
def string_to_date(string,&block) | |
string.to_date || yield | |
rescue => e | |
block_given? ? yield : raise | |
end |
This file contains hidden or 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
#!/usr/bin/env bash | |
export PATH="$PATH:/usr/texbin/" | |
which pandoc &>/dev/null | |
if [ $? -eq 0 ] | |
then | |
if [ ! -n "$1" ] | |
then | |
echo 'defaulting to pdf' | |
file_name='scalingphp.pdf' | |
else |
This file contains hidden or 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
gem 'rake', '=0.8.7' | |
require 'rake' | |
require 'rake/testtask' | |
require 'rake/rdoctask' | |
#TODO don't shell out quite as much | |
namespace :bootstrap do | |
task :dev => ['bootstrap:copy_configs', 'bootstrap:bundle_gems', 'bootstrap:database'] do | |
run_cmd "bundle exec rake db:test:prepare" | |
end |
This file contains hidden or 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 'action_view' | |
require 'ostruct' | |
require 'erb' | |
require 'flog' | |
require 'ruby_parser' | |
require 'sexp_processor' | |
ERBHandler = ActionView::Template::Handlers::ERB.new | |
def new_template(body, details={format: :html}) |
This file contains hidden or 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 'action_view' | |
require 'ostruct' | |
require 'erb' | |
require 'flog' | |
require 'ruby_parser' | |
require 'sexp_processor' | |
ERBHandler = ActionView::Template::Handlers::ERB.new | |
def new_template(body, details={format: :html}) |
This file contains hidden or 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
# encoding: utf-8 | |
# code from: http://techtime.getharvest.com/blog/harvest-is-now-on-ruby-1-dot-9-3 | |
# and also: https://gist.github.com/1976864 | |
# Serialized columns in AR don't support UTF-8 well, so set the encoding on those | |
class ActiveRecord::Base | |
def unserialize_attribute_with_utf8(attr_name) | |
traverse = lambda do |object, block| | |
if object.kind_of?(Hash) |
OlderNewer