Skip to content

Instantly share code, notes, and snippets.

View davegurnell's full-sized avatar
🐱

Dave Pereira-Gurnell davegurnell

🐱
View GitHub Profile
@davegurnell
davegurnell / placeholder.js
Created March 28, 2010 17:13
Text field placeholders with jQuery.
/* Text field placeholders
*
* Dave Gurnell, http://www.untyped.com
*
* Example usage: $("#my-date-field").placeholder("yyyy-mm-dd");
*/
(function ($) {
// -> Boolean
$.fn.hasPlaceholder = function () {
@davegurnell
davegurnell / ios-scroll.js
Created January 23, 2011 11:16
iOS HTML5 Scrollpane
/* iOS scrollpane jQuery plugin, v1.0
* ==================================
*
* (c) 2011 Dave Gurnell
* http://boxandarrow.com
*
* Distributed under the Creative Commons Attribution 3.0 Unported licence:
* http://creativecommons.org/licenses/by/3.0/
*/
@davegurnell
davegurnell / ColorParser.scala
Created October 13, 2011 14:29
Simple parser for CSS color literals, based on Scala parser combinators
/*
* Copyright (c) 2011 Untyped Ltd, http://untyped.com
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@davegurnell
davegurnell / Build.scala
Created June 13, 2012 07:50
Using the Untyped JS/Less plugins with Play 2.0 (sample SBT configuration)
import sbt._
import Keys._
import PlayProject._
import com.untyped.sbtjs.Plugin._
import com.untyped.sbtless.Plugin._
/* Example build config to use the Untyped JS/Less/Coffeescript plugins:
*
* http://github.com/untyped/sbt-plugins
@davegurnell
davegurnell / .latexmkrc
Created July 11, 2012 19:31
Sample latexmk file to provide continuous compilation and preview with MacTex on OS X
# Sample latexmk configuration to use xelatex and Preview on OS X.
# Should help if you want to use latexmk with MacTeX.
#
# 1. Install MacTeX
# 2. Put this file in ~/.latexmkrc
# 3. Continuously recompile and preview your document with the command:
# latexmk -pvc myfile.tex
$pdflatex = 'xelatex -interaction=nonstopmode %O %S';
$pdf_previewer = 'open -a Preview "%S"';
@davegurnell
davegurnell / GLTest.java
Created July 15, 2012 09:28
LWJGL OpenGL version test case
import org.lwjgl.*;
import org.lwjgl.opengl.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.GL20.*;
import static org.lwjgl.opengl.GL30.*;
import static org.lwjgl.util.glu.GLU.*;
import static org.lwjgl.BufferUtils.*;
public class GLTest {
@davegurnell
davegurnell / gist:3246361
Created August 3, 2012 09:50
Sublime Text 2 keybinding for "reveal in sidebar"
[
{ "keys": ["super+shift+r"], "command": "reveal_in_side_bar"}
]
@davegurnell
davegurnell / compiler.scala
Last active December 14, 2015 22:59
Rough idea for an update to the Untyped sbt-js and sbt-less plugins: create a single asset compiler plugin that allows flexible creation of compiler functions.
// TODO: This code doesn't distinguish between "main" files for which we want to generate outputs,
// and "library" files that are used in compilation but don't generate outputs.
case class SourceLocation(val rel: File, val relTo: File, val abs: File)
// Compilation may take several steps (Coffeescript => CommonJS => Concat => Uglifyjs etc).
// Sources are cached on disk after each step, allowing us to check timestamps to avoid
// unnecessary recompilation. Compiler steps accept one or more Sources as an argument and
// emit one or more Sources as outputs. Each Source knows where the original source file is
// located, where the target file is going to end up, and where the content is cached at the
@davegurnell
davegurnell / validation.scala
Created May 28, 2014 15:03
Simple example of a functional data validation using combinators
import scala.util.{ Try, Success, Failure }
case class ValidationError(field: Seq[String], message: String) {
def prefix(name: String) = this.copy(field = name +: field)
}
def validator[A](func: A => Seq[ValidationError]): Validator[A] =
new Validator[A] {
def apply(value: A) = func(value)
}
@davegurnell
davegurnell / noisyactors.scala
Created May 28, 2014 15:05
Sample code: dispatching jobs to actors and retrieving the results as futures
import akka.actor._
import akka.pattern.ask
import akka.routing._
import akka.util.Timeout
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
object Speaker {
case class EventuallySay(phrase: String)