Skip to content

Instantly share code, notes, and snippets.

@jaredbeck
jaredbeck / gist:4156939
Created November 27, 2012 20:53
Using CURL to make a SOAP request against PFAPI 1.1

Given a file with a SOAP request ...

$ cat cupa_request.xml
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <q1:unit_fetch xmlns:q1="http://v1_1.v.pfapi.remote_api">

cupahr_remote

@jaredbeck
jaredbeck / automatic_constructor.cfc
Last active December 10, 2015 06:08
Constructors in ColdFusion
component {
if (NOT StructKeyExists(this, 'initialized') OR this.initialized EQ false) {
init();
}
public void function init() {
this.foo = 'bar';
this.initialized = true;
}
}
@jaredbeck
jaredbeck / bundler-1.3-ssl.md
Last active December 14, 2015 08:58
bundler 1.3 checks the identity of rubygems

Bundler 1.3 checks the identity of rubygems.org

by Jared Beck, 2013-02-28

If your gemfile starts with

source 'https://rubygems.org'

and you upgrade to bundler 1.3, you may get a warning like

@jaredbeck
jaredbeck / Gemfile
Created April 23, 2013 18:23
Ruby bug 8308 supporting files
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '3.2.13'
gem 'pg'
gem 'taps'
# Web server
gem 'unicorn'
@jaredbeck
jaredbeck / ruby_introspection.md
Created May 28, 2013 00:41
Use `source_location` to find where a method is defined

TL;DR

Use ruby's [Method#source_location][1] to determine where a method is defined.

method(:s).source_location
# => ["..snip../gems/sexp_processor-4.2.1/lib/sexp.rb", 332]
@jaredbeck
jaredbeck / heroku_pull.rb
Last active December 18, 2015 05:29
A script to export a heroku database and overwrite the specified local database
#!/usr/bin/env ruby
#
# `Puller` exports a heroku database, and overwrites the specified
# local database. See "Importing and Exporting Heroku Postgres
# Databases with PG Backups" (http://bit.ly/15Udpfl)
# -Jared Beck 2013-06-07
#
class Puller
def initialize args
@jaredbeck
jaredbeck / crash
Created June 12, 2013 21:04
qt5 - webkit_server cannot find QtWebKit
Process: webkit_server [4641]
Path: /Users/USER/*/webkit_server
Identifier: webkit_server
Version: ???
Code Type: X86-64 (Native)
Parent Process: ruby [4637]
User ID: 501
Date/Time: 2013-06-12 17:00:06.378 -0400
OS Version: Mac OS X 10.8.3 (12D78)
PID/THRD SYSCALL(args) = return
18235/0x163c3b: execve("/Users/jared/bin/bash\0", 0x7FFF5310DBA8, 0x7FFF5310DBC8) = -1 Err#2
18235/0x163c3b: execve("/usr/local/bin/bash\0", 0x7FFF5310DBA8, 0x7FFF5310DBC8) = -1 Err#2
18235/0x163c3b: execve("/Users/jared/.rbenv/shims/bash\0", 0x7FFF5310DBA8, 0x7FFF5310DBC8) = -1 Err#2
18235/0x163c3b: execve("/Users/jared/.rbenv/bin/bash\0", 0x7FFF5310DBA8, 0x7FFF5310DBC8) = -1 Err#2
18235/0x163c3b: execve("/usr/local/heroku/bin/bash\0", 0x7FFF5310DBA8, 0x7FFF5310DBC8) = -1 Err#2
18235/0x163c3b: execve("/usr/bin/bash\0", 0x7FFF5310DBA8, 0x7FFF5310DBC8) = -1 Err#2
18235/0x163c3b: thread_selfid(0x0, 0x1DC0, 0x7FFF671FD550) = 1457211 0
18235/0x163c3b: csops(0x0, 0x0, 0x7FFF5310D294) = 0 0
18235/0x163c3b: issetugid(0x0, 0x0, 0x0) = 0 0
@jaredbeck
jaredbeck / gist:58420c1daaa870869619
Created July 27, 2015 20:33
paper_trail issue 572
Loading development environment (Rails 4.2.3)
irb(main):001:0> s = Subgroup.create!(name: "sub")
(0.1ms) begin transaction
SQL (0.3ms) INSERT INTO "subgroups" ("name", "created_at", "updated_at") VALUES (?, ?, ?) [["name", "sub"], ["created_at", "2015-07-27 20:23:35.477973"], ["updated_at", "2015-07-27 20:23:35.477973"]]
SQL (0.2ms) INSERT INTO "versions" ("event", "created_at", "item_id", "item_type") VALUES (?, ?, ?, ?) [["event", "create"], ["created_at", "2015-07-27 20:23:35.477973"], ["item_id", 1], ["item_type", "Subgroup"]]
SQL (0.3ms) UPDATE "versions" SET "transaction_id" = ? WHERE "versions"."id" = ? [["transaction_id", 1], ["id", 1]]
(2.3ms) commit transaction
=> #<Subgroup id: 1, name: "sub", created_at: "2015-07-27 20:23:35", updated_at: "2015-07-27 20:23:35">
irb(main):002:0> f = Faq.create!(name: "faq", subgroups: [s])
(0.1ms) begin transaction
@jaredbeck
jaredbeck / pt_issue_663.rb
Created January 8, 2016 04:58
PaperTrail Issue 663 - Unable to reproduce
# https://github.com/airblade/paper_trail/issues/663
# Use this template to report PaperTrail bugs.
# It is based on the ActiveRecord template.
# https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e