Skip to content

Instantly share code, notes, and snippets.

@whym
whym / hr_replace_for_epub.py
Created Oct 21, 2017
Some epub readers ignore HR element in HTML. This program fixes it by replacing all HRs with '* * *'.
View hr_replace_for_epub.py
#! /usr/bin/env python
# -*- coding:utf-8 -*-
"""Some epub readers ignore HR element in HTML. This program fixes it by replacing all HRs with '* * *'. (Replacement is actually customizable beyond that)"""
import sys
import argparse
from ebooklib import epub
import re
import os
@whym
whym / iwenwiktnoll.py
Last active Jun 27, 2016
Add interwiki links to pages with no interwiki links
View iwenwiktnoll.py
#! /usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import sys
import oursql
import pandas as pd
sys.path.append(os.environ['PWB'])
from scripts import interwiki
@whym
whym / iwjawiktnoll.py
Last active May 30, 2016
Add interwiki links to pages in a given CSV list
View iwjawiktnoll.py
#! /usr/bin/python3
import pandas as pd
import os
import sys
sys.path.append(os.environ['PWB'])
from scripts import interwiki
import pywikibot
def mygen(target):
View producer_consumer.go
package main
import (
"fmt"
"time"
"math/rand"
)
type Load struct {
val int
@whym
whym / bad_words.txt
Last active Mar 5, 2016
Japanese bad words list
View bad_words.txt
死ね
しね
シネ
あほ
アホ
ばか
バカ
やりまん
ヤリマン
まんこ
@whym
whym / 政府ホームページ利用規約の一覧.mediawiki
Last active Sep 24, 2016
政府ホームページ利用規約と Creative Commons Attribution (CC BY)互換性明記の有無
View 政府ホームページ利用規約の一覧.mediawiki

以下の表の初版は2016年2月7日に政府(系)機関のCC BY対応状況を確認してまとめたものです。以後更新する可能性があります。「CC BY?」の欄は Creative Commons Attribution との互換性が規約に明記されているかどうかを示します。

政府機関 ウェブサイトの利用規約 CC BY?
内閣官房 http://www.cas.go.jp/jp/tyosakuken/contents.html
OK
View Global user contributions.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@whym
whym / bits.scala
Last active Apr 24, 2017
benchmark Java/Scala BigInt/BitSet implementations
View bits.scala
// benchmark Java/Scala BigInt/BitSet implementations
import scala.util.Random
import scala.collection.mutable
import scala.collection.immutable
import java.util.BitSet
import java.math.BigInteger
// derived from https://github.com/alexmasselot/benchmark-bitarray/blob/master/src/benchmark/bitarray/TimeIt.scala
def timeInMilli(n: Int, f: () => Unit) = {
View webarchive.rb
#! /usr/bin/env ruby
require 'open-uri'
require 'uri'
require 'readline'
require 'simpleidn'
require 'addressable/uri'
require 'mechanize'
def to_ascii_uri(uri)
u = Addressable::URI.parse(uri)
View Edit_intervals.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.