Skip to content

Instantly share code, notes, and snippets.

View terrafied's full-sized avatar
💭
Shopping for cute shoes

Terra Metta terrafied

💭
Shopping for cute shoes
  • The Trans Agenda
  • 62 West Wallaby St., The Shire
View GitHub Profile
@terrafied
terrafied / soap.php
Last active December 20, 2015 11:39
One Page Soap Server
// Create a file named "login.php" within a WSDL recognized folder (e.g. www/test/wsdl).
<?php
if(!extension_loaded("soap")){
dl("php_soap.dll");
}
ini_set("soap.wsdl_cache_enabled","0");
$server = new SoapServer("login.wsdl");
function UserLoginCommand($yourName){ //EXAMPLE! NOT VALID ARGUMENT LIST

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

@terrafied
terrafied / gist:5622175
Last active December 17, 2015 14:09
Regex for replacing ruby hashes keyed with symbols
Search regex: :([\w\d]+)(?:\s*)=>(?:\s*)
Replace: $1:
@terrafied
terrafied / safe_transpose.rb
Created May 17, 2013 20:35
Safe transpose method, to avoid IndexErrors with non-rectangular multidimensional arrays
# Safe transpose method, to avoid IndexErrors with non-rectangular multidimensional arrays
# >> a = [[1,2], [3,4], [5]]
# >> puts a.transpose.inspect
# [[1, 3, 5], [2, 4, nil]]
class Array
def safe_transpose
result = []
max_size = self.max { |a,b| a.size <=> b.size }.size
max_size.times do |i|
result[i] = Array.new(self.first.size)
@terrafied
terrafied / maybe_match.rb
Last active December 16, 2015 20:29
RSpec matcher to allow for possible, not required, conditions
require 'rspec/expectations'
# It would be better if we could change this to pending on the fly, but that happens in a higher scope,
# so there's nothing but "pass" or "fail"
RSpec::Matchers.define :maybe_match do |expected|
match do |actual|
true
end
description do |actual|
@terrafied
terrafied / .gitconfig
Last active May 12, 2016 14:23 — forked from igal/.gitconfig
#---[ Includes ]--------------------------------------------------------
[include]
# Load private information from a separate file, e.g. name, email, global
# ignores, tokens, etc.
path = ~/.gitconfig.local
#---[ Settings ]--------------------------------------------------------
[core]
@terrafied
terrafied / pull.rb
Last active December 14, 2015 21:49
Hub pull-request command, simplified. Update defaults, then you can just run ```pull.rb``` without options for most current pull request, or easily add branch-specific info with less hassle. I'd alias to something like ```gpr```
#!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: pull.rb [options]"
###### DEFAULTS
options[:account] = "qstream"
#!/bin/bash
# This script is edited by Brice Dutheil
# See there in french http://blog.arkey.fr/2012/07/30/script-pour-installer-le-jdk-5-sur-macosx-lion/
# Translate button is broken for now, please use Google to translate this website.
#
# 2012/08/25 This script didn't behave correctly when ran on 10.8.1
# Added recommendation to always run this script after updates such as Java, XCode, OSX, etc.
#
# 2O12/07/29 Added Mountain Lion support => Choose the 64bit JVM !
@terrafied
terrafied / query.sql
Created October 26, 2012 17:14
Timeseries query in Postgres
CREATE OR REPLACE VIEW opendiscrepencydailycounts AS
WITH opendays(day) AS (
SELECT gs.day::date AS day
FROM generate_series((( SELECT
min(discrepencylist.discstartdt) AS min
FROM discrepencylist))::timestamp without time
zone, 'now'::text::date::timestamp without time zone, '1
day'::interval) gs(day)
)
SELECT opendays.day, ds.resolvingparty, count(opendays.day) AS
@terrafied
terrafied / query.sql
Created October 5, 2012 18:16
non-first
SELECT question_records.* FROM `question_records` WHERE `question_records`.`enrollment_id` IN (50912, 59119, 56414, 59171, 52856, 59168, 52857, 59169, 52858, 59170, 52859, 59173, 52860, 59172, 52861, 59118, 52862, 59114, 52863, 59112, 52864, 59116, 52865, 59113, 52866, 59115, 52867, 59117, 52868, 59124, 52869, 59123, 52871, 59121, 52872, 59126, 52873, 59127, 52874, 59128, 52875, 59122, 52876, 59125, 52877, 59129, 52878, 59132, 52879, 59135, 52880, 59134, 52881, 59131, 52882, 52883, 59133, 52884, 59130, 52886, 59136, 52887, 59138, 52888, 59137, 52889, 59140, 52890, 59142, 52891, 59141, 52892, 59139, 52893, 59144, 52894, 59149, 52895, 59147, 52896, 59151, 52898, 59150, 52899, 59148, 52900, 59145, 52901, 59157, 52902, 59154, 52903, 59158, 52904, 59152, 52905, 59153, 52906, 59155, 52907, 52908, 59156, 52909, 59159, 52910, 59166, 52911, 59167, 52912, 59165, 52913, 59163, 52914, 59164, 52915, 59160, 52916, 59162, 52917, 59161, 58688, 59120, 60804, 60805, 60806, 60807, 60808, 60809, 60810, 65942, 65943, 65944) AND `