Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# use
# watch ./top.sh
#
OUT="/tmp/topdata"
echo "---- cpu ----" >> $OUT
// 名前付きパラメータに対応
get("/${user}/${id}.html"){env =>
import env._
template(
<h1>ブログなんだよもん</h1>
<p>
<a href="new.html">投稿</a>
</p>
<p>name :{params("user")}</p>
<p>id :{params("id")}</p>
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class ExceptionSample {
public void f(){
try{
new FileInputStream(new File(""));
}catch (FileNotFoundException e) {
@koduki
koduki / vimrc
Created February 11, 2010 13:11
set nocompatible
filetype plugin indent on
syntax enable
set backspace=eol,indent,start
set smartcase
noremap ; :
noremap : ;
object ExploringCaves extends Application {
class Vector(var x:Int, var y:Int){ def r = x*x + y*y}
def solv(logs:List[(Int, Int)]) = {
var m = new Vector(0, 0);
var c = new Vector(0, 0);
def f(dx:Int, dy:Int){
c.x += dx
c.y += dy
if((c.r > m.r) || ((c.r == m.r) && (c.x > m.x))){
m.x = c.x
public class FactorySample {
static class Hoge{
public Hoge() {
System.out.println("Hello wold");
}
}
static <T> T as( Object o ) {
return (T) o;
}
//パターン1 hoge, foo, barのテストをいい感じに書けない!
class A{
public run(){
return hoge(foo(bar))
}
private hoge(String s) ...
private foo(String s) ...
private bar(String s) ...
}
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja">
<head>
<meta charset="utf-8" />
<title>ブログなんだよもん</title>
</head>
<body>
<header>
<h1>ブログなんだよもん</h1>
import java.io._
import scala.xml._
def tag2html(text:String) = text.replaceAll("<link caption=\"(.*?)\".*?>(.*?)</link>", "<a href='$2'>$1</a>").replaceAll("<link>(.*?)</link>", "<a href='$1'>$1</a>").replaceAll("<p>(.*?)</p>", "<pre>$1</pre>").replaceAll("<p>(.*?)</p>", "<pre>$1</pre>");
val blog_data = scala.xml.XML.loadFile(new File("/mnt/share/documents/blog.txt"))
val article = (blog_data \ "document") toList(3)
article \ "@id"
/*
* 作りかけ
*/
function f(i){
var us = document.location.toString().split("/");
us.pop();
var url = us.join('/');
return (url + '/books/images/1.4585/' + i + '.jpg');
}