Skip to content

Instantly share code, notes, and snippets.

@tksk
tksk / annotate-output.sh
Last active August 29, 2015 14:10
annotate each output lines
#! /bin/bash
# this script was downloaded from:
# http://jeroen.a-eskwadraat.nl/sw/annotate
# and is part of devscripts 2.10.53ubuntu3
# Executes a program annotating the output linewise with time and stream
# Version 1.2a
# Copyright 2003, 2004 Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
// http://nabetani.sakura.ne.jp/hena/ord13updowndouble/
object PlusMinusDouble extends App {
def solve(list: List[(Int, Int)]): Int = list match {
case (n, 0) :: _ => n
case (n, x) :: xs if x % 2 != 0 =>
solve(xs :+ (n+1, x+1) :+ (n+1, x-1))
case (n, x) :: xs =>
1 2
1 1
1 2
4 3
4 8
1 5
8 2
8 2
8 7
scala> Seq.tabulate(9,9)((i,j)=>(i+1)*(j+1)).foreach{println}
List(1, 2, 3, 4, 5, 6, 7, 8, 9)
List(2, 4, 6, 8, 10, 12, 14, 16, 18)
List(3, 6, 9, 12, 15, 18, 21, 24, 27)
List(4, 8, 12, 16, 20, 24, 28, 32, 36)
List(5, 10, 15, 20, 25, 30, 35, 40, 45)
List(6, 12, 18, 24, 30, 36, 42, 48, 54)
List(7, 14, 21, 28, 35, 42, 49, 56, 63)
List(8, 16, 24, 32, 40, 48, 56, 64, 72)
List(9, 18, 27, 36, 45, 54, 63, 72, 81)
import org.objectweb.asm._
import org.objectweb.asm.tree._
import java.io._
import java.lang.{Iterable => JIterable}
import java.util.jar._
import collection.JavaConverters._
/** Jinsei INSpects jar Entries' Inside
*/
@tksk
tksk / Hexify.scala
Last active December 17, 2015 04:08
0xdeadbeaf みたいな、hex の範囲で表現可能な単語をリストする。このとき、o => 0 などいくつかの特例を認める。
// wget https://raw.github.com/rubymaniac/coursera/master/scala/week6/assignment/target/scala-2.9.2/classes/forcomp/linuxwords.txt
object Hexify extends App {
val table = ("abcdefilozsgq" zip
"abcdef1102599") toMap
def hexify(word: String) = util.Try(word -> (word map table)).toOption
val words = io.Source.fromFile("linuxwords.txt").getLines.flatMap { hexify }
words foreach println
@tksk
tksk / build.sbt
Created December 7, 2012 18:37
fork proc
fork := true
javaOptions += "-Denv=boo"
[
{ "command": "copy", "caption": "コピー" },
{ "command": "cut", "caption": "切り取り" },
{ "command": "paste", "caption": "貼り付け" },
{ "caption": "-", "id": "selection" },
{ "command": "select_all", "caption": "すべて選択" },
{ "caption": "-", "id": "file" },
{ "command": "open_in_browser", "caption": "ブラウザで開く" },
{ "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"}, "caption": "ファイラで開く" },
{ "command": "copy_path", "caption": "フルパスをコピー" },
@tksk
tksk / gsk7.out
Created November 2, 2012 17:50
gsk7cmd parser
Label:<label name>
Key Size: 1024
Version: X509 V3
Serial Number: 45 A0 C2 70 8D 77 8F 34 43 A1 5A C1 AE CB 62 DE
Issued By: VeriSign Class 3 Secure Server CA
VeriSign Trust Network
VeriSign, Inc.
US
Subject: xxx.com
<Organization name>
@tksk
tksk / svnkit.scala
Created August 15, 2012 16:35
svnkit.scala
::#!
@echo off
call C:\path\to\sbt\scalas %0 %*
goto :eof
::!#
/***
scalaVersion := "2.9.2"