Skip to content

Instantly share code, notes, and snippets.

@oker1
oker1 / json.scala
Last active December 11, 2015 09:48
sealed abstract class JValue {
override def toString: String = {
this match {
case JString(value) => String.format("\"%s\"", value)
case JBool(true) => "true"
case JBool(false) => "false"
case JNumber(value) => value.toString
case JNull() => "null"
case JList(values) => "[" ++ values.map(_.toString).mkString(", ") ++ "]"
case JObject(values) => "{" ++ values.foldLeft("") { case (prefix, (key, value)) => prefix ++ String.format("\"%s\": %s", key, value) } ++ "}"
@oker1
oker1 / RomanNumbersTest.scala
Created February 20, 2013 20:38
roman numerals kata
import org.scalatest._
class RomanNumbersTest extends FlatSpec with ShouldMatchers with BeforeAndAfterEach {
private var numbers: RomanNumbers = _
override def beforeEach() {
numbers = new RomanNumbers
}
"Roman numbers" should "convert I to 1" in {
find src -name '*.php' -print0 | xargs -0 -I{} gsed -i 's/\(.*\)?>/\1/' '{}'
@oker1
oker1 / post-checkout
Last active December 21, 2015 01:49 — forked from lyrixx/post-checkout
#!/bin/bash
# Put this file at: .git/hooks/post-checkout
# and make it executable
# You can install it system wide too, see http://stackoverflow.com/a/2293578/685587
PREV_COMMIT=$1
POST_COMMIT=$2
NOCOLOR="\x1B[0m"
@oker1
oker1 / gist:6864060
Created October 7, 2013 07:57
go crosscompile linux/amd64
hg clone -u release https://code.google.com/p/go
cd go/src
./all.bash
export GOROOT=$HOME/go
export PATH=$GOROOT/bin:$PATH
cd $GOROOT/src
GOOS=linux GOARCH=amd64 ./make.bash --no-clean 2>&1
@oker1
oker1 / jenkins-slave
Last active December 25, 2015 16:09 — forked from bols-blue/jenkins-slave
# defaults for jenkins continuous integration server
SLAVE_NAME=slave1
JENKINS_ARGS="-jnlpUrl http://test.lnc.jp:8080/computer/$SLAVE_NAME/slave-agent.jnlp"
# jenkins home location
JENKINS_HOME=/opt/jenkins-slave
# location of the jenkins war file
JENKINS_WAR=$JENKINS_HOME/slave.jar
Stream.continually(input.readLine())
.takeWhile(_ != null)
.map(_.split(",", 2))
.map { case Array(x, y) => (new java.util.Date(java.lang.Long.parseLong(x) * 1000), y) }
==> Downloading https://github.com/facebook/hhvm/archive/HHVM-2.4.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/hhvm-2.4.0.tar.gz
==> Verifying hhvm-2.4.0.tar.gz checksum
tar xf /Library/Caches/Homebrew/hhvm-2.4.0.tar.gz
==> rm -rf hphp/submodules/folly
==> ln -s /opt/homebrew/opt/folly hphp/submodules/folly
==> cmake . -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/gcc48/bin/g++-4.8 -DCMAKE_C_COMPILER=/opt/homebrew/opt/gcc48/bin/gcc-4.8 -DCMAKE_ASM_COMPILER=/opt/homebrew/opt/gcc48/bin/gcc-4.8 -DBINUTIL_LIB=/opt/homebrew/opt/gcc48/lib/x86_64/libiberty-4.8.a -DLIBIBERTY_LIB=/opt/homebrew/opt/gcc48/lib/x86_64/libiberty-4.8.a -DCMAKE_INCLUDE_PATH="/usr/local/include:/usr/include" -DCMAKE_LIBRARY_PATH="/usr/local/lib:/usr/lib" -DLIBEVENT_LIB=/opt/homebrew/opt/libeventfb/lib/libevent.dylib -DLIBEVENT_INCLUDE_DIR=/opt/homebrew/opt/libeventfb/include -DICU_INCLUDE_DIR=/opt/homebrew/opt/icu4c/include -DICU_LIBRARY=/opt/homebrew/opt/icu4c/lib/libicuuc.dylib -DICU_I18N_LIBRARY=/opt/homebrew/opt/icu4c/lib/libicui18n.dyl
@oker1
oker1 / gist:8919826
Created February 10, 2014 16:57
vagrant-lxc log
Vagrant up:
Mon 10 Feb 2014 08:47:26 AM PST
Shell provisioner:
Mon 10 Feb 2014 08:47:45 AM PST
Chef log:
[Mon, 10 Feb 2014 16:47:51 +0000] INFO: *** Chef 10.18.2 ***
... error
@oker1
oker1 / gist:9048014
Created February 17, 2014 10:12
homebrew-hhvm
> $ brew install -v hhvm [±master]
==> Downloading https://github.com/facebook/hhvm/archive/HHVM-2.4.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/hhvm-2.4.0.tar.gz
==> Verifying hhvm-2.4.0.tar.gz checksum
tar xf /Library/Caches/Homebrew/hhvm-2.4.0.tar.gz
==> rm -rf hphp/submodules/folly
==> ln -s /opt/homebrew/opt/folly hphp/submodules/folly
==> cmake . -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/gcc48/bin/g++-4.8 -DCMAKE_C_COMPILER=/opt/homebrew/opt/gcc48/bin/gcc-4.8 -DCMAKE_ASM_COMPILER=/opt/homebrew/opt/gcc48/bin/gcc-4.8 -DBINUTIL_LIB=/opt/homebrew/opt/gcc48/lib/x86_64/libiberty-4.8.a -DLIBIBERTY_LIB=/opt/homebrew/opt/gcc48/lib/x86_64/libiberty-4.8.a -DCMAKE_INCLUDE_PATH="/opt/homebrew/include:/usr/include" -DCMAKE_LIBRARY_PATH="/opt/homebrew/lib:/usr/lib" -DLIBEVENT_LIB=/opt/homebrew/opt/libeventfb/lib/libevent.dylib -DLIBEVENT_INCLUDE_DIR=/opt/homebrew/opt/libeventfb/include -DICU_INCLUDE_DIR=/opt/home