Skip to content

Instantly share code, notes, and snippets.

@mathfur
mathfur / generate_graph_for_training.rb
Created November 23, 2010 04:11
素振り用課題を生成(hatena記法ソース->html->dot->gif)
# なぜかtext/hatenaのロードに失敗していたので入れた
$LOAD_PATH << "C:/Ruby/lib/ruby/gems/1.8/gems/text-hatena-0.12.20080627.0/lib"
require "nkf"
require "text/hatena"
module Enumerable
def rand
index = Kernel.rand(self.to_a.size)
self[index]
end
@mathfur
mathfur / text_hatena_example.rb
Created November 23, 2010 03:02
text/hatena使用例
# 準備:
# http://moonrock.jp/~don/ruby/text-hatena/README.html.ja
# からgemダウンロードして
# >gem install text-hatena-~.gem
# を実行した
# なぜかrequireに失敗するので追加した
$LOAD_PATH << "C:/Ruby/lib/ruby/gems/1.8/gems/text-hatena-0.12.20080627.0/lib"
require "text/hatena"
@mathfur
mathfur / get_links.js
Created November 18, 2010 12:36
現在開いているページの任意のtr > td > aについて、リンク先のページからpre要素を取得し、現在のページの末尾にリストアップする。
// バルーン表示メモ
// 以下抜粋
void InitializeComponent(void)
{
// notifyIcon1
this->notifyIcon1->BalloonTipIcon = System::Windows::Forms::ToolTipIcon::Warning;
this->notifyIcon1->BalloonTipText = L"ここが内容";
this->notifyIcon1->BalloonTipTitle = L"タイトル";
this->notifyIcon1->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"notifyIcon1.Icon"))); // ■アイコンがないとバルーンも表示されない
this->notifyIcon1->Text = L"notifyIcon1";
-- foo.txtを読み込んで行番号をつけて表示
-- ※同ディレクトリにApplicativeParsec.hsが要る
import ApplicativeParsec
p :: CharParser () [PLine]
p = many line
eol = string "\n"
letters = many1 letter
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
hello
<div id="output">output</div>
<script>
$(function(){
$.get("file:///C:/usr/tmp/in",function(e){
# [単語\t絶対パス\t行番号]のファイルから単語検索する
require "digest/md5"
wanna_search = ARGV[1]
ext = ARGV[0]
context = (ARGV[2] || 1).to_i
max_output = (ARGV[3] || 10).to_i
unless wanna_search && ext
STDERR.puts "args error"
# 指定のパス下にあるファイルから/w+を取り出して
# 単語\t絶対パス\t行番号
# のファイルを生成する
require "digest/md5"
paths = ["C:/usr/examples"]
exts = %w{ps1}
$verbose = false
void setup(){
size(300,300);
noLoop();
}
void draw(){
println("__START__");
String[] s = loadStrings("c:/usr/tmp/in");
PFont f = createFont(PFont.list()[0],20);
textFont(f);
-- ルーチン同士の呼び出し関係を解析するコード
-- * Parsecを使う
-- * ファイルinを読み込んで行ごとに分解して表示
-- * 表示するのはcallの行のみ
-- * showを一部実装
-- 同じフォルダにApplicativeParsec.hsを用意する
import ApplicativeParsec
import Data.Maybe