Skip to content

Instantly share code, notes, and snippets.

View seratch's full-sized avatar

Kazuhiro Sera seratch

View GitHub Profile
@seratch
seratch / find_scct.sh
Created July 13, 2013 00:41
Finding scct dependency in Compile
BASE_URL=https://oss.sonatype.org/content/repositories/releases/com/github/seratch
VERSION=1.6.5
for SCALA_VERSION in 2.9.1 2.9.2 2.9.3 2.10
do
for NAME in scalikejdbc scalikejdbc-interpolation-core scalikejdbc-interpolation-macro scalikejdbc-interpolation scalikejdbc-config scalikejdbc-test scalikejdbc-mapper-generator-core scalikejdbc-mapper-generator scalikejdbc-play-plugin scalikejdbc-play-fixture-plugin
do
URL=${BASE_URL}/${NAME}_${SCALA_VERSION}/${VERSION}/${NAME}_${SCALA_VERSION}-${VERSION}.pom
echo ${URL}
curl --silent ${URL} | grep -3 scct
done
import java.util.UUID
import org.joda.time.DateTime
import java.sql.SQLException
import scala.Option
import scalikejdbc.SQLInterpolation.SQLSyntaxSupport
import util.control.Exception._
import java.sql.Connection
import scalikejdbc._
import scalikejdbc.SQLInterpolation._
@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)))

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 / 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
@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 / 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.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 / 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 / config.yml
Created October 25, 2012 09:37
AWS SQS Example
access_key_id: xxx
secret_access_key: yyy