Skip to content

Instantly share code, notes, and snippets.

View gotwalt's full-sized avatar

Aaron Gotwalt gotwalt

View GitHub Profile
@gotwalt
gotwalt / gist:528586
Created August 17, 2010 05:33
Posting to twitpic in Ruby using oauth echo
require "nestful"
require "roauth"
def upload(path_to_file)
twitpic_key = "my_twitpic_api_key"
oauth_url = "https://api.twitter.com/1/account/verify_credentials.json"
oauth = {
:access_key => "account_access_key",
:access_secret => "account_access_secret",
@gotwalt
gotwalt / shiftjis-csv.rb
Created February 23, 2011 09:45
Convert a CSV file to Shift-JIS for use in Japanese versions of Microsoft Excel in ruby-1.8.7
require "iconv"
encoding = "SHIFT-JIS"
# Open a file for writing in the Shift-JIS format
File.open("output.csv", "w:#{encoding}") do |io|
# Read the CSV file, and convert CRs to CRLFs.
csv = File.open("input.csv").read.gsub("\r", "\r\n")
# Convert the CSV to the correct encoding
io.write Iconv.iconv(encoding, "UTF-8", csv).join
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head profile="http://gmpg.org/xfn/11">
<title>This Guy Took A Picture Of His Face Every Day For 8 Years</title>
<link rel="SHORTCUT ICON" href="favicon.ico" />
<meta http-equiv="content-type" content="text/html; charset=us-ascii" />
<meta property="og:title" content="This Guy Took A Picture Of His Face Every Day For 8 Years" />
<meta name="description" content="" />
require 'spec_helper'
require 'rack/test'
require 'support/vcr'
describe User do
describe '#find_or_initialize_by_facebook_token' do
puts "it gets here"
it "creates a new user for a valid" do
puts "but never gets inside here"
require 'rake/testtask'
require 'cucumber/rake/task'
Rake::TestTask.new(:test) do |t|
t.libs << 'spec'
t.pattern = 'spec/**/*_spec.rb'
t.verbose = true
end
@gotwalt
gotwalt / gist:2892818
Created June 8, 2012 01:13
Install gem bundler 1.2pre
rvm gemset use global
gem uninstall -ax bundler
gem install bundler --pre
bundle --version
rvm gemset use giver
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
environment_id="ruby-1.9.3-p125@thumbs"
#
# First we attempt to load the desired environment directly from the environment
# file, this is very fast and efficicent compared to running through the entire
8:24:20 AM Aaron Gotwalt: we're having the collection-json vs other api forms argument tomorrow
8:24:36 AM Aaron Gotwalt: or hypermedia types, i suppose
8:25:00 AM Aaron Gotwalt: he's concerned about verbosity and that it presents the data in a format that is not ideal for either the client or the server
8:25:33 AM Larry Marburger: that's a feature
8:26:09 AM Larry Marburger: it's designed to be future proof which hand-rolled json won't be
8:26:19 AM Larry Marburger: it's an interchange format
8:26:31 AM Larry Marburger: i may have just made that up
8:26:34 AM Aaron Gotwalt: right, but it has processing cost on either side
8:26:39 AM Aaron Gotwalt: which is less of a concern in ruby-land
8:26:43 AM Aaron Gotwalt: but on ios
@gotwalt
gotwalt / gist:3837068
Created October 4, 2012 23:16
Late night code comments
# how many posts to we rip on the daily?
def count
# say me say many moni, say me say manymanymany
redis.zcount(key, '-inf', '+inf')
end
class NoChoice < Choice
end