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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
ex.py | |
expand pattern and return sequence. | |
Kosei Moriyama <[email protected]> |
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
BaseBallGame.prototype.pitch = function(toHitting, toBunt, score) { | |
var strike_prob = 0.6; | |
var goro_prob = 0.3; | |
var swing_miss_prob = 0.2; | |
var hit_prob = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 4]; | |
var strike = Math.random() > strike_prob; | |
var base = hit_prob[parseInt(Math.random() * 10, 10)]; | |
var isHit = false; | |
var isGoro = Math.random() < goro_prob; | |
var isSwingMiss = 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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
clgrep.py | |
grep ChangeLog memo. | |
forked from clgrep on Ruby (http://0xcc.net/unimag/1/) | |
Kosei Moriyama <[email protected]> |
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 sys | |
for line in sys.stdin: | |
tmp = line.strip().split(',') | |
print "insert into eip_t_todo (user_id, todo_name, category_id, priority, state, note, start_date, end_date, public_flag, addon_schedule_flg) values (10, {0}, 9, 3, 0, {1}, '2011-05-06', '9999-12-31', 'T', 'T');".format(tmp[0], tmp[1]) |
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
# /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import re | |
from xml.dom.minidom import parse | |
def markdown_nize(html): | |
ret = '' | |
html = html.encode('utf-8') |
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
var ul = document.querySelectorAll("ul"); | |
var i; | |
var out = ""; | |
for (i=2; i<ul.length; i++) { | |
var li = Array.slice.call(ul[i].querySelectorAll("li")); | |
li.map(function(x) { | |
var c = x.childNodes; | |
if (c.length === 1) { | |
var del = c[0].nodeValue.indexOf(":"); |
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
/* | |
* Kosei Moriyama <[email protected]> | |
* | |
* Sample code for Firefox Extensions. | |
* Enable auto complete for certain form from history of inputs. | |
*/ | |
// Write like this in xul firstly. | |
// Set "id" and "autocompletesearchparam" attribute for your own. | |
// <textbox id="my-form" type="autocomplete" autocompletesearch="form-history" autocompletesearchparam="my-form-history"/> |
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
/* | |
* Kosei Moriyama <[email protected]> | |
* | |
* Sample code for Firefox Extension. | |
* Get installed extension data using extensionsManager. | |
* List of attributes of extension data (returned value of getItemList()): | |
* http://www.oxymoronical.com/experiments/apidocs/interface/nsIUpdateItem | |
*/ | |
var extensionsManager = Components.classes["@mozilla.org/extensions/manager;1"] |
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
/* | |
* progress_listener.js | |
* Kosei Moriyama <[email protected]> | |
* | |
* Sample code for Firefox Extension. | |
* Do something when uri is changed using progress listener. | |
*/ | |
window.addEventListener('load', function() { myExtension.init(); }, false); | |
window.addEventListener("unload", function() { myExtension.uninit(); }, 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
#! /usr/bin/perl | |
use strict; | |
use warnings; | |
&main; exit; | |
sub main { | |
if (!$ARGV[0]) { | |
print "Usage: $0 <script name>\n"; |