build.sbt って、かならず settingの値 じゃないといけないから、
val UnfilteredVersion = "0.5.0"っていう行を定義できないけれど、こんな風 ↓ に書けば DRY に書けるね!っていう、超細かいどーでもいいテクニック !
Some("net.databinder","0.5.0").map{case (a,v) =>| var global = this; | |
| global.__defineGetter__("self", function _() { | |
| return _.caller || global; | |
| }); | |
| function foo() { | |
| alert(self); | |
| } |
| // $ 6g echo.go && 6l -o echo echo.6 | |
| // $ ./echo | |
| // | |
| // ~ in another terminal ~ | |
| // | |
| // $ nc localhost 3540 | |
| package main | |
| import ( |
| def new_user(admin_username, admin_password): | |
| env.user = 'root' | |
| # Create the admin group and add it to the sudoers file | |
| admin_group = 'admin' | |
| runcmd('addgroup {group}'.format(group=admin_group)) | |
| runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format( | |
| group=admin_group)) | |
| # Create the new admin user (default group=username); add to admin group |
| import play.db.anorm._ | |
| import play.db.anorm.defaults._ | |
| trait Identifiable[A] { | |
| type ID = A | |
| val id: Pk[ID] | |
| } | |
| trait ExMagic[A <: Identifiable[_]] extends Magic[A] { | |
| opt <- options(warn=-1) | |
| ## ------------------------------------------------------------ | |
| ## Test | |
| ## ------------------------------------------------------------ | |
| ## > rm(list=ls()); source("Eval.R") | |
| ## > repl() | |
| ## rlisp > (<- make.counter (function (c) (function () (<<- c (+ c 1))))) |
build.sbt って、かならず settingの値 じゃないといけないから、
val UnfilteredVersion = "0.5.0"っていう行を定義できないけれど、こんな風 ↓ に書けば DRY に書けるね!っていう、超細かいどーでもいいテクニック !
Some("net.databinder","0.5.0").map{case (a,v) =>| //To compile this, "-P:continuations:enable" option is needed. | |
| import scala.util.continuations._ | |
| import scala.collection._ | |
| object Generator { | |
| abstract sealed class Computation[+A] | |
| case class Yielded[A](k: Unit => Computation[A], v: A) extends Computation[A] | |
| case object Done extends Computation[Nothing] | |
| type yieldable[A] = cps[Computation[A]] |
| (* ocamlfind c -w A -linkpkg -package lwt,lwt.unix,lwt.syntax -syntax camlp4o,lwt.syntax myecho.ml -o myecho *) | |
| (* This code refers to https://github.com/avsm/ocaml-cohttpserver/blob/master/server/http_tcp_server.ml *) | |
| open Lwt | |
| let server_port = 12345 | |
| let so_timeout = Some 20 | |
| let backlog = 10 | |
| let try_close chan = | |
| catch (fun () -> Lwt_io.close chan) |
| # Basics of Elliptic Curve Cryptography implementation on Python | |
| import collections | |
| def inv(n, q): | |
| """div on PN modulo a/b mod q as a * inv(b, q) mod q | |
| >>> assert n * inv(n, q) % q == 1 | |
| """ | |
| for i in range(q): | |
| if (n * i) % q == 1: |
| scalaVersion := "2.9.1" | |
| resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/releases" | |
| libraryDependencies ++= Seq( | |
| "play" %% "anorm" % "2.0-RC4", | |
| "com.github.seratch" %% "scalikejdbc" % "[0.5,)", | |
| "org.hsqldb" % "hsqldb" % "[2,)" | |
| ) |