CREATE TABLE users (
id INTEGER PRIMARY KEY,
name VARCHAR(256) NOT NULL
)
CREATE TABLE groups (
id INTEGER PRIMARY KEY,
name VARCHAR(256) NOT NULL
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 lombok.experimental.ExtensionMethod; | |
// @ExtensionMethod({ String.class }) // Compile Error. | |
@ExtensionMethod({ Extensions.class }) | |
public class Main { | |
public static void main(String[] args) { | |
System.out.println("Hello, %s".format("World.")); // => "Hello, World." | |
} | |
} |
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
trait ApiInjector { | |
var twitter : TwitterApi = new TwitterApiImpl; | |
//他にもいろいろなサービス | |
} |
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
bcx david$ rake stats | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Controllers | 3704 | 2942 | 72 | 479 | 6 | 4 | | |
| Helpers | 1901 | 1529 | 13 | 261 | 20 | 3 | | |
| Models | 5310 | 4116 | 50 | 653 | 13 | 4 | | |
| Libraries | 2167 | 1593 | 51 | 200 | 3 | 5 | | |
| Integration tests | 297 | 217 | 6 | 1 | 0 | 215 | | |
| Functional tests | 3897 | 3065 | 61 | 11 | 0 | 276 | |
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
1 2 3 | |
1 2 3 | |
1 2 3 |
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
val uriEscaped = args(0) | |
implicit def listToArray[T: ClassManifest](list: List[T]): Array[T] = | |
list.toArray | |
implicit def arrayToList[T](arr: Array[T]): List[T] = | |
(arr: scala.collection.mutable.WrappedArray[T]).toList | |
def unescapeHexChars(char1: Char, char2: Char): Byte = { | |
Integer.decode("0x" + char1 + char2).toByte |
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
class StringWithReverses(str: String) { | |
def reverseOrder(): String = { | |
var rev = new StringBuilder(str.length) | |
(0 until str.length) foreach { (i) => rev.append(str.charAt(str.length-1-i)) } | |
rev.toString() | |
} | |
def reverseCases(): String = { | |
var rev = new StringBuilder(str.length) | |
(0 until str.length) foreach { (i) => |
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
object Main extends App { | |
trait Reversible { | |
val s:String | |
def reverseOrder = s reverse | |
def reverseCases = s collect{ | |
case c if c.isUpper => c.toLower | |
case c if c.isLower => c.toUpper | |
case c => c | |
} |
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
package scala | |
object ob { | |
class ReversibleString(str: String) { | |
def reverseOrder() = { | |
var s = "" | |
for (c <- str.split("")) { | |
s = c + s | |
} |
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
# -*- coding: utf-8 -*- | |
import math | |
def is_prime(n): | |
for i in xrange(2, int(math.sqrt(n)) + 1): | |
if not n % i: | |
return False | |
return True |