Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>{Title}{block:PostTitle} - {PostTitle}{/block:PostTitle}</title>
<link rel="icon" href="{Favicon}"/>
<link rel="alternate" type="application/rss+xml" title="RSS" href="{RSS}"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=775"/>
<!-- DEFAULT COLORS -->
@gkojax
gkojax / prestigeSampleDownloader
Created April 26, 2012 01:37
prestigeSampleDownloaderで型番が3文字でない場合にリンクが取得できない件
// ==UserScript==
// @id prestigeSampleDownloader
// @name prestigeSampleDownloader
// @include http://www.prestige-av.com/*
// @author phorbidden
// @version 1.00
// ==/UserScript==
(function() {
@gkojax
gkojax / gist:2730047
Created May 19, 2012 08:15
2012/05/19 Finagleハッカソン
package com.twitter.finagle.example.http
import java.net.InetSocketAddress
import com.twitter.finagle.{Service, SimpleFilter}
import com.twitter.util.Future
import com.twitter.finagle.http.path._
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.http._
import com.twitter.finagle.builder.ClientBuilder
@gkojax
gkojax / build.sbt
Created June 8, 2012 04:37 — forked from kmizu/build.sbt
Code snippet of build.sbt for Finagle 4.0.2 in Scala 2.9.1
resolvers += "twitter-repo" at "http://maven.twttr.com"
libraryDependencies ++= Seq(
"com.twitter" % "finagle-core_2.9.1" % "4.0.2",
"com.twitter" % "finagle-http_2.9.1" % "4.0.2",
"com.twitter" % "finagle-stream_2.9.1" % "4.0.2"
)
@gkojax
gkojax / gist:2943264
Created June 17, 2012 03:02
mongoからcollection.findで取ってきたデータはtoListしないとListにならないのわかってなかった
package jp.ddo.loveless
import com.mongodb.casbah.Imports._
import net.liftweb.json._
object CasbahSample extends App {
val collection = MongoConnection("servername")("tumblr")("reblogdata")
val condition = MongoDBObject("count"->221)
case class Data(rk:String, count:Int)
@gkojax
gkojax / gist:3007063
Created June 27, 2012 21:46
FinagleのhttpのParamMatcher使ってみた。
class Respond extends Service[Request, Response] {
def apply(request: Request) = {
object KI extends IntParamMatcher("k")
object K extends ParamMatcher("k")
val text = (Path(request.path) :? request.params) match {
case Root / "name" / name :? KI(k) =>
"Hello, %s i %s!".format(name, k)
case Root / "name" / name :? K(k) =>
"Hello, %s %s!".format(name, k)
@gkojax
gkojax / Finagle.scala
Created July 1, 2012 03:48
Finagleのhttpサーバーをcommons-daemonでデーモン化した
package org.example
import java.io.File
import java.util.concurrent.TimeUnit
import java.net.InetSocketAddress
import com.twitter.finagle.{Service, SimpleFilter}
import com.twitter.util.{Future, Duration}
import com.twitter.finagle.http.path._
import com.twitter.finagle.builder.{Server, ServerBuilder}
import com.twitter.finagle.http._
@gkojax
gkojax / 1.scala
Created July 8, 2012 01:47
ランダムな数値のリスト
List(Random.nextInt(size), Random.nextInt(size), Random.nextInt(size))
// はもうちょっとかっこよくかける気がする。
@gkojax
gkojax / 1.scala
Created July 11, 2012 14:21
メソッドの末尾に _ を付けると関数オブジェクトになる。
val addUmm: String => String = _ + " umm"
val addAhem: String => String = _ + " ahem"
val ummThenAhem = addAhem.compose(addUmm)
def addUmm2(x: String) = x + " umm"
def addAhem2(x: String) = x + " ahem"
val ummThenAhem2 = (addAhem2 _).compose(addUmm2 _)
import com.twitter.sbt._
organization := "com.example"
name := "Finagle Http Project"
version := "0.1.0"
scalaVersion := "2.9.2"