Skip to content

Instantly share code, notes, and snippets.

get "/" do
set_common_variables
set_from_config(:title, :subtitle, :description, :keywords)
@heading = @title
@title = "#{@title} - #{@subtitle}"
@articles = Page.find_by_path("news").articles[0..7]
@body_class = "home"
cache haml(:index)
end
/* Multiget web service, written in Node
http://127.0.0.1:9001/?urls=http://example.com/,http://example.net/
Will fetch all URLs in parallel, then return a JSON response containing
the fetched content from them.
*/
var DEFAULT_TIMEOUT = 10000;
<commandset>
<command id="wordtracker-review-links-command"
oncommand="WT.LinkBuilder.reviewLinks()"/>
</commandset>
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="wordtracker-button"
class="toolbarbutton-1 chromeclass-toolbar-additional"
label="Wordtracker"
tooltiptext="Open the Wordtracker menu"
#!/bin/bash
# The script that I use to launch unicorn, running Rails 2.3 apps with
# Rack apps mounted within via Metal.
#
# The situation seems to be complicated by the fact that I deploy with one
# user account, and run my apps with another one (that has no perms - why do
# so few Ruby developers do this?). Getting sudo to set the path such that
# bundler could find everything it needed under the app's user account wasn't
# working out; hence this script. Run with sudo.
@gma
gma / app.rb
Created September 27, 2010 17:21
Enabling article dates in Nesta URLs
# This code enables URLs with dates in for pages that have date set.
#
# If you use this code then a page published on 27 September 2010 with a path
# (relative to Nesta's content directory) of /foo/bar will now be available
# from /2010/09/07/foo/bar.
#
# Installation:
#
# $ mkdir -p local
# $ cat >> local/app.rb # (paste the following code, then press ^D)
@gma
gma / app.rb
Created September 28, 2010 15:54
# To redirect to your latest article when somebody hits the home page
# of your Nesta site, try this:
#
# $ mkdir -p local
# $ cat >> local/app.rb # then paste in this code and type Ctrl-D
get "/" do
latest = Page.find_articles[0]
redirect latest.abspath
end
poncho% ~/bin/gist < foo.txt
#<Net::HTTPFound 302 Found readbody=true>
https://gist.github.com/gists/new
#!/bin/sh
## Functions
usage()
{
echo "Usage: $(basename $0) <name>" 1>&2
exit 1
}
@gma
gma / pre-commit
Created November 5, 2010 17:57
Stop yourself from committing failed merges -> .git/hooks/pre-commit
#!/bin/sh
to_grep()
{
ls | grep -v db | grep -v logs
}
contains_merge_marks()
{
local files=$*
@gma
gma / gist:674141
Created November 12, 2010 14:17
Bluepill config for resque
ENV["PATH"] = "/opt/ruby/bin:#{ENV['PATH']}"
ENV["RAILS_ENV"] = "production"
ENV["QUEUE"] = "*"
Bluepill.application("nichelator") do |app|
app.working_dir = "/var/apps/nichelator/current"
app.uid = "app"
app.gid = "app"
2.times do |i|
app.process("resque-#{i}") do |process|