Skip to content

Instantly share code, notes, and snippets.

View motemen's full-sized avatar

Hironao OTSUBO motemen

View GitHub Profile
// ==UserScript==
// @name Hatena::Diary - Replace mimeTeX by ASCIIMathML
// @namespace http://subtech.g.hatena.ne.jp/motemen/
// @include http://d.hatena.ne.jp/*
// @include http://*.g.hatena.ne.jp/*
// @include https://*.g.hatena.ne.jp/*
// ==/UserScript==
// Thanks to ASCIIMathML http://www1.chapman.edu/~jipsen/asciimath.html
var texImages = document.evaluate('//img[@class="tex"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
// ==UserScript==
// @name id:USERNAME
// @namespace http://subtech.g.hatena.ne.jp/motemen/
// @include http://*.hatena.ne.jp/USERNAME/
// @include http://*.hatena.ne.jp/USERNAME
// ==/UserScript==
location.href = location.href.replace('USERNAME', 'motemen');
100000th post
#!perl
use strict;
use warnings;
use File::Temp;
my $basename = shift;
my $output = `cat $basename.in | perl $basename.pl`;
my $fh = File::Temp->new;
print $fh $output;
exec "diff -u $basename.out " . $fh->filename;
// ==UserScript==
// @name s/Bishoujo/Ijoufu/g
// @namespace http://subtech.g.hatena.ne.jp/motemen/
// ==/UserScript==
function ijoufize (node) {
var children = node.childNodes;
for (var i = 0; i < children.length; i++) {
if (children[i].nodeType == children[i].TEXT_NODE) {
children[i].nodeValue = children[i].nodeValue.replace(/美少女/g, '偉丈夫');
addBefore(Tumblr, 'post', function (ps) {
if (ps.itemUrl.match(/^http:\/\/img\d+\.pixiv\.net\/img\/([^\/]+?)\/\d+_m\.\w+$/)) {
ps.itemUrl = ps.itemUrl.replace(/_m(\.\w+)$/, '$1');
}
if (ps.pageUrl.match(/^http:\/\/www\.pixiv\.net\/member_illust\.php\?mode=big&illust_id=\d+$/)) {
ps.pageUrl = ps.pageUrl.replace(/mode=big/, 'mode=medium');
}
});
object HelloWorld {
def quickSort(list : List[Double]) : List[Double] =
list match {
case Nil => Nil
case List(x) => list
case x :: xs => quickSort(xs filter (x >=)) ::: List(x) ::: quickSort(xs filter (x <))
}
println(quickSort(List(3,1,4,1,5,9,2)))
println("Hello, world!")
import scala.io.Source
import scala.collection.immutable._
abstract class Bencoding
case class BString(string : String) extends Bencoding
case class BInt(number : Int) extends Bencoding
case class BList(list : List[Bencoding]) extends Bencoding
case class BDict(dict : Map[String,Bencoding]) extends Bencoding
object Bencoding {
package net.tokyoenvious.scalatest
import org.scalatest._
class TAPReporter extends Reporter {
var testNumber : Int = 1
override def runStarting (testCount : Int) =
println ("1.." + testCount)
object Main extends Application {
object TAP {
var number:Int = 1
var directive = ""
def plan (planNum:Int) {
println(
"1.." + planNum
)