Skip to content

Instantly share code, notes, and snippets.

View hallettj's full-sized avatar

Jesse Hallett hallettj

View GitHub Profile
2013-09-16 07:21:40,143 INFO com.buddycloud.mediaserver.Main - buddycloud Media Server HTTP server started!
2013-09-16 07:21:41,481 ERROR com.buddycloud.mediaserver.Main - Media Server XMPP Component could not be started.
org.xmpp.component.ComponentException: java.io.EOFException: input contained no data
at org.jivesoftware.whack.ExternalComponent.connect(ExternalComponent.java:267) ~[whack.jar:na]
at org.jivesoftware.whack.ExternalComponentManager.addComponent(ExternalComponentManager.java:211) ~[whack.jar:na]
at org.jivesoftware.whack.ExternalComponentManager.addComponent(ExternalComponentManager.java:191) ~[whack.jar:na]
at com.buddycloud.mediaserver.Main.createXMPPComponent(Main.java:138) ~[buddycloud-media-server-0.1.jar:na]
at com.buddycloud.mediaserver.Main.startXMPPToolBox(Main.java:105) ~[buddycloud-media-server-0.1.jar:na]
at com.buddycloud.mediaserver.Main.main(Main.java:51) ~[buddycloud-media-server-0.1.jar:na]
Caused by: java.io.EOFException: in
@hallettj
hallettj / mori.markdown
Created September 10, 2013 23:26
Slides from my presentation on Mori, a library that makes data structures from the ClojureScript standard library available to plain JavaScript apps.
@hallettj
hallettj / for.sibilant
Created July 29, 2013 01:22
Demonstration of a monad comprehension macro in Sibilant, a Lisp dialect that compiles to JavaScript. See http://sibilantjs.info/ for information on Sibilant.
; A monad comprehension is a syntactic construct that translates
; synchronous-looking code into a callback-based implementation. Monads
; are a very general abstraction - which means that monad comprehensions
; have more expressive power than other sync-to-async code
; transformations.
; Here is an example that uses jQuery's $.get method to fetch resources:
(def post-with-author (id)
(for
@hallettj
hallettj / acorn.js
Created May 27, 2013 23:57
Defining a module in a way that will work in several different environments. This is from Acorn <https://github.com/marijnh/acorn.git>, a JavaScript parser.
(function(mod) {
if (typeof exports == "object" && typeof module == "object") return mod(exports); // CommonJS
if (typeof define == "function" && define.amd) return define(["exports"], mod); // AMD
mod(self.acorn || (self.acorn = {})); // Plain browser env
})(function(exports) {
"use strict";
exports.version = "0.2.0";
/* ... */
@hallettj
hallettj / state-example-game.js
Created November 9, 2012 04:41
Implementation of a State monad in JavaScript
/*
* Example of a state monad in use. This is adapted from an example on
* the Haskell Wiki:
* http://www.haskell.org/haskellwiki/State_Monad#Complete_and_Concrete_Example_1
*/
require(['state', 'qunit'], function(state, qunit) {
/*
* playGame() is a recursive function that given an array of moves
* defines an algorithm for constructing a final game score. Along
@hallettj
hallettj / base36.hs
Created August 25, 2012 21:56
Haskell library to convert unsigned integers to and from base36 representations
-- Converts unsigned integers to and from base36 representations
module Numeric.Base36 (
readBase36
, showBase36
) where
import Data.Char (isAscii, isLetter, isDigit, ord, chr, toLower)
import Numeric (readInt, showIntAtBase)
@hallettj
hallettj / jquery.flatmap.js
Created August 1, 2012 02:08
$.flatMap, generalizes running asynchronous operations in sequence
$.flatMap = function(promise, f) {
var deferred = $.Deferred();
function reject(/* arguments */) {
// The reject() method puts a deferred into its failure
// state.
deferred.reject.apply(deferred, arguments);
}
promise.then(function(/* values... */) {
@hallettj
hallettj / iframe-memory-leak-prevention.html
Created July 16, 2012 23:28
iFrame memory leak prevention test
<!doctype html>
<html>
<head>
<title>iFrame memory leak prevention test</title>
</head>
<body>
<h1>iFrame memory leak prevention test (void)</h1>
<p>In IE up through version 8 adding an iframe to a page and
removing it produces a memory leak in some cases. The pattern
@hallettj
hallettj / prototype_puzzle.js
Created May 22, 2012 20:56
Prototype Puzzle
function f() {}
f.prototype = { i: 10 };
var i = new f();
f.prototype = { j: 11 };
var j = new f();
equal(i.i, ?);
equal(i.j, ?);
equal(j.i, ?);
@hallettj
hallettj / xmonad.hs
Created March 6, 2012 19:45
XMonad configuration for a left-handed Tall layout
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}
-- FlexibleInstances and MultiParamTypeClasses are necessary for the
-- LayoutClass instance declaration of Flip.
-- I use two monitors. The default tiled layout in XMonad, Tall, puts
-- the master window on the left side of the screen. That feels right
-- for my right screen. But for my left screen I would prefer the
-- master window to be on the right side of the screen because that side