Skip to content

Instantly share code, notes, and snippets.

@james
james / waitrose_login_paste.user.js
Created October 29, 2012 18:02
Waitrose Login Paste Password
// ==UserScript==
// @name Waitrose Login Paste Password
// @description Allow to paste password in Waitrose's login forms
// @author James Darling <james@abscond.org>
// @include http*://www.waitrose.com/*
// ==/UserScript==
document.getElementById("logonPasswordField").setAttribute("onpaste", "return true;");
document.getElementById("newPasswordField").setAttribute("onpaste", "return true;");
document.getElementById("logonPasswordVerifyField").setAttribute("onpaste", "return true;");
@james
james / gumtree_shout_ban.js
Created June 20, 2012 19:57
Hide all gumtree adds that are all caps
// ==UserScript==
// @name Gumtree Shout Ban
// @namespace GumtreeShoutBan
// @description Hide all gumtree adds that are all caps
// @include http://www.gumtree.com/*
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
@james
james / concise
Created May 19, 2012 15:44
Vault example JSON config storage
// Defaults are the same as website
{
'phrase': 'HASH',
'services': [
{'name': 'Twitter'},
{'name': 'Google'},
{
'name': 'Nationwide',
'length': 24,
'space': false,
I don't understand that if this is, and always has been a partisan account,
then why Boris received a formal letter of warning from the GLA when using
it to post partisan updates
(http://www.guardian.co.uk/politics/2009/dec/08/boris-johnson-twitter-party-political).
Surely you can agree that the account, if not illegal, has been misleading
enough for thousands of londoners and the GLA itself to confuse it as an
official public information source?
ethan:breakcore james$ ruby scrape.rb
"starting download of firestorm viper - \"cut dem down\""
"Failed 404 Not Found"
"starting download of firestorm viper - \"haters want war\""
"Failed 404 Not Found"
"starting download of firestorm viper - \"live in paris\""
"Failed 404 Not Found"
"starting download of firestorm viper - \"live in vancouver\""
"Failed 404 Not Found"
"starting download of kid606 - \"live at ultrahang fest, 09.25.03\""
@james
james / gist:1231642
Created September 21, 2011 09:16
attr_accessor parsed as a method variable when setting with a get
class Base
attr_accessor :configuration
def initialize(configuration)
@configuration = configuration
end
def do_a_thing
configuration = configuration + 1
end
@james
james / hipster.rb
Created March 7, 2011 11:10
10 minutes of filthy code to let me know if I'm allowed to like the tune I'm listening
require 'rubygems'
require 'json'
require 'net/http'
require 'cgi'
def track_info(title, artist)
JSON.parse(http.get("/2.0/?method=track.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=#{CGI.escape(artist)}&track=#{CGI.escape(title)}&format=json").body)
end
def http
Consider this:
`= select_tag "blockstyles[#{blockstyle}]"`
Now consider
`blockstyle == "[Basic Text Frame]"`
resulting in http parameter name

Deploying Rails

Passenger

We are using [Passenger][1] to serve Rails application requests, which integrates into Apache (it's also known as mod_rails). This means there is not much configuration to keep Rails running.

Rails environments

Rails internally handles a lot of the different environments. To set which environment Rails is running in, simply set the RailsEnv configuration in the apache vhost config file, which for this app is located at /etc/httpd/sites-available/application_name. We currently have 4 environments, of which only the last two will be relevant for you - development, test, staging and production.

#!/usr/bin/ruby
# Download NASA MODIS imagery and use it as a desktop background.
# You'll need ImageMagick installed for this to work.
require 'date'
require 'net/http'
# Screen width/height
X = 1440
Y = 900