Skip to content

Instantly share code, notes, and snippets.

View amasses's full-sized avatar

Matthew Lewis amasses

View GitHub Profile
@amasses
amasses / standard-payment.php
Created July 26, 2012 00:10
PHP Standard Payments example
<?php
include_once("FatZebra.class.php");
define("FATZEBRA_USERNAME", "TEST");
define("FATZEBRA_TOKEN", "TEST");
define("FATZEBRA_GATEWAY", "gateway.sandbox.fatzebra.com.au"); // Live: gateway.fatzebra.com.au
define("FATZEBRA_TEST_MODE", true);
$gateway = new FatZebra\Gateway(FATZEBRA_USERNAME, FATZEBRA_TOKEN, FATZEBRA_TEST_MODE, FATZEBRA_GATEWAY); // The last option can be omitted to use the live gateway
@amasses
amasses / benchmark_names.rb
Created March 16, 2012 05:40
Benchmark of different way to make a name string from first_name and last_name
# Note: I realize this is trivial, but this is a pattern I use a lot (name from first/last) so I was
# curious as to which method was quicker, and if perhaps I've been doing it wrong...? Run on 1.9.3
require 'benchmark'
first_name = "john"
last_name = "smith"
i = 1000000
# Reopen string to add the blank? method
@amasses
amasses / lib_gateway_money_monkey.rb
Created June 7, 2011 23:07
Spree Payments Issue
# lib/gateway/money_monkey.rb
class Gateway::MoneyMonkey < Gateway
preference :login, :string
preference :token, :string
def provider_class
ActiveMerchant::Billing::MoneyMonkeyGateway
end
end
@amasses
amasses / roulette.rb
Created December 10, 2010 05:46
For http://www.engineyard.com/blog/2010/engine-yard-lucky-13-contest/ - I know it said as fewer lines as possible, but I'm just bored and procrastinating so... enjoy :)
require 'httparty'
require 'json'
WHEEL_URL = "http://roulette.engineyard.com"
LUCKY_NUMBER = 13 #or not so lucky
PAYOUT_FACTOR = 35
def spin_the_wheel(bet)
spin = HTTParty.get(WHEEL_URL)
[Broc-MBP.local]: Broc:~/.bin [git:master!]
→ cd /tmp
[Broc-MBP.local]: Broc:/tmp
→ git clone http://github.com/jnunemaker/mongomapper.git
Initialized empty Git repository in /private/tmp/mongomapper/.git/
mviremote: Counting objects: 6667, done.
remote: Compressing objects: 100% (2387/2387), done.
Receiving objects: 27% (1801/6667), 316.00 KiB | 97 KiB/s
remote: Total 6667 (delta 4737), reused 6014 (delta 4193)
var app = {
featureTimeoutHandle: -1,
setupUserDialog: function() {
jQuery(".user_placeholder").load("/members/current.js?r=" + location.href);
jQuery("a#signin_link").live("click", function(e) {
e.preventDefault();
e.stopPropagation();
jQuery("#login_dialog").fadeIn();
});
/*
* Fabtabulous! Simple tabs using Prototype
* http://tetlaw.id.au/view/blog/fabtabulous-simple-tabs-using-prototype/
* Andrew Tetlaw
* version 1.1 2006-05-06
* http://creativecommons.org/licenses/by-sa/2.5/
*
* Note: getInitialTab() method modified for Swellnet
*/
var Fabtabs = Class.create();
(function($) {
$.fn.fabtabs = function() {
var target = $(this);
this.fabtab.init(target);
return this;
};
// Some local storage..
$.fn.fabtab = {
development:
access_key_id: YOUR-KEY-ID
secret_access_key: YOUR-SECRET-KEY
test:
access_key_id:
secret_access_key:
production:
access_key_id: YOUR-KEY-ID
@amasses
amasses / benchmarker.rb
Created March 2, 2010 13:41
Ruby files used for benchmarking
require 'rubygems'
require 'active_support'
require 'active_support/core_ext'
require 'ohm'
require 'mongo_mapper'
require 'benchmark'
require 'dm-core'
require 'model1'
require 'model2'
require 'model3'