Skip to content

Instantly share code, notes, and snippets.

Avatar

Colin Webb cjwebb

View GitHub Profile
@noelwelsh
noelwelsh / Example.scala
Created Feb 20, 2015
Robust Error Handling in Scala
View Example.scala
import scalaz.\/
import scalaz.syntax.either._
object Example2 {
// This example simulates error handling for a simple three tier web application
//
// The tiers are:
// - the HTTP service
// - a user authentication layer
// - a database layer
@bhauman
bhauman / core.cljs
Last active Jan 28, 2021
Helpful patterns when developing with ClojureScript Figwheel and Express js
View core.cljs
(ns todo-server.core
(:require
[cljs.nodejs :as nodejs]
[figwheel.client :as fw]))
(nodejs/enable-util-print!)
(defonce express (nodejs/require "express"))
(defonce serve-static (nodejs/require "serve-static"))
(defonce http (nodejs/require "http"))
@john2x
john2x / 00_destructuring.md
Last active Feb 27, 2021
Clojure Destructuring Tutorial and Cheat Sheet
View 00_destructuring.md

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

View reactjs.js
/** @jsx React.DOM */
/**
* Our component structure will look like the following:
* - WikiBox
* -- AutoCompleteBox
* --- AutoComplete
*/
// this component renders a single entity coming from wikipedia
View serviced
#!/bin/sh
#
# chkconfig: 2345 20 80
# description: java app daemon
#
DAEMON_PATH="/opt/APP_NAME/bin"
DAEMON='java -jar ../APP_NAME.jar'
DAEMONOPTS=""
@oxbowlakes
oxbowlakes / scala-interview2.scala
Created Mar 2, 2012
Scala interview questions hard
View scala-interview2.scala
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")
}
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created Sep 25, 2011
This is what I did to insert the CSRF token in backbone requests. This works with django.
View Backbone.sync_csrftoken.js
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
View 3nightclubs.scala
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._