Skip to content

Instantly share code, notes, and snippets.

View seratch's full-sized avatar

Kazuhiro Sera seratch

View GitHub Profile
@seratch
seratch / ideas.md
Created October 18, 2012 12:27
Ideas for developer contest
  • Play の WebSocket で何か
  • Akka を使った何か
  • ディスク IO に関した何か
  • Play scaffold sbt plugin
  • DSL をつくる?
  • giter8 で何か
  • Play の javascriptRouter
  • クローラシステム
  • Node.js のサンプルを移植
  • AWS と連携
@seratch
seratch / prettyprint.scala
Created October 22, 2012 10:39
XML PrettyPrinter in Scala
import scala.xml._
val xml: Elem = XML.load("./input.xml")
val formatted: String = new PrettyPrinter(80, 2).format(xml)
@seratch
seratch / config.yml
Created October 25, 2012 09:37
AWS SQS Example
access_key_id: xxx
secret_access_key: yyy
@seratch
seratch / sinatra_on_eb_example.sh
Created November 8, 2012 09:38
Deploying a Sinatra Application to AWS Elastic Beanstalk
# http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_sinatra.html
wget https://s3.amazonaws.com/elasticbeanstalk/cli/AWS-ElasticBeanstalk-CLI-2.2.zip
unzip AWS-ElasticBeanstalk-CLI-2.2.zip
mkdir eb_ruby
cd eb_ruby
echo "require './helloworld'
run Sinatra::Application" > config.ru
@seratch
seratch / Build.scala
Created November 26, 2012 22:48
Using ScalikeJDBC on Play 2.1-RC1
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "sample"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
@seratch
seratch / build.gradle
Created December 8, 2012 05:41
Tweet from Gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.twitter4j', name: 'twitter4j-core', version: '3.0.2'
}
}
import twitter4j.*
@seratch
seratch / build.gradle
Created December 8, 2012 06:21 — forked from yusuke/build.gradle
Tweet from Gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'org.twitter4j', name: 'twitter4j-core', version: '3.0.2'
}
}
import twitter4j.*
@seratch
seratch / 1_preparing_data.scala
Last active June 28, 2022 07:55
ScalikeJDBC powerful SQLSyntaxSupport example
import scalikejdbc._
import scalikejdbc.SQLInterpolation._
// load settings
Class.forName("org.hsqldb.jdbc.JDBCDriver")
ConnectionPool.singleton("jdbc:hsqldb:mem:test", "", "")
GlobalSettings.loggingSQLAndTime = LoggingSQLAndTimeSettings(enabled = true, logLevel = 'info)
implicit val session = AutoSession

Schema

CREATE TABLE users (
    id    INTEGER       PRIMARY KEY,
    name  VARCHAR(256)  NOT NULL
)
CREATE TABLE groups (
    id    INTEGER       PRIMARY KEY,
 name VARCHAR(256) NOT NULL
@seratch
seratch / ExampleMacros.scala
Last active December 15, 2015 12:49
"Type-safe" Dynamic implemenatation in Scala 2.10
package foo
import scala.language.experimental.macros
import scala.reflect.macros._
object ExampleMacros {
def selectDynamicImpl(c: Context)(name: c.Expr[String]): c.Expr[String] = {
import c.universe._
val _name: String = c.eval(c.Expr[String](c.resetAllAttrs(name.tree.duplicate)))