This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalaquery._ | |
import ql._ | |
import basic.{BasicTable => Table, _} | |
import BasicDriver.Implicit._ | |
import session.{ Session, Database } | |
/* | |
scala_query_example=> select * from Coffees; | |
id | name | supid | price | |
----+-----------------+-------+------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.DynamicVariable | |
object Main extends App { | |
val dyn = new DynamicVariable[Int](0) | |
println(dyn.value) | |
dyn.withValue(100) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import org.scalaquery.session.Database | |
import org.scalaquery.session.Database | |
scala> import org.scalaquery.session.Database.threadLocalSession | |
import org.scalaquery.session.Database.threadLocalSession | |
scala> import org.scalaquery.simple.StaticQuery._ | |
import org.scalaquery.simple.StaticQuery._ | |
scala> val db = Database.forURL("jdbc:postgresql:scala_query_example", driver="org.postgresql.Driver", user="user", password="password") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalaquery.session.Database | |
scala> import org.scalaquery.session.Database | |
import org.scalaquery.session.Database | |
scala> import org.scalaquery.session.Database.threadLocalSession | |
import org.scalaquery.session.Database.threadLocalSession | |
scala> import org.scalaquery.simple.StaticQuery._ | |
import org.scalaquery.simple.StaticQuery._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.util.control.Exception._ | |
class ServerIsDownException extends Exception | |
object A extends App { | |
val remoteCalculatorService = new AnyRef { | |
def add(a: Int, b: Int): Int = { | |
a + b match { | |
case odd if odd % 2 == 1 => odd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitter4j._ | |
import conf._ | |
/* build.sbt | |
scalaVersion := "2.9.1" | |
libraryDependencies ++= Seq( | |
"org.twitter4j" % "twitter4j-core" % "2.2.5", | |
"org.twitter4j" % "twitter4j-stream" % "2.2.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def repeat(n: Int)(f: => Unit) { | |
for (i <- 0 until n) { | |
f | |
} | |
} | |
repeat(3){ | |
println("Hello") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar my-py-docs-python-org-url "http://docs.python.org") | |
(defun my-py-search-documentation-interactive (word) | |
(interactive "sSEARCH: ") | |
(my-py-search-documentation word)) | |
(defun my-py-search-documentation-at-point () | |
(interactive) | |
(let ((word (current-word))) | |
(when word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void((function () { | |
var url = location.href; | |
var ja = url.search(/hl=ja/); | |
var en = url.search(/hl=en/); | |
if (url.search(/google\.(co\.jp|com)\/search/) < 0) return; | |
if (ja > 0) { | |
location.href = url.replace(/hl=ja/, "hl=en"); | |
} else if (en > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
import subprocess | |
def do_sed(fullpath, old, new): | |
sed_script = "s/%s/%s/g" % (old, new) | |
command = ["sed", "-i", fullpath, "-e", sed_script] |