Skip to content

Instantly share code, notes, and snippets.

@lstoll
lstoll / downloader.rb
Created April 30, 2012 03:34 — forked from chrisjm/s3-delete-bucket.rb
fork of s3-delete-files.rb -- Used for downloading a bucket with lots of files.
#!/usr/bin/env ruby
require 'rubygems'
require 'thread'
require 'fog'
# Ensure a bucket is specified
if ARGV.count < 4
raise "Specify a key, secret, bucket and output dir (eg ./downloader.rb key secret my-bucket '~/out')"
return
# On 10.7.3
/usr/bin/gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
- RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
@lstoll
lstoll / gist:2411499
Created April 18, 2012 06:41 — forked from lclarkmichalek/gist:1657284
Flymake mode for golang
(require 'flymake)
(defun flymake-go-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "go" (list "build" "-o" "/dev/null" temp-file))))
@lstoll
lstoll / Play_job.md
Created March 26, 2012 01:58
Scheudling jobs on heroku with the play framework.

Jobs with the Play! Framework and Heroku

First thing, create a job that runs your task. Don't set a timer or anything on it, we will trigger it manually.

You will need to add two things to your app. First is an endpoint that uses authorisation (for your security) to trigger the job in the background. Something like this will do it:

public class JobEndpoint extends Controller{ 
    public static void runTheJob(){ 
        if( "jobuser".equals(request.username) && "jobpass".equals(request.password) ){ 

new WhateverYourJobClassIs().now();

@lstoll
lstoll / clojure.clj
Created March 19, 2012 11:50
Docstrings
$ clj
Clojure 1.3.0
user=> (defn fun "Docstring" [] ())
#'user/fun
user=> (meta (var fun))
{:arglists ([]), :ns #<Namespace user>, :name fun, :doc "Docstring", :line 4, :file "NO_SOURCE_PATH"}
user=>
@lstoll
lstoll / runpg.sh
Created March 14, 2012 14:45
Simple script to run an app local postgres instance
#!/bin/bash
PORT=5556
DB=gsv
if [ ! -d "db" ]; then
sudo sysctl -w kern.sysv.shmall=65536
sudo sysctl -w kern.sysv.shmmax=16777216
mkdir db
initdb db
postgres -D db -p $PORT &
PGPID=$!
@lstoll
lstoll / mongo.py
Created March 13, 2012 04:16
MongoHQ w/ pymongo on Heroku
import os
import pymongo
if os.environ['MONGOHQ_URL']:
# Get a connection
conn = pymongo.Connection(os.environ['MONGOHQ_URL'])
# Get the database
db = conn[urlparse(os.environ['MONGOHQ_URL']).path[1:]]
else:
source :rubygems
gem "aws-s3", :require => 'aws/s3'
@lstoll
lstoll / pom.xml
Created March 12, 2012 03:57
A maven pom.xml that does nothing.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.lstoll</groupId>
<artifactId>nullpom</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>nullpom</name>
@lstoll
lstoll / get_nab_account_balances.rb
Created February 6, 2012 13:50 — forked from wezm/get_nab_account_balances.rb
Update for current NAB IB
require 'rubygems'
require 'nokogiri'
require 'mechanize'
require 'logger'
module BankBalance
class NabFetcher
def fetch(client_number, password)