Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import yaml
import urllib
import logging
import simplejson
# for OAuth
const static CvScalar Black = CV_RGB(0x00, 0x00, 0x00);
const static CvScalar Navy = CV_RGB(0x00, 0x00, 0x80);
const static CvScalar DarkBlue = CV_RGB(0x00, 0x00, 0x8B);
const static CvScalar MediumBlue = CV_RGB(0x00, 0x00, 0xCD);
const static CvScalar Blue = CV_RGB(0x00, 0x00, 0xFF);
const static CvScalar DarkGreen = CV_RGB(0x00, 0x64, 0x00);
const static CvScalar Green = CV_RGB(0x00, 0x80, 0x00);
const static CvScalar Teal = CV_RGB(0x00, 0x80, 0x80);
const static CvScalar DarkCyan = CV_RGB(0x00, 0x8B, 0x8B);
const static CvScalar DeepSkyBlue = CV_RGB(0x00, 0xBF, 0xFF);
@mohayonao
mohayonao / yahoodict.py
Created December 30, 2010 06:21
Yahoo!辞書で言葉を調べる
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import urllib
from collections import namedtuple
import BeautifulSoup
DictResult = namedtuple("YahooDictResult", "type lemma defins opts")
@mohayonao
mohayonao / MarioMML.py
Created January 22, 2011 00:14
Python+PyAudio+MMLでマリオのBGM再生 http://www.youtube.com/watch?v=rQtyiy-OOtA
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
import math
import array
import random
import itertools
import collections
@mohayonao
mohayonao / find_homography
Created March 25, 2011 22:09
4つの点からホモグラフィ行列(平面射影変換行列)を求める
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
def find_homography(src, dst):
# X = (x*h0 +y*h1 + h2) / (x*h6 + y*h7 + 1)
# Y = (x*h3 +y*h4 + h5) / (x*h6 + y*h7 + 1)
#
@mohayonao
mohayonao / isbn10
Created April 5, 2011 22:06
ISBN13をISBN10に変換する
var isbn10 = function(isbn) {
if (isbn && isbn.length == 13) {
var c = 0;
for (var i = 0; i < 9; i++)
c += isbn.charAt(i + 3) * (10 - i) - 0;
c = 11 - c % 11;
return isbn.substr(3, 9) + ((c == 10) ? "X" : c);
}
return isbn;
};
@mohayonao
mohayonao / Main.java
Created April 27, 2011 10:18
SimpleClock
package com.mohayonao.SimpleClock;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
@mohayonao
mohayonao / gist:1131616
Created August 8, 2011 11:39
JavaScript Sound Player Samples
window.onload = function() {
var IsMacChrome = navigator.userAgent.indexOf('Mac') != -1 &&
navigator.userAgent.indexOf('Chrome') != -1;
var samplerate = 48000, channel = 1, stream_length = 4096;
var sinwave = function(frequency) {
this.phase = 0.0;
this.phaseStep = frequency / samplerate;
@mohayonao
mohayonao / setupTypedArray.js
Created August 25, 2011 01:15
Fake TypedArray
function setupTypedArray(name) {
var fake_typedarray;
if (name in window) {
return window[name];
}
console.warn(name + ' is not defined, so use fake.');
fake_typedarray = function(arg) {
var i;
@mohayonao
mohayonao / dpdf.py
Created August 29, 2011 02:05
PDFを分割する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, re, optparse
import yaml
import pyPdf
def getprofile(profile):