Skip to content

Instantly share code, notes, and snippets.

@travitch
travitch / NotificationDaemon.hs
Created September 12, 2012 14:37
A freedesktop notification plugin for xmobar
{-# LANGUAGE OverloadedStrings, RankNTypes, KindSignatures, FlexibleContexts #-}
module Plugins.NotificationDaemon where
-- xmobar plugin API
import Plugins
import DBus.Bus
import DBus.Client
import DBus.Constants
@eberle1080
eberle1080 / dirwatcher.scala
Created September 26, 2011 00:43
Recursive directory watcher in Scala
/**
* dirwatcher.scala
*
* Uses the Java 7 WatchEvent filesystem API from within Scala.
* Adapted from:
* http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
*
* @author Chris Eberle <eberle1080@gmail.com>
* @version 0.1
*/
@knowtheory
knowtheory / prettyprint.js
Created April 11, 2011 05:44
A pretty printer for Javascript objects that looks like Ruby's pp formatter. In use on Rhino, untested elsewhere.
function pp(object, depth, embedded) {
typeof(depth) == "number" || (depth = 0)
typeof(embedded) == "boolean" || (embedded = false)
var newline = false
var spacer = function(depth) { var spaces = ""; for (var i=0;i<depth;i++) { spaces += " "}; return spaces }
var pretty = ""
if ( typeof(object) == "undefined" ) { pretty += "undefined" }
else if ( typeof(object) == "boolean" ||
typeof(object) == "number" ) { pretty += object.toString() }
else if ( typeof(object) == "string" ) { pretty += "\"" + object + "\"" }