Skip to content

Instantly share code, notes, and snippets.

Eoin Kelly eoinkelly

Block or report user

Report or block eoinkelly

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View safer_raw_sql.rb
class SaferRawSQL
TEXT_FORMAT = 0
BINARY_FORMAT = 1
##
# You must be using the PostgreSQL database to use this method because it
# relies on PostgreSQL features.
#
# This method returns the same results as `ActiveRecord::Base.execute` but it
# helps you avoid SQL injection attacks by using the PostgreSQL feature which
View work-alias.sh
# Add this to your ~/.zshrc (it only works in zsh not bash AFAIK)
# #####################################
# A fast way of chdir to a code project
function work {
cd ~/Code/repos/$1
}
function _work() {
local state
View nzsl_log_output_comparison.md

GET /numbers at log level 'debug' is 462 lines

[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Started GET "/numbers/" for 127.0.0.1 at 2019-01-19 17:25:17 +1300
[c23afe93-b615-4c4d-bf0a-539ea1d6928f] Processing by PagesController#show as HTML
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Parameters: {"slug"=>"numbers"}
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Setting Load (1.4ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."key" = $1 LIMIT $2  [["key", "footer"], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Page Load (11.2ms)  SELECT  "pages".* FROM "pages" WHERE "pages"."id" = $1 ORDER BY "pages"."order" ASC LIMIT $2  [["id", 11], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Page Load (3.2ms)  SELECT  "pages".* FROM "pages" WHERE "pages"."slug" = $1 ORDER BY "pages"."order" ASC LIMIT $2  [["slug", "numbers"], ["LIMIT", 1]]
[c23afe93-b615-4c4d-bf0a-539ea1d6928f]   Rendering pages/numbers.html.haml within layouts/application
View day_2.rb
module Part2
# 1
# 2 3 4
# 5 6 7 8 9
# A B C
# D
class State
def go_u; self; end
def go_d; self; end
def go_l; self; end
View Promises.md
@eoinkelly
eoinkelly / bus.rb
Created Sep 19, 2016
Command line tool to get upcoming bus departures for a particular stop in Wellington NZ
View bus.rb
#!/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 Apr 8, 2016
post push git hook that will automatically generate a codeship CI build badge that you can paste into your PR description
View post-push.rb
#!/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
View mulit-conns.rb
##
#
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 Nov 9, 2017
Upgrade Postgres to 9.4 using Homebrew on Mac OSX
View postgres-upgrade-recipe.sh
#!/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 Aug 29, 2015 — forked from cjolly/pg.sh
View 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
You can’t perform that action at this time.