Skip to content

Instantly share code, notes, and snippets.

@laser
laser / Timeout.hs
Created October 29, 2015 02:55
Experimenting with timeout
module Timeout where
import Control.Concurrent (threadDelay)
import System.Timeout (timeout)
onesecond = 1000000
timeoutmax = onesecond * 2
delay = timeoutmax * 2 -- timer will expire before delay ends
@laser
laser / BigData.scala
Created October 15, 2015 19:03 — forked from davegurnell/BigData.scala
Slick database mapping of >22 columns using HLists
import slick.driver.MySQLDriver.simple._
import scala.slick.collection.heterogenous._
import scala.slick.collection.heterogenous.syntax._
import scala.slick.jdbc._
// This is the large case class we are mapping -- 25 string fields:
case class BigData(
field1: String,
field2: String,
field3: String,
@laser
laser / gist:7647d1d10d04c2510a57
Last active September 15, 2015 03:03 — forked from cvogt/gist:9239494
Slick app architecture cheat sheet
// Please comment in case of typos or bugs
import scala.slick.driver.H2Driver._
val db = Database.for...(...)
case class Record( ... )
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){
...
def * = ... <> (Record.tupled,Record.unapply)
// place additional methods here which return values of type Column
@laser
laser / Derp.hs
Created September 4, 2015 02:41
yarply
module Main where
data Foo = Foo
{ x :: String
, y :: String
, z :: String
} deriving (Show)
q = Foo "one" "two" "three" -- Foo {x = "one", y = "two", z = "three"}
@laser
laser / alt-composition.js
Last active August 29, 2015 14:23
composing non-unary functions
var async = require('async');
var _ = require('lodash');
var $ = require('./utilities.js');
//////////////////////////////////////////////////
// two simple unary functions, for demonstration
// purposes
function dubble(x) {
return x * 2;
@laser
laser / looper.sh
Last active August 29, 2015 14:22
testing the services
#!/bin/bash
echo "Running diffs against responses from service at: $1"
for run in {1..9999}
do
curl $1/mobile/videos/search?query=Star+Trek\&pageSize=1 | json_pp | diff api-movieclips/test/fixtures/search.json -
if [ $? -eq 1 ]; then
osascript -e 'display notification "MovieClips API Video Search call failed" with title "MovieClips API Failure"'
fi
@laser
laser / home.json
Created June 9, 2015 16:00
HOME.JSON
{
"navigation" : [
{
"dateUpdated" : "2015-06-02T23:05:47.760Z",
"mature" : null,
"description" : null,
"dateTerminated" : null,
"image" : null,
"keywords" : null,
"videos" : [
async.parallel({
'alpha': function(callback) {
window.setTimeout(function() {
callback(null, 0);
}, 1000);
},
'beta': function(callback) {
window.setTimeout(function() {
callback(null, 1, 2);
});
@laser
laser / search.md
Last active August 29, 2015 14:22
API Search Functionality

MovieClips API, Search Functionality

Responsible for servicing mobile clients' search requests. Involves issuing HTTP request to the Search Service (for ids) and then to individual services (Video Service, Movie Service) for full objects.

Table of Contents

@laser
laser / search.md
Last active August 29, 2015 14:22
Search Service API

Search Service API

Wraps ElasticSearch in a Fandango (Express) service, exposing movie and video-searches. Allow for searching for videos and movies independent of a specific view context. Consumed by the MovieClips API.

Autocomplete (Videos)

Sample HTTP request/response (from MovieClips API):