Skip to content

Instantly share code, notes, and snippets.

View tototoshi's full-sized avatar

Toshiyuki Takahashi tototoshi

View GitHub Profile
def index(id:String) = Action {
getFirstData(id)
}
private def getFirstData(id:String) = {
Cache.get(id) match {
case Some(id2) => getSecondData(id2)
case None => NotFound
}
}
private def getSecondData(id2:String) = {
@narcisobenigno
narcisobenigno / WebAppWithJetty.scala
Created August 5, 2012 03:47
SBT configs to use Jetty 8.1.x
import sbt._
import Keys._
import com.github.siasia._
import WebPlugin._
import WebappPlugin._
import PluginKeys._
object WebAppWithJetty extends Build {
lazy val root = Project(
fizz = function f() {
fizz = function () {
fizz = function () {
fizz = f
return "Fizz"
}
}
}
buzz = function f() {
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@lyricallogical
lyricallogical / rpscala88
Created September 26, 2012 09:50
rpscala88
!SLIDE
Play 2.0 の Action と BodyParser について学ぼう
----------------
!SLIDE
自己紹介
----------------
* 望月 慎也
* @lyrical_logical
* 株式会社レピダム
@drexin
drexin / Macros.scala
Last active October 27, 2016 09:41
macros to get current file and line, inspired by ruby's __FILE__ and __LINE__
import java.io.File
import language.experimental.macros
import scala.reflect.macros.Context
object Macros {
def LINE: Int = macro lineImpl
def lineImpl(c: Context): c.Expr[Int] = {
import c.universe._
@gakuzzzz
gakuzzzz / gist:5632577
Last active December 17, 2015 15:29
色んなSQLをScalikeJDBCで書くと?
@cb372
cb372 / x-in-xs.txt
Last active December 18, 2015 16:39
Python-style "x in xs" testing in Scala using implicit conversion and duck typing. Sinful but convenient.
scala> implicit class WithInMethod(obj: Any) {
| def in(a: {def contains(e: Any): Boolean}): Boolean = a.contains(obj)
| }
warning: there were 1 feature warnings; re-run with -feature for details
defined class WithInMethod
scala> "foo" in List("1", "2")
res3: Boolean = false
scala> "foo" in List("foo", "bar")
@cb372
cb372 / pom-vbump.py
Last active November 1, 2019 10:07
Version-bump script for Maven projects. Reads pom.xml, parses the version, increments it and either updates pom.xml or writes an updated pom to stdout.
#! /usr/bin/env python
#
# coding: utf-8
"""
Version-bump script for Maven projects.
Reads pom.xml, parses the version, increments it and writes an updated pom to stdout.
Usage:
pom-vbump.py [-i] [-v <new version number>] [path to pom.xml]
@mtgto
mtgto / proxy.rb
Created September 25, 2013 03:02
対sbt用proxy (ruby製。typoあり)
require 'socket'
require 'net/http'
require 'uri'
class Proxy
PORT = 8888
def initialize
@server_socket = TCPServer.open(nil, PORT)
@responses = {}