Skip to content

Instantly share code, notes, and snippets.

View chrisroos's full-sized avatar

Chris Roos chrisroos

View GitHub Profile
@chrisroos
chrisroos / google-api-docs-offline.md
Created September 9, 2011 12:08
Using wget to create offline copies of Google API docs

I've used this in the past to grab offline copies of some of the Google API docs.

$ wget --no-parent --recursive --page-requisites --html-extension --convert-links "http://code.google.com/apis/gears/"

# --no-parent - Don't fetch anything in the parent directory of the URL specified
# --page-requisites - Download everything required for the page to display correctly
# --recursive - Recursively download (use default depth of 5)
# --html-extension - Add .html to downloaded html files (this isn't necessarily required for the google code example but might be useful on other sites)

--convert-links - Update links in the downloaded document to point to, either the downloaded copy of a file or a full URL

@chrisroos
chrisroos / background-colour-fadeout-test.html
Created September 16, 2011 14:56
Playing around with fading out background colours using pure Javascript.
<!DOCTYPE html>
<html>
<head>
<title>Background colour fadeout test</title>
</head>
<body>
<h1>Background colour fadeout test</h1>
<p>I wanted to work out how to fade background colours using pure Javascript.</p>
<script src="fadeout.js" type="text/javascript" charset="utf-8"></script>
</body>
@chrisroos
chrisroos / left-margin-notification-bar-test.html
Created September 16, 2011 14:59
Playing around with the idea of a notification bar to display canonical URLs. This is from a couple of years ago.
<!DOCTYPE html>
<html>
<head>
<link rel="canonical" href="http://example.com/path/to/resource">
<link rev="canonical" href="http://example.com/short-url">
<title>Left margin notification bar test</title>
</head>
<body>
<h1>Left margin notification bar test</h1>
<p>The idea behind this was to have something like the android notification bar that would appear when there were canonical links.</p>
@chrisroos
chrisroos / gist:1268834
Created October 6, 2011 22:06
Error message when viewing our GFR blog using Passenger and Ruby 1.9.2
[Error rendering 'list-of' - "invalid byte sequence in US-ASCII"]
list-of:15:in `split'
list-of:15:in `block in handle'
list-of:14:in `map'
list-of:14:in `handle'
/Users/chrisroos/.rvm/gems/ruby-1.9.2-p290/bundler/gems/vanilla-rb-38c454a3507b/lib/vanilla/renderers/ruby.rb:37:in `process_text'
/Users/chrisroos/.rvm/gems/ruby-1.9.2-p290/bundler/gems/vanilla-rb-38c454a3507b/lib/vanilla/renderers/base.rb:98:in `render_without_including_snips'
/Users/chrisroos/.rvm/gems/ruby-1.9.2-p290/bundler/gems/vanilla-rb-38c454a3507b/lib/vanilla/renderers/base.rb:87:in `render'
/Users/chrisroos/.rvm/gems/ruby-1.9.2-p290/bundler/gems/vanilla-rb-38c454a3507b/lib/vanilla/app.rb:64:in `block in render'
/Users/chrisroos/.rvm/gems/ruby-1.9.2-p290/bundler/gems/vanilla-rb-38c454a3507b/lib/vanilla/app.rb:116:in `rendering_and_handling_errors'
@chrisroos
chrisroos / grab-ramsgate-harbour-webcam-image
Created January 24, 2012 20:46
Simple script to download a snapshot from the Ramsgate harbour webcam
#!/usr/local/bin/ruby
wget_path = File.join('/', 'usr', 'local', 'bin', 'wget')
image_url = "http://82.69.41.142/axis-cgi/jpg/image.cgi?resolution=640x480&compression=50"
output_directory = File.join('/', 'home', 'chrisroos', 'ramsgate-harbour-webcam-images')
image_name = "#{Time.now.strftime('%Y%m%dT%H%M%S')}.jpg"
image_path = File.join(output_directory, image_name)
cmd = %%#{wget_path} "#{image_url}" -O"#{image_path}" --quiet%
@chrisroos
chrisroos / nokogiri-warning-with-pg-gem.md
Created March 29, 2012 12:24
The Nokogiri warning I'm seeing when using pg and nokogiri together.

To replicate the warning:

$ mkdir /tmp/pg-nokogiri-test
$ cd /tmp/pg-nokogiri-test

$ cat > Gemfile
source :rubygems

gem 'pg'

gem 'nokogiri'

@chrisroos
chrisroos / bootstrap.min.css
Created August 9, 2012 11:39
Exploring the History.js pushState problem with encoded UTF-8 characters
/*!
* Bootstrap v2.0.4
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;
@chrisroos
chrisroos / Gemfile
Last active December 17, 2015 05:39 — forked from gljeremy/disconnect.rb
source :rubygems
gem 'mechanize'
gem 'choice'
gem 'highline'
@chrisroos
chrisroos / testing-render-partial-and-assert-template.md
Created October 25, 2013 11:45
An investigation in testing `render :partial` with `assert_template`

Testing render :partial with assert_template

Testing the use of render :partial with the :object option

In short, in order to use assert_template, or expect(view).to render_template, to test the rendering of a partial with an :object you'll have to write it out longhand in the template.

# Use this in the template
<%= render partial: 'people', locals: { people: @people } %>

Rather than

@chrisroos
chrisroos / 0_reuse_code.js
Created November 4, 2013 16:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console