Skip to content

Instantly share code, notes, and snippets.

View landon9720's full-sized avatar

Landon Kuhn landon9720

View GitHub Profile
def hi {
println("hello world")
}
scala> def sum(x: Int, y: Int) = x + y
sum: (x: Int, y: Int)Int
scala> def plus1 = sum(_: Int, 1)
plus1: (Int) => Int
scala> plus1(2)
res0: Int = 3
scala> def plus2 = sum(2, _: Int)
Welcome to Scala version 2.9.0.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_24).
Type in expressions to have them evaluated.
Type :help for more information.
scala> class A { println("A") }
defined class A
scala> class B extends A { println("B") }
defined class B
import Math._
// random number in range 1 - 5
def rnd5 = (floor(random * 5) + 1).toLong
// random bit
def rndbit: Long = {
val i = rnd5
if (i == 1 || i == 2) 0L
else if (i == 3 || i == 4) 1L
scala> class Test { object Obj }
defined class Test
scala> (new Test).Obj
res0: object Test#Obj = Test$Obj$@6e929b52
scala> (new Test).Obj
res1: object Test#Obj = Test$Obj$@46b44bc2
@landon9720
landon9720 / iterm2-colors
Created February 20, 2012 22:48
iterm2 colors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.11764705926179886</real>
<key>Green Component</key>
<real>0.11372549086809158</real>
@landon9720
landon9720 / .vimrc
Created February 28, 2012 20:43
.vimrc
set number
set incsearch
set hlsearch
syntax enable
:colorscheme evening
@landon9720
landon9720 / gist:2002273
Created March 8, 2012 17:38
HumanTime demo
scala> import com.eaio.util.text.HumanTime.{approximately => ht}
import com.eaio.util.text.HumanTime.{approximately=>ht}
scala> ht(0)
res0: java.lang.String = ""
scala> ht(1)
res1: java.lang.String = 1 ms
scala> ht(1000)
@landon9720
landon9720 / gist:2654845
Created May 10, 2012 18:15
anonymous class constructor
Map<String, String> map = new HashMap<String, String() {{
add("foo", "bar");
add("name", "landon");
}};
@landon9720
landon9720 / last.sh
Created June 14, 2012 21:07
the most recent file in the current directory is ...
#!/bin/bash
ls -lrt | awk '{ f=$NF }; END{ print f }'