Skip to content

Instantly share code, notes, and snippets.

View avocade's full-sized avatar
💭
Designing domains and coding clojure for Fluent.to

Oskar Boëthius Lissheim avocade

💭
Designing domains and coding clojure for Fluent.to
View GitHub Profile
@jcarbaugh
jcarbaugh / fsql.py
Created April 23, 2009 18:12
convert a MySQL dump into SQLite
#!/usr/bin/env python
# Convert a mysql dump into a sqlite-compatible format.
# I wrote this for just one script... no guarantess that it will work with others...
# python fsql.py < mysqldump.sql > readyforsqlite.sql
import re
import sys
content = sys.stdin.read()
def calculate_range_start_of_months
#Catacrocker obscurism
[current = range.begin.beginning_of_month].tap { |result| result << current while (current += 1.month) <= range.end }
end
@jnunemaker
jnunemaker / database.yml
Created November 12, 2009 14:59
mongo initializer to load config from database.yml, authenticate if needed and ensure indexes are created
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
@ato
ato / debug.clj
Created December 9, 2009 11:42
Simpler debug-repl that works with unmodified Clojure
;; Inspired by George Jahad's version: http://georgejahad.com/clojure/debug-repl.html
(defmacro local-bindings
"Produces a map of the names of local bindings to their values."
[]
(let [symbols (map key @clojure.lang.Compiler/LOCAL_ENV)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(declare *locals*)
(defn eval-with-locals
@markbates
markbates / watchr script
Created July 20, 2010 15:25
A Watchr script for rails, rspec, and cucumber
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
@lukeredpath
lukeredpath / fetch_finance_reports.rb
Created July 28, 2010 15:00
Fetch iTunes finance reports for your iPhone apps
#!/usr/bin/env ruby
require 'mechanize'
require 'open-uri'
require 'pathname'
require 'fileutils'
require 'pp'
### BEGIN CUSTOMIZATION
# set this to where you would like the reports to be stored
@lukeredpath
lukeredpath / process_finance_report.rb
Created July 28, 2010 15:14
A script for processing iTunes finance reports and importing to FreeAgent
#!/usr/bin/env ruby
### REQUIRED GEMS: restclient, activesupport, crack, mash, money, fastercsv
### USAGE
# fetch_finance_reports finance_report_1 finance_report_2 ... finance_report_x
### BEGIN CUSTOMIZATION
# I like to store this in a separate file in my home folder, ~/.freeagent
class CucumberExternalResqueWorker
DEFAULT_STARTUP_TIMEOUT = 1.minute
COUNTER_KEY = "cucumber:counter"
class << self
attr_accessor :pid, :startup_timeout
def start
# Call from a Cucumber support file so it is run on startup
return unless Rails.env.cucumber?
require 'eventmachine'
require 'json'
require 'mimic'
require 'logger'
module FakeCampfireServer
class Handler
def initialize(ipc)
@ipc = ipc
@ipc.delegate = self
class Sequence
class << self
def sequences
Enumerator.new do |y|
sequence = Sequence.new
while sequence
sequence = sequence.next
break unless sequence