Skip to content

Instantly share code, notes, and snippets.

View sbycrosz's full-sized avatar
💭
I may be slow to respond.

Sam Aryasa sbycrosz

💭
I may be slow to respond.
View GitHub Profile
#!/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;
// 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]]] =
// Implementation of Tree Traversal in Scala
package kata
trait Node {
def postorder: Stream[Node]
def inorder: Stream[Node]
def preorder: Stream[Node]
}
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)] = {
// ==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==
@sbycrosz
sbycrosz / GameOfLife.scala
Last active August 29, 2015 14:25
Game of Life
package kata
object GameOfLife {
type World = List[List[Int]]
type Position = (Int, Int)
val DEAD = 0
val ALIVE = 1
def run(world: World): World = {
@sbycrosz
sbycrosz / app.js
Created June 16, 2014 04:42
Local image placeholder service
// 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,