Skip to content

Instantly share code, notes, and snippets.

@scan
scan / righter.scala
Created May 14, 2011 06:30
String Righter
#!/bin/sh
exec scala $0 $@
!#
def righter(str: String) = str.head + (str.slice(1,str.length-2).sorted) + std.last
args.foreach(s => print(righter(s) + " "))
@scan
scan / Matrix.scala
Created May 20, 2011 22:00
Scala Matrices
case class Matrix(_1: (Double, Double, Double, Double), _2: (Double, Double, Double, Double),
_3: (Double, Double, Double, Double), _4: (Double, Double, Double, Double)) extends Immutable {
def transpose = Matrix(
(_1._1, _2._1, _3._1, _4._1),
(_1._2, _2._2, _3._2, _4._2),
(_1._3, _2._3, _3._3, _4._3),
(_1._4, _2._4, _3._4, _4._4)
)
@scan
scan / Game.hs
Created June 5, 2011 11:03
Game Monad for GLFW
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Theorem.Core.Monad (
TheoremT, Theorem, MonadTheorem(..),
MonadIO(..),
runTheorem
) where
import Control.Monad (Monad)
import Control.Monad.RWS (RWST, MonadRWS)
import Control.Monad.Reader (ReaderT, MonadReader)
@scan
scan / gist:1029445
Created June 16, 2011 15:06 — forked from philcali/gist:1029230
Nicol project definition
// sbt 0.10 parent project definition
import sbt._
imoprt Keys._
object General {
val settings = Defaults.defaultSettings ++ Nicol.engineSettings ++ Seq (
organization := "com.github.scan",
version := "0.1.0.1",
@scan
scan / matrix.scala
Created October 1, 2011 21:23
4x4 matrix
case class Matrix(_1: (Float, Float, Float, Float),
_2: (Float, Float, Float, Float),
_3: (Float, Float, Float, Float),
_4: (Float, Float, Float, Float)) extends Immutable {
lazy val transpose = Matrix(
(_1._1, _2._1, _3._1, _4._1),
(_1._2, _2._2, _3._2, _4._2),
(_1._3, _2._3, _3._3, _4._3),
(_1._4, _2._4, _3._4, _4._4))
@scan
scan / toggle.coffee
Created October 14, 2011 12:40
A Toggle Button with jQuery
$ ->
$('.toggle, .pressed').each ->
$('<input>', { type: 'hidden', name: $(this).data('name'), value: 'on' }).appendTo($(this))
$('.toggle').click ->
$btn = $(this)
$btn.toggleClass 'pressed'
if $btn.is '.pressed'
$('<input>', { type: 'hidden', name: $btn.data('name'), value: 'on' }).appendTo($btn)
else
@scan
scan / toggle.coffee
Created October 14, 2011 12:46
Source of jQuery Toggle Button
$ ->
$('.toggle, .pressed').each ->
$('<input>', { type: 'hidden', name: $(this).data('name'), value: 'on' }).appendTo($(this))
$('.toggle').click ->
$btn = $(this)
$btn.toggleClass 'pressed'
if $btn.is '.pressed'
$('<input>', { type: 'hidden', name: $btn.data('name'), value: 'on' }).appendTo($btn)
else
@scan
scan / axiom.coffee
Created November 3, 2011 14:41
Bouncing Balls!
$ = jQuery
requestAnimFrame = window.requestAnimationFrame or window.mozRequestAnimationFrame or window.webkitRequestAnimationFrame or window.msRequestAnimationFrame or window.oRequestAnimationFrame or (callback) -> window.setTimeout(callback, 1000 / 60)
$.fn.axiom = (render) ->
$element = $ this
$canvas = $("<canvas width=\"#{$element.width()}\" height=\"#{$element.height()}\" />").appendTo(this)
screen = $canvas[0].getContext '2d'
@scan
scan / htaccess
Created December 14, 2011 14:16 — forked from dave1010/htaccess
HTTP Status Cats Apache (htaccess) config
# HTTP Status Cats
# Apache (htaccess) config created by @dave1010
# Licensed CC BY 2.0
# Images CC BY 2.0, from GirlieMac's photostream:
# http://www.flickr.com/photos/girliemac/sets/72157628409467125/with/6508023065/
# Usage: copy save this file as .htaccess or add it to your httpd.conf
ErrorDocument 404 '<a href="http://www.flickr.com/photos/girliemac/6508022985/" title="404 - Not Found by GirlieMac, on Flickr"><img src="http://farm8.staticflickr.com/7172/6508022985_b22200ced0.jpg" width="500" height="400" alt="404 - Not Found"></a>'
@scan
scan / build.sbt
Created December 18, 2011 10:19 — forked from aolshevskiy/build.sbt
xsbt-lift-basic
seq(WebPlugin.webSettings :_*)
scalaVersion := "2.8.1"
libraryDependencies ++= Seq(
"net.liftweb" %% "lift-webkit" % "2.3" % "compile",
"net.liftweb" %% "lift-mapper" % "2.3" % "compile",
"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty,test",
"ch.qos.logback" % "logback-classic" % "0.9.26",
"junit" % "junit" % "4.5" % "test",