Skip to content

Instantly share code, notes, and snippets.

@cou929
cou929 / template.pl
Created October 10, 2010 02:49
Template for perl script.
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
my $man = 0;
my $help = 0;
# my $port = 0;
@cou929
cou929 / input.pl
Created January 4, 2011 15:56
Read file if the command line argument is specified, or read from standard input.
#! /usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
# global variables
my $help = 0;
my $man = 0;
@cou929
cou929 / bootpl.pl
Created January 4, 2011 15:57
Generate template of perl script
#! /usr/bin/perl
use strict;
use warnings;
&main; exit;
sub main {
if (!$ARGV[0]) {
print "Usage: $0 <script name>\n";
@cou929
cou929 / progress_listeners.js
Created January 5, 2011 13:52
Sample code for progress listener.
/*
* progress_listener.js
* Kosei Moriyama <cou929@gmail.com>
*
* 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);
@cou929
cou929 / extension_manager.js
Created January 5, 2011 13:58
Sample code for extension manager
/*
* Kosei Moriyama <cou929@gmail.com>
*
* 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"]
@cou929
cou929 / add_from_history.js
Created January 5, 2011 14:04
Sample code for form history auto complete
/*
* Kosei Moriyama <cou929@gmail.com>
*
* 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"/>
@cou929
cou929 / extract_lists_to_hatena.js
Created March 31, 2011 05:40
Extract list of community member data from "http://nodeguide.com/community.html" and make hatena notation.
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(":");
@cou929
cou929 / convert.py
Created May 3, 2011 12:47
Convert exported file from wordpress.com for importing posterous.
# /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')
@cou929
cou929 / task_bulk_upload.py
Created May 6, 2011 12:35
support task bulk upload
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])
@cou929
cou929 / clgrep.py
Created May 6, 2011 17:50
grep ChangeLog memo.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
clgrep.py
grep ChangeLog memo.
forked from clgrep on Ruby (http://0xcc.net/unimag/1/)
Kosei Moriyama <cou929@gmail.com>