Skip to content

Instantly share code, notes, and snippets.

View traviskaufman's full-sized avatar

Travis Kaufman traviskaufman

View GitHub Profile
@ungoldman
ungoldman / curl_post_json.md
Last active April 15, 2024 14:46
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@domenic
domenic / iterator-of-promises.js
Created July 12, 2013 21:27
Iterator of promises: forEach
function iteratorOfPromisesForEach(iterator, callback) {
var snapshot = iterator.next();
if (snapshot.done) {
return Promise.resolve();
}
return snapshot.value.then(callback).then(() => iteratorOfPromisesForEach(iterator, callback));
}
var result = iteratorOfPromisesForEach(filesIterator, function (file) {
// return immediately to just do sync processing
@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@oxbowlakes
oxbowlakes / scala-interview2.scala
Created March 2, 2012 12:08
Scala interview questions hard
trait MyList[+A] {
def fold[B](k: Option[(A, B)] => B): B
def map[B](f: A => B): MyList[B] = sys.error("Implement me in terms of fold")
def flatMap[B](f: A => MyList[B]): MyList[B] = sys.error("Implement me in terms of fold")
def headOption: Option[B] = sys.error("Implement me in terms of fold")
def tailOption: Option[MyList[B]] = sys.error("Implement me in terms of fold")
def isEmpty = sys.error("Implement me in terms of fold")
def length = sys.error("Implement me in terms of fold")
}
@jlbruno
jlbruno / ordinal.js
Last active July 28, 2022 14:58
Javascript Ordinal Numbers
// found here http://forums.shopify.com/categories/2/posts/29259
var getOrdinal = function(n) {
var s=["th","st","nd","rd"],
v=n%100;
return n+(s[(v-20)%10]||s[v]||s[0]);
}
@darktable
darktable / app.yaml
Created March 16, 2011 19:10
GAE: App.yaml designed for serving a static site on Google App Engine (Python). Copy your static html and files into a folder called "static" next to app.yaml. Contains a bunch of mimetype declarations from html5boilerplate's .htaccess. May not be neces
application: you-app-name-here
version: 1
runtime: python
api_version: 1
default_expiration: "30d"
handlers:
- url: /(.*\.(appcache|manifest))
mime_type: text/cache-manifest
@ishikawa
ishikawa / HeapPermute.java
Created November 5, 2008 00:16
B. Heap's permutation algorithm
import java.util.Arrays;
/**
* http://lucitworks.com/Snippets/Algorithms/permutation.htm
*/
public class HeapPermute {
private static void swap(int[] v, int i, int j) {
int t = v[i]; v[i] = v[j]; v[j] = t;
}