Skip to content

Instantly share code, notes, and snippets.

View chrhicks's full-sized avatar

Chris Hicks chrhicks

  • Flow Commerce
  • New York
View GitHub Profile

Keybase proof

I hereby claim:

  • I am chrhicks on github.
  • I am chrhicks (https://keybase.io/chrhicks) on keybase.
  • I have a public key ASAnqvN5GeqpzwIjh1pecA0pEk1o-W1OpssD7UxmUQdjQgo

To claim this, I am signing this object:

@chrhicks
chrhicks / example-order.json
Created April 10, 2017 18:19
Example Flow order format
{
"id": 4684773897,
"lines": [
{
"variant_id": 6056723589,
"quantity": 1,
"price": {
"name": "Price",
"amount": 135,
"cents": 13500,
@chrhicks
chrhicks / apidoc.users.js
Last active October 25, 2015 19:26
Users client generated by apidoc
var request = require('request');
/**
* ## Responses
* Responses from this API with be wrapped in an envelope to assist the caller
* in dealing with the various responses from the service. There are no types
* to check against in JavaScript, so this facilitates that.
*
* {
* status: 200,
@chrhicks
chrhicks / index.html
Created January 31, 2014 12:03
A Pen by Chris Hicks.
<p>Given any integer print an English phrase that describes the integer. (e.g. "One Thousand, Three Hundred Twenty Four").</p>
<div id="log"></div>
@chrhicks
chrhicks / menu.scala
Created March 21, 2013 01:28
A navigation menu model
object menu extends App {
val admin = NavItem("Admin", Some("http://www.gilt.com/admin"))
.addChild("Sale", None)
.addChild(
NavItem("Product", Some("https://admin.gilt.com/product/"))
.addChild("Edit Product", Some("https://admin.gilt.com/proudct/edit/2123"))
)
println(admin)
@chrhicks
chrhicks / ProgramHelper.scala
Created February 26, 2013 15:10
Traversing a handlebars.scala Program
object ProgramHelper {
def filter(node: Node)(implicit filterFn: Node => Boolean): List[Node] = {
(if (filterFn(node)) List(node) else List()) ++ (node match {
case n:Path => n.value.flatMap(filter(_))
case n:Partial => filter(n.value)
case n:Mustache => filter(n.value) ++ n.parameters.flatMap(filter(_))
case n:Section => filter(n.name) ++ filter(n.value)
case n:Program => n.value.flatMap(filter(_)) ++ n.inverse.map(filter(_)).getOrElse(List())
case _ => List()
})
@chrhicks
chrhicks / HandlebarsHelper.scala
Created June 19, 2012 02:04
handlebars.scala from files
object HandlebarsHelper {
def apply(baseuri: String): HandlebarsHelper = new HandlebarsHelper(baseuri)
}
class HandlebarsHelper(baseuri: String) extends Loggable {
val EXTENSION = ".handlebars"
def fromFile(fileName: String): Handlebars =
Handlebars(parse(getFileContents(baseuri + "/" + fileName).getOrElse("")))
@chrhicks
chrhicks / uri.js
Created April 22, 2012 15:14 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"