Skip to content

Instantly share code, notes, and snippets.

View jcoleman's full-sized avatar

James Coleman jcoleman

  • Braintree Payments
  • Greenville, SC
View GitHub Profile
@jcoleman
jcoleman / Rakefile
Created March 30, 2023 15:32
Using ActiveRecord Migrations outside of a Rails app
require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
require "erb"
require "yaml"
require "active_record"
- (void) setExpirationTextField:(UITextField*)expirationTextField {
_expirationTextField = expirationTextField;
JCTextFieldSetKeyboardToDigits(expirationTextField);
}
- (void) setCardNumberTextField:(UITextField*)cardNumberTextField {
_cardNumberTextField = cardNumberTextField;
JCTextFieldSetKeyboardToDigits(cardNumberTextField);
}
gem "pg_query", :git => "git@github.com:jcoleman/pg_query.git", :ref => "f870ce136ea15a33cf9e2aabf7e8b20607061d8a"
@jcoleman
jcoleman / gist:5569537
Last active December 17, 2015 06:59 — forked from pmdarrow/gist:3427827
# These instructions were tested on Ubuntu 12.04 64bit
# Be prepared to wait a while...
sudo apt-get install openssl build-essential xorg libssl-dev libxrender-dev libxext-dev libpq-dev libx11-dev
git clone git://github.com/antialize/wkhtmltopdf.git
git clone git://github.com/jcsalterego/wkhtmltopdf-qt.git
cd wkhtmltopdf
mkdir static-build
ln -s ../wkhtmltopdf-qt static-build/qt
./scripts/static-build.sh
@jcoleman
jcoleman / gist:5052148
Created February 27, 2013 21:56
Ruby 1.9.3p392 compilation error (Clang, Mac OS 10.8)
[2013-02-27 16:49:27] make
CC = clang
LD = ld
LDSHARED = clang -dynamiclib
CFLAGS = -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Werror=pointer-arith -Werror=write-strings -Werror=declaration-after-statement -Werror=shorten-64-to-32 -Werror=implicit-function-declaration -fno-common -pipe
XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hidden -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libxml2/include -I/usr/local/opt/libxslt/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I. -I.ext/include/x86_64-darwin12.2.1 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace -install_name /Users/jcoleman/.rvm/rubies/ruby-1.9.3-p392-nclang/lib/libruby.1.9.1.dylib -current_version 1.9.1 -compatibility_version 1.9.1
@jcoleman
jcoleman / coalescing_priority_queue.rb
Created September 27, 2012 13:11
Naïve implementation of a coalescing priority queue.
require 'algorithms'
# Hybrid data structure: A priority queue in which each value pushed
# also contains an indentifying key. If a new value with that same key
# is pushed before the previous one is popped, then only the one with
# the higher priority will actually be available. The implementation
# also guarantees that should multiple values with the same key and
# the same priority be pushed, the queue with will function in a
# last-in-first-out manner.
@jcoleman
jcoleman / PCPropertyObserver.h
Last active October 9, 2015 18:08 — forked from pnc/PCPropertyObserver.c
PCPropertyObserver
// © 2011-2014 Phillip N. Calvin, James Coleman
// For use in a setter.
// Signs up self to receive KVO notifications about given properties
// on any new value and removes self as an observer from the old value.
// For example, to observe properties of a property called customer
// (backed by ivar _customer):
// PCPropertyObserver(customer, @"allowSubscriptionPurchase", @"availableProducts");
// You'd need to write this selector yourself:
with recursive
deck_cards as (
select face_values.card, suits.i as suit
from generate_series(1, 13) as face_values(card)
cross join generate_series(1, 4) as suits(i)
order by random()
),
deck_cards_with_player_indices as (
select (row_number() over ()) % 2 as player_index, deck_cards,card
from deck_cards
From c1358ec83a89819416f0a68a674cc06c325e8e81 Mon Sep 17 00:00:00 2001
From: James Coleman <james.coleman@m33integrated.com>
Date: Thu, 2 Jun 2011 10:22:37 -0400
Subject: [PATCH] Faster retrieval of bills of lading on consolidation.
---
.../tms/controllers/ShipmentController.groovy | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/grails-app/controllers/com/m33integrated/tms/controllers/ShipmentController.groovy b/grails-app/controllers/com/m33integrated/tms/controllers/ShipmentController.groovy
# The idea here is to emulate Groovy's delegate= pattern for closures.
# We define a builder module. This will receive method calls
# from our builder. It could be an instance of an object if we wanted.
module FamilyBuilder
def self.parent(name)
puts "Parent: #{name}"
end
def self.child(name)