Skip to content

Instantly share code, notes, and snippets.

View eoinkelly's full-sized avatar

Eoin Kelly eoinkelly

View GitHub Profile
@eoinkelly
eoinkelly / bus.rb
Created September 19, 2016 07:05
Command line tool to get upcoming bus departures for a particular stop in Wellington NZ
#!/usr/bin/env ruby
require "nokogiri"
require "net/http"
courtenay_place = 5002 # Get your stop number from the metlink.co.nz website
buses_i_care_about = %w(52 56 57 58)
# .../departures returns 20 results
@eoinkelly
eoinkelly / post-push.rb
Created April 8, 2016 13:21
post push git hook that will automatically generate a codeship CI build badge that you can paste into your PR description
#!/usr/bin/env ruby
require "net/http"
require "json"
CODESHIP_API_KEY = "PUT_YOUR_CODESHIP_API_KEY_HERE".freeze
origin_remote_url = `git config --get remote.$(git config --get branch.master.remote).url`.chomp
current_project_name = %r{(?:\:|\/)(.+)\.git$}.match(origin_remote_url)[1]
current_branch_name = `git rev-parse --abbrev-ref HEAD`.chomp
##
#
class Connection
def self.create_many(inits)
inits.map { |init| new(init) }
end
def self.for_all(conns, &block)
block.call(conns)
end
@eoinkelly
eoinkelly / postgres-upgrade-recipe.sh
Last active November 9, 2017 16:59
Upgrade Postgres to 9.4 using Homebrew on Mac OSX
#!/bin/bash
# This script can be used in "run & hope" mode or you can use it as a recipe to
# do things manually - you probably want the latter if you really care about
# the data in your databases.
# Happy hacking
# /Eoin/
# Tell bash to stop if something goes wrong
set -e
@eoinkelly
eoinkelly / pg.sh
Last active August 29, 2015 14:11 — forked from cjolly/pg.sh
newpg=9.3.2
oldpg=9.2.4 # set this to your current PG version
# Stop current Postgres server
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Backup current db
mv /usr/local/var/postgres/ /usr/local/var/postgres-$oldpg
# Homebrew
@eoinkelly
eoinkelly / hybrid-apps-2014.md
Last active August 29, 2015 14:11
A brief overview of Hybrid apps in 2014

Hybrid apps in 2014

  • What is is like to build hybrid apps in 2014?
  • How does it differ from mobile development in 2014?

The tools:

  • Webviews
    • WebView not necessairly the same as the built-in browser on the device.
  • Apache Cordova

Keybase proof

I hereby claim:

  • I am eoinkelly on github.
  • I am eoinkelly (https://keybase.io/eoinkelly) on keybase.
  • I have a public key whose fingerprint is 05FB 2362 B986 574E 8E04 10BD 6491 A52A CC5D AABC

To claim this, I am signing this object:

@eoinkelly
eoinkelly / tinymce_fill_in.rb
Created September 9, 2014 23:53
A capybara helper to fill in text into a TinyMCE editor instance
##
# id must be the id attribute of the editor instance (without the #) e.g.
# <textarea id="foo" ...></textarea>
# would be filled in by calling
# tinymce_fill_in 'foo', 'some stuff'
#
def tinymce_fill_in(id, val)
# wait until the TinyMCE editor instance is ready. This is required for cases
# where the editor is loaded via XHR.
sleep 0.5 until page.evaluate_script("tinyMCE.get('#{id}') !== null")
// I am confused about how you can use `call` without supplying an object for `this`
// The docs don't indicate that you can:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
var funny = function (a) { return (a + 3); }
funny(3); // 6
funny.call({},3); // 6
funny.call(3); // NaN // (as expected)
var xs = [1,2,3]