Skip to content

Instantly share code, notes, and snippets.

@david-torres
david-torres / AmazonSignatureUtil.py
Created September 9, 2011 15:13
A basic utility class written in Python that verifies an Amazon Simple Payments return url or IPN url using VerifySignature from the FPS API
import base64
import hmac
import hashlib
import urllib
import urllib2
import time
from datetime import datetime, tzinfo
from xml.dom import minidom
@david-torres
david-torres / ClickyApi.py
Created October 29, 2011 22:22
Simple Python interface for Clicky web analytics API
import requests
import json
class ClickyApi(object):
"""
A simple Python interface for the Clicky web analytics api.
Relies on the Requests library - python-requests.org
Usage:
@david-torres
david-torres / diffbot.py
Created November 3, 2011 18:13
Simple Python interface for Diffbot API
import requests
import json
class Diffbot(object):
"""
A simple Python interface for the Diffbot api.
Relies on the Requests library - python-requests.org
Usage:
@david-torres
david-torres / gist:3013369
Created June 28, 2012 19:31
Hello World using Moai SDK
MOAISim.openWindow('test', 320, 480)
viewport = MOAIViewport.new()
viewport:setSize(320, 480)
viewport:setScale(320, 480)
layer = MOAILayer2D.new()
layer:setViewport(viewport)
MOAISim.pushRenderPass(layer)
@david-torres
david-torres / db_exists.js
Last active July 7, 2023 16:26
[mongo db_exists command] MongoDB command to check if a database exists. I use it with a puppet script to conditionally load up a database dump if one isn't detected. Useful for provisioning Vagrant. Returns with exit code zero if the database was found. #mongodb
function db_exists(db_name) {
db = db.getSiblingDB('admin');
db.runCommand('listDatabases').databases.forEach(function(db_entry){
if (db_entry.name == db_name) {
// quit with exit code zero if we found our db
quit(0);
}
});
// quit with exit code 1 if db was not found
@david-torres
david-torres / sort_hex.php
Last active June 15, 2017 15:40
[sort hex] Sort an array of hexadecimal numbers in PHP #php
<?php
$hexValues = array(
dechex(10), // a
dechex(42), // 2a
dechex(111), // 6f
dechex(78), // 4e
dechex(16) // 10
);
usort($hexValues, function($a, $b){

Keybase proof

I hereby claim:

  • I am david-torres on github.
  • I am detour (https://keybase.io/detour) on keybase.
  • I have a public key ASAfJq14-bdH5FUHOCLONuhlQCqd9FDSwoVDIsWT2P4newo

To claim this, I am signing this object:

@david-torres
david-torres / nginx.conf
Created November 18, 2019 15:25 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which