Skip to content

Instantly share code, notes, and snippets.

View mjallday's full-sized avatar
🏠
WFH

Marshall Jones mjallday

🏠
WFH
View GitHub Profile
@mjallday
mjallday / watcher.py
Created March 8, 2012 17:36
File watcher in Python
#!/bin/python
"""
A simple directory watching script that will compute the checksum for all files
within a path and execute a change when the sum changes.
This will not work well with large files as it reads the entire file into
memory.
"""
import argparse
@mjallday
mjallday / balanced.py
Created November 1, 2012 19:01
Balanced Payments Card Error Map
response_codes = {
'201': 'Invalid CC Account Number',
'202': 'Bad Amount, Non-Numeric Amount',
'203': 'Zero Amount',
'204': 'Other Error',
'205': 'Bad Total Auth Amount',
'218': 'Invalid SKU Number',
'219': 'Invalid Credit Plan',
'220': 'Invalid Store Number',
#!/usr/bin/env python
from __future__ import unicode_literals
import pymongo
import threading
DB_NAME = 'events'
COLLECTION_NAME = 'events'
class Subscriber(threading.Thread):

Keybase proof

I hereby claim:

  • I am mjallday on github.
  • I am mjallday (https://keybase.io/mjallday) on keybase.
  • I have a public key whose fingerprint is 5043 3C86 AAD6 968F 3D28 8F98 F439 FD97 E280 4455

To claim this, I am signing this object:

@mjallday
mjallday / balanced.rb
Created January 22, 2014 16:25
bank account payment example - ruby
require 'balanced'
# create an api key and marketplace for example purposes only.
# in real-life you only do this once by the dashboard.
api_key = Balanced::ApiKey.new.save
Balanced.configure(api_key.secret)
marketplace = Balanced::Marketplace.new.save
# create a bank account. this is normally done with balanced.js
@mjallday
mjallday / bg_task.py
Created December 4, 2013 19:00 — forked from amjith/bg_task.py
import newrelic.agent
import time
import logging
logging.basicConfig()
logger = logging.getLogger('newrelic')
logger.setLevel(logging.DEBUG)
newrelic.agent.initialize('newrelic.ini', environment='staging')
newrelic.agent.register_application(timeout=10.0)
@mjallday
mjallday / CHANGELOG.md
Created December 3, 2013 19:00
CHANGELOG 1.0 -> 1.1
  • Cards can be charged without being associated to a customer
  • Transactions are now created via the funding instrument, not via the customer. E.g. card.debit(amount), bank_account.credit(amount) is now favoured over customer.debit(card, amount)
  • Failing to create a transaction will result in a transaction being created with a FAILED state. E.g. debiting a card with insufficient funds will result in a transaction with a FAILED state. These are filtered out of the API by default but can be specifically retrieved with a state filter e.g. /credits?state=failed
  • A new resource called "Orders" has been created to allow grouping transactions. An Order can consist of 0:n buyers, 0:n debits and 0:n credits to a single seller. Each debit associated with an Order will result in the Order's escrow balance accruing the value of the debit rather than the marketplace's escrow balance. You cannot pay out more than the total amount escrowed for an Order.
  • Accounts no longer exist, customers and orders are the
@mjallday
mjallday / EXAMPLE.mkd
Created November 21, 2013 21:07
Failed debit creates transaction

curl https://api.balancedpayments.com/debits -XPOST -u ak-test-2yK59ihwoOOk0S6wsg77iMGzLGnGxiohB: -d "source[number]=4444444444444448" -d "source[expiration_month]=12" -d "source[expiration_year]=2016" -d amount=100

{
  "errors": [
    {
      "status": "Payment Required",
      "category_code": "card-declined",
      "additional": "Account Frozen",
      "status_code": 402,
@mjallday
mjallday / example.mkd
Created November 21, 2013 21:04
Untokenized card debit

curl http://api.balancedpayments.com/debits -XPOST -u ak-test-2DBryLFR3BBam1CipbWEGSO6gqVOBKghP: -d "source[number]=4111111111111111" -d "source[expiration_month]=12" -d "source[expiration_year]=2016" -d amount=100

{
  "debits": [
    {
      "status": "succeeded",
      "description": null,
      "links": {
        "customer": "CU6wJUpqcVWf2JwgyfIsRy1z",
@mjallday
mjallday / README.mkd
Created November 21, 2013 19:28
Implement HTTP Server Problem

Implement a HTTP server which can respond to the following curl command

curl 'http://127.0.0.1:8000/images' -H 'Origin: http://127.0.0.1:8000' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: 127.0.0.1:8000' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: http://127.0.0.1:8000/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --data-binary '{"name":"Balanced","src":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAAAQCAMAAADDNnYVAAAAmVBMVEVXWFpfYGJpaWtycnR7e32EhIaNjY+Wlpefn6CipA+mqB2oqKmxsbKztUS6uru8vV/AwW3Dw8TExXvFxnvJyojMzMzR0qPV1dXW1rHa2r7e3t7e38zj49nmpRLmqR/mrSzmrS3msTnnyonnzpfn1rLn27/n38zn49rn5+fox8Xo0tDqk43qnZjqqKTriIHrk43tU0ntXlTuPzMyENYEAAACeklEQVR42q2VC5PTIBDHIUCghquiRhQ9H3enx/k4td//w7nLApvUpDPO+J+W7oNkfyQLFQ+/T4+56d3Tw9UbMq0mmSn29BH8UO0Z