Skip to content

Instantly share code, notes, and snippets.

;;
;; Read a CSV file and look up the product ids it contains in a
;; database. Report all the products in the CSV that do not exist in
;; the database.
;;
;; Usage: $0 <path-to-csv-file>
;;
(import 'java.io.FileReader 'au.com.bytecode.opencsv.CSVReader)
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
require 'yaml'
environment = YAML.load_file(".rea-env.yml")
connection_details = {
:provider => "AWS",
:endpoint => environment["ec2"]["url"],
@mrowe
mrowe / gist:1494680
Created December 18, 2011 22:31
iiNet DNS problems
$ dig PTR 169.41.170.124.in-addr.arpa.
; <<>> DiG 9.7.3-P3 <<>> PTR 169.41.170.124.in-addr.arpa.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43719
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;169.41.170.124.in-addr.arpa. IN PTR
@mrowe
mrowe / gist:1927654
Created February 27, 2012 22:43
a simple gradient
background: #f1dec2;
background: url("edge.png") repeat-x; /* fallback */
background: url("edge.png") repeat-x, -webkit-gradient(linear, left top, left bottom, from(#ebc17f), to(#f1dec2)); /* Saf4+, Chrome */
background: url("edge.png") repeat-x, -webkit-linear-gradient(left, #ebc17f, #f1dec1); /* Chrome 10+, Saf5.1+ */
background: url("edge.png") repeat-x, -moz-linear-gradient(left, #ebc17f, #f1dec1); /* FF3.6+ */
background: url("edge.png") repeat-x, -ms-linear-gradient(left, #ebc17f, #f1dec1); /* IE10 */
background: url("edge.png") repeat-x, -o-linear-gradient(left, #ebc17f, #f1dec1); /* Opera 11.10+ */
background: url("edge.png") repeat-x, linear-gradient(left, #ebc17f, #f1dec1); /* W3C */
@mrowe
mrowe / anything-git-project-files.el
Created August 2, 2012 01:17
Anything source to search files in current GIT project (http://www.emacswiki.org/emacs/AnythingSources#toc64)
(defvar anything-c-source-git-project-files-cache nil "(path signature cached-buffer)")
(defvar anything-c-source-git-project-files
'((name . "Files from Current GIT Project")
(init . (lambda ()
(let* ((git-top-dir (magit-get-top-dir (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory)))
(top-dir (if git-top-dir
(file-truename git-top-dir)
default-directory))
@mrowe
mrowe / job1273.md
Created November 26, 2012 04:10
Senior Software and Systems Engineer

We are home to Australia’s No.1 residential and commercial property websites, realestate.com.au and realcommercial.com.au. In the international marketplace, we operate the market-leading Italian property site, casa.it.

As Australia’s leading online property company, we pride ourselves on outstanding products and innovative thinking. We recognise that to continue to be the best in the business, we need to have the best people in the business. That’s where you come in.

As a technology focused business we pride ourselves on a forward thinking attitude, adoption of leading edge technologies and ways of working, such as agile and lean practices at scale, dev-ops, cloud adoption and award winning mobile apps. We also love to be involved in the IT community.

This current opportunity is in REA’s Delivery Services team. We’re a small cross-functional delivery team that provides direction and support to our Line of Business delivery teams in the use of our cloud environments, build engineering and tooling and specia

@mrowe
mrowe / nodes.clj
Created January 8, 2013 05:54
Rerender GET on POST on validation error
(defn create-form [{:keys [env name type]}]
(common/layout
[:h2 (str "Create instance in " env)]
(form-to [:post (str "/environments/" env "/create")]
(hidden-field "env" env) (hidden-field "principal" "web-ui")
(instance-fields name type)
(submit-button "Create"))))
(defroutes node-routes
@mrowe
mrowe / wait-for.clj
Last active July 20, 2020 18:09
A first attempt at a polling loop in clojure...
;; Based on a queue polling function from Chas Emerick's bandalore:
;; https://github.com/cemerick/bandalore/blob/master/src/main/clojure/cemerick/bandalore.clj#L124
(defn wait-for
"Invoke predicate every interval (default 10) seconds until it returns true,
or timeout (default 150) seconds have elapsed. E.g.:
(wait-for #(< (rand) 0.2) :interval 1 :timeout 10)
Returns nil if the timeout elapses before the predicate becomes true, otherwise
@mrowe
mrowe / api_tests.clj
Created February 2, 2013 00:19
Long-running web service integration tests in Clojure
(deftest ^:integration instance-lifecycle
(testing "create instance"
(def result (POST "/instances" (with-principal {:name "rea-ec2-tests/int-test-micro", :instance-type "t1.micro"})))
(has-status result 200)
(let [id (first (:body result))]
(prn (str "Created instance " id))
(testing "get instance"
@mrowe
mrowe / stopinator.rb
Created May 9, 2013 02:07
The genesis of the zombie apocalypse.
def ec2
Fog::Compute.new(:provider => 'AWS',
:aws_secret_access_key => ENV['EC2_SECRET_KEY'],
:aws_access_key_id => ENV['EC2_ACCESS_KEY'])
end
def tenured? (instance)
instance.created_at && (instance.created_at < Chronic.parse('50 minutes ago'))
end