Skip to content

Instantly share code, notes, and snippets.

import lob
lob.api_key = 'YOUR_KEY'
api_version = 'v1'
api_url = 'https://api.lob.com/{version}/'.format(version=api_version)
#######################################################################################################################
def get_setting_int(description):
pc_setting_dict = {"4x6":1001,
@brianseitel
brianseitel / Lob.php
Created June 11, 2015 01:49
Lob API wrapper
<?php
use Guzzle\Http\Client;
use Guzzle\Http\EntityBody;
use Guzzle\Http\Message\Request;
use Guzzle\Http\Message\Response;
class Lob {
private $base_url = 'https://api.lob.com/v1/';
@brianseitel
brianseitel / lzw_compression.rs
Last active January 4, 2016 10:09
LZA Compression
use std::hashmap::HashMap;
fn main() {
let (encode_dict, decode_dict) = build_dict();
let uncompressed = ~"I like hot dogs";
let compressed = compress(uncompressed, encode_dict);
println!("{:?}", compressed);
let decompressed = decompress(compressed, decode_dict);
@brianseitel
brianseitel / fibonacci.rs
Created January 17, 2014 00:37
Fibonacci implementation in Rust
fn main() {
let max: uint = 25;
let results = fibonacci(max, ~[]);
for i in results.iter() {
println!("{}", i.to_str());
}
}
fn fibonacci(max: uint, mut list: ~[int]) -> ~[int] {
@brianseitel
brianseitel / levenshtein.rs
Created January 16, 2014 23:53
Levenshtein distance in Rust
fn main() {
let distance = levenshtein("brian", "seitel");
println!("{}", distance);
}
/*
Calculate the levenshtein distance between two strings.
@param first -
*/
fn levenshtein(first: &str, second: &str) -> uint {
@brianseitel
brianseitel / index.html
Created February 12, 2013 21:50
a birthday cmx.io
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg);">
<scene id="scene1">
<label t="translate(0,346)">
@brianseitel
brianseitel / ermagherd.py
Created August 5, 2012 22:10
Python port of @dancrew32's Ermagherd translator
# To use:
#
# erma = ermagerd("oh my god, a refrigerator1")
import re
class ermagerd:
def __init__(self, arg1):
print self.gherd(arg1)
@brianseitel
brianseitel / class.TMDB.php
Created April 12, 2012 15:27
TMDB Wrapper for API v3
<?
class TMDB {
const VERSION = 3;
const BASE_URL = 'api.themoviedb.org';
protected static $api_key = '';
public function __construct($api_key) {
@brianseitel
brianseitel / gist:1495488
Created December 19, 2011 05:09
SimpleXML to Array
function simplexml_to_array($simplexml_object, &$array) {
$children = $simplexml_object->children();
$executed = false;
foreach ($children as $elementName => $node) {
if ($array[$elementName] != null) {
if ($array[$elementName][0] !== null) {
$i = count($array[$elementName]);
simplexml_to_array($node, $array[$elementName][$i]);
} else {
$tmp = $array[$elementName];
@brianseitel
brianseitel / array_flatten.php
Created November 10, 2011 23:36
Take a multi-dimensional array and flatten it into a one-dimensional array.
function flatten_array($array, $return = array(), $main_key = '') {
if ($main_key)
$main_key = $main_key.'_';
foreach ($array as $k => $item) {
if (is_array($item))
$return = self::flatten_array($item, $return, $main_key.$k);
else {
$new_key = $main_key.$k;
$return[$main_key.$k] = $item;