Skip to content

Instantly share code, notes, and snippets.

@arosh
arosh / gist:2048547
Created March 16, 2012 04:45
はてな記法用のリンクを取得するブックマークレット (TwitterとMarkdown付き)

ブックマークレットをGistに上手く書く方法を見つけられなかったので、自分で「お気に入りを作成」→「編集」の手順で登録して下さい。

javascript:(function(){var%20d=window.open().document;d.writeln('<table>');d.writeln('<tr><td>はてな記法</td><td>['+location.href+':title='+document.title+']</td></tr>');d.writeln('<tr><td>Twitter</td><td>'+document.title+'%20'+location.href+'%20</td></tr>');d.writeln('<tr><td>Markdown</td><td>['+document.title+']('+location.href+')</td></tr>');d.writeln('</table>');d.close();})();

1行になるように気をつけて下さい。

object Main {
def ><(x: Any) = Console.err.println(x)
def main(args: Array[String]) {
(><) {"Error!"}
}
}
@arosh
arosh / gist:2198230
Created March 25, 2012 16:53
カナ入力の暗号ソルバー
#!/usr/bin/env ruby
# encoding: utf-8
kana_keys = <<-'EOS'
ぬふあうえおやゆよわほへ
たていすかんなにらせ
ちとしはきくまのりれけむ
つさそひにみもねるめろ
EOS
@arosh
arosh / gist:2686865
Created May 13, 2012 08:02
そのディレクトリにあるHTMLをUTF-8に変換するシェルスクリプト
iconv --list
で指定できる文字コードが表示される
for s in *.html; do cp $s ${s%.html}.cp.html; done
for s in *.cp.html; do iconv -f CP932 -t UTF-8 < $s > ${s%.cp.html}.html; done
@arosh
arosh / gist:3097887
Created July 12, 2012 12:45
scroll.js
function smooth_scroll(selector, target) {
$(selector).click(function() {
var pos = $(target).offset().top;
$('body').animate( { scrollTop: pos }, 'slow' );
});
}
@arosh
arosh / gist:3122978
Created July 16, 2012 14:18
FizzBuzz
(define (FizzBuzz n)
(if (> n 1) (FizzBuzz (- n 1)))
(cond
((= (modulo n 15) 0) (print "FizzBuzz"))
((= (modulo n 5) 0) (print "Fizz"))
((= (modulo n 3) 0) (print "Buzz"))
(else (print n))))
(define (main args)
(FizzBuzz 30))
@arosh
arosh / MainWindow.xaml
Created July 31, 2012 02:54
System.Windows.Forms.PictureBox with WPF
<Window x:Class="Measure_and_Control.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="初めてのアプリケーション" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
@arosh
arosh / rmexe.py
Last active October 7, 2015 21:18
rmexe
#!/usr/bin/env python
# coding: utf-8
import sys
from sys import stderr
import os
from os import path
import re
import shutil
def main():
@arosh
arosh / gist:3286305
Created August 7, 2012 15:18
ダミヤン識別
// 起動時に呼び出される関数
void setup() {
// ウィンドウのサイズ
size(720, 480);
// fps
// timer関数を呼んで時間経過を調べるほうが望ましいが、
// 時間もあまりないので、0.05秒に1回draw()関数が呼ばれるのを利用した
frameRate(20);
// 背景色(灰色っぽい)
background(128);
@arosh
arosh / gist:3303574
Created August 9, 2012 11:53
extractSessionID
/**
* headerからSessionIDを抽出する
*/
def extractSessionID(header: Map[String, Set[String]]): Option[String] = {
val regex = """^JSESSIONID=(\w+);.+$""".r
val r = header.get("Set-Cookie") flatMap { cookie =>
cookie collect {
case regex(id) => id
} headOption