This file contains hidden or 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
(defun my-html-escape (start end) | |
(interactive "r") | |
(save-excursion | |
(save-restriction | |
(narrow-to-region start end) | |
(goto-char (point-min)) | |
(while (re-search-forward "<" nil t) | |
(replace-match "<")) | |
(goto-char (point-min)) | |
(while (re-search-forward ">" nil t) |
This file contains hidden or 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 java.security.MessageDigest | |
abstract class Digest(algorithm: String) { | |
val digest = MessageDigest.getInstance(algorithm) | |
def hexdigest(value: String) : String = hexdigest(value.getBytes()) | |
def hexdigest(value: Array[Byte]) : String = { | |
byte2hexstring(digest.digest()) | |
} |
This file contains hidden or 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:(function(){document.addEventListener("keydown",function%20handleKey(e){var%20tag=(e.target||e.srcElement).tagName;if(/input|textarea/i.test(tag)){return;}if(e.keyCode==74){var%20next=$(document.querySelector("ul.s_shapeSheetNavi%20a.active")).parent().next().find("a");next.length==0?$(document.querySelector("ul.s_shapeSheetNavi%20li:first-child%20a")).click():next.click();}else%20if(e.keyCode==75){var%20prev=$(document.querySelector("ul.s_shapeSheetNavi%20a.active")).parent().prev().find("a");prev.length==0?$(document.querySelector("ul.s_shapeSheetNavi%20li:last-child%20a")).click():prev.click();}e.preventDefault();},false);})(); |
This file contains hidden or 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
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>example</groupId> | |
<artifactId>example</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>Example</name> | |
<properties> | |
<scala.version>2.8.0.RC2</scala.version> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
This file contains hidden or 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 Benchmark { | |
import java.lang.management.ManagementFactory | |
val CAPTION = " user system total real" | |
def benchmark(block: Job => Unit) : Unit = benchmark(1)(block) | |
def benchmark(count: Int)(block: Job => Unit) : Unit = { | |
val job = new Job(count) | |
block(job) | |
job.dump() |
This file contains hidden or 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.matching.Regex | |
object NamedCapturing { | |
val namedCapture = """\((\?<(.+?)>)(.+?)\)""".r | |
def regex(path: String) : Regex = { | |
val (r, names) = parse((path, Array[String]())) | |
new Regex(r, names: _*) | |
} |
This file contains hidden or 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 calc(n: Int)(block: Int => Int) = { | |
block(n) | |
} | |
println(calc(10) { n => | |
if (n % 2 == 0) return 0 | |
n * 2 | |
}) |
This file contains hidden or 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.collection.JavaConversions._ | |
import java.lang.reflect.{Type, ParameterizedType} | |
import jp.sf.amateras.mirage._ | |
import jp.sf.amateras.mirage.session._ | |
abstract class AbstractService[T] { | |
private def findEntityClass() : Option[Class[_]] = { | |
def genericParameter(t: Type) : scala.Array[Type] = { | |
if (classOf[ParameterizedType].isInstance(t)) { |
This file contains hidden or 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 java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.security.AccessController; | |
import java.security.PrivilegedActionException; | |
import java.security.PrivilegedExceptionAction; | |
import java.text.MessageFormat; |
This file contains hidden or 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 java.io._ | |
import java.util._ | |
import java.util.ResourceBundle.Control | |
import java.net._ | |
import java.security._ | |
class CharsetSupportedControl(charset: String = "utf-8") extends Control { | |
override def newBundle(baseName: String, locale: Locale, format: String, loader: ClassLoader, reload: Boolean) : ResourceBundle= { | |
if ("java.class" == format) { | |
super.newBundle(baseName, locale, format, loader, reload) |
OlderNewer