Skip to content

Instantly share code, notes, and snippets.

View sstarr's full-sized avatar
🏠
Working from home

Simon Starr sstarr

🏠
Working from home
View GitHub Profile
require 'rubygems'
require 'open-uri'
require 'xml'
# Grab the raw XML from FriendFeed using open-uri
raw_xml = open("http://friendfeed.com/api/feed/user/simonstarr?format=xml").read
# Parse the XML with LibXml
# (this is where the magic happens)
source = XML::Parser.string(raw_xml) # source.class => LibXML::XML::Parser
#!/usr/bin/env ruby
# Basic titlebot for JsChat (http://jschat.org)
# Run 'gem install eventmachine' (with sudo if required) if your computer doesn't have it
# gem might also be gem1.8 if you got it from Debian/ubuntu
require 'rubygems'
require 'eventmachine'
require 'json'
require 'open-uri'
# this goes in ~/.freeagent
ENV['FA_COMPANY'] = 'mycompany'
ENV['FA_USERNAME'] = 'myloginemail'
ENV['FA_PASSWORD'] = 'mypassword'
@sstarr
sstarr / gist:506478
Created August 3, 2010 14:36
Tumblr only allows a maximum width of 500px for embedded YouTube videos. Paste this script into your theme, change contentWidth and the embed code will be updated accordingly.
<!-- Widescreen YouTube Embeds by Matthew Buchanan & Hayden Hunter
http://matthewbuchanan.name/451892574
http://blog.haydenhunter.me
Hacked around by Simon Starr to break out of Tumblr's max width of 500px
http://www.simonstarr.com
Original source here: http://pastie.org/871790
Released under a Creative Commons attribution license:
# Use ImageMagick to get the dimensions of an image
def get_image_dimensions(image_url)
open(image_url, 'rb') do |f|
@image = Magick::Image.from_blob(f.read)
end
"width=\"#{@image.first.columns}\" height=\"#{@image.first.rows}\""
end
# Insert the width and height into all img tags in a string
def insert_image_dimensions(string)
@sstarr
sstarr / gist:1260303
Created October 3, 2011 21:26
Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.10'
# Authentication and authorisation
gem 'devise'
gem 'cancan'
# Attachments
gem 'carrierwave'
@sstarr
sstarr / blogspot_to_jekyll.rb
Created February 16, 2012 16:01 — forked from kennym/blogspot_to_jekyll.rb
Migrate your blogger blog posts to jekyll.
#!/usr/bin/env ruby
#
# Convert blogger (blogspot) posts to jekyll posts
#
# Basic Usage
# -----------
#
# ./blogger_to_jekyll.rb feed_url
#
# where `feed_url` can have the following format:
@sstarr
sstarr / staging_deploy.sh
Created June 18, 2012 14:43
A sample Bash deployment script. This is for a Rails app hosted on an OS X server.
#!/usr/bin/env bash
# Configuration
SERVER='10.20.30.40'
DEPLOY_TO='/Users/simon/apps/some_app/staging/'
EXCLUDE='*.sqlite3 *.swp .DS_Store .git/ tmp/ log/ public/uploads/ uploads/'
DRY_RUN=false
DEPLOY_GEM_PATH='/Users/simon/.rvm/gems/ruby-1.9.2-p180'
MYSQL2_BUNDLE='/Users/simon/apps/some_app/staging/vendor/bundle/ruby/1.9.1/gems/mysql2-0.2.13/lib/mysql2/mysql2.bundle'
@sstarr
sstarr / config.log
Created September 23, 2012 15:33
Ruby on Mountain Lion
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by configure, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --prefix=/Users/simon/.rvm/rubies/ruby-1.9.3-p194 --enable-shared --disable-install-doc --with-libyaml --with-opt-dir=/Users/simon/.rvm/usr
## --------- ##
## Platform. ##
@sstarr
sstarr / gist:3848925
Created October 7, 2012 16:55
Sublime Text 2 Settings
{
"auto_complete_commit_on_tab": true,
"auto_complete_with_fields": true,
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"detect_slow_plugins": false,
"draw_white_space": "all",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",