This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script for quickly change wallpaper when people leaves their mac unlocked | |
curl http://i64.tinypic.com/22amc9.jpg > 'wp.jpg' | |
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '${PWD}/wp.jpg'"; | |
killall Dock; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A solution for disjoint subset problem (P27) | |
// which is described in 99 Scala problem http://aperiodic.net/phil/scala/s-99/ | |
package kata | |
object Kata { | |
def group3(names: Set[String]): List[List[Set[String]]] = | |
group(List(2, 3, 4), names) | |
def group(groupSizes: List[Int], names: Set[String]): List[List[Set[String]]] = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implementation of Tree Traversal in Scala | |
package kata | |
trait Node { | |
def postorder: Stream[Node] | |
def inorder: Stream[Node] | |
def preorder: Stream[Node] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Point(x: Double, y: Double) | |
def distance(pair: Option[(Point, Point)]): Double = { | |
pair match { | |
case None => Double.MaxValue | |
case Some((p1, p2)) => Math.sqrt( Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2) ) | |
} | |
} | |
def closestPair(points: List[Point]): Option[(Point, Point)] = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Leave Balance Calculator | |
// @namespace | |
// @version 0.0.1 | |
// @description | |
// @author Sam | |
// @match https://na32.salesforce.com/a1W?rlid=00N50000002ejrH&id=a0y50000000onx0 | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package kata | |
object GameOfLife { | |
type World = List[List[Int]] | |
type Position = (Int, Int) | |
val DEAD = 0 | |
val ALIVE = 1 | |
def run(world: World): World = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Local image placeholder service | |
// Usage: <img src="http://localhost:9999/300/400" /> | |
var express = require('express'), | |
app = express(), | |
gm = require('gm'); | |
app.get('/:width/:height', function(request, response){ | |
var width = request.params.width, | |
height = request.params.height, |
NewerOlder