Skip to content

Instantly share code, notes, and snippets.

View MatthewCallis's full-sized avatar
🍖
Hungry Goriya

Matthew Callis MatthewCallis

🍖
Hungry Goriya
View GitHub Profile
#!/usr/bin/env ruby
$KCODE = 'utf8'
# 漢数字を数値に変換する
#
# * http://ja.wikipedia.org/wiki/%E6%BC%A2%E6%95%B0%E5%AD%97
# * http://www.akatsukinishisu.net/kanji/kansuji.html
module Kansuji
saykanji()
{
voice=`kanji2voice "$1"`
echokanji "$voice"
/usr/local/bin/saykana "$voice" &
}
#FORMAT_OPTION='--node-format=%pS%f[8] --unk-format=%M --eos-format="\n"'
sayeb()
{
# -*- coding: utf-8 -*-
require 'open-uri'
require 'kconv'
#
#= SKK の人名辞書ファイルから架空の氏名を生成する (Ruby version)
#
# Authors:: 宮國 渡
# Copyright:: Copyright (c) 2009 Wataru MIYAGUNI <gonngo@gmail.com>
# URL:: http://github.com/gongo
@nebiros
nebiros / mb_str_pad.php
Created November 4, 2009 20:30
mb_str_pad
<?php
/**
* mb_str_pad
*
* @param string $input
* @param int $pad_length
* @param string $pad_string
* @param int $pad_type
* @return string
@nebiros
nebiros / App_Thumb.php
Created February 23, 2010 15:06
Thumbnails lib
<?php
class App_Thumb
{
protected $_width = null;
protected $_oldWidth = null;
protected $_height = null;
protected $_oldHeight = null;
protected $_imagePath = null;
protected $_resource = null;
#!/usr/local/bin/ruby
# -*- coding: utf-8 -*-
require "cgi"
cgi = CGI.new
$KCODE = "UTF8"
class String
def fragments(n)
@paulirish
paulirish / gist:357048
Created April 6, 2010 00:28
average hex color
// get the average color of two hex colors.
function avgcolor(color1,color2){
var avg = function(a,b){ return (a+b)/2; },
t16 = function(c){ return parseInt((''+c).replace('#',''),16) },
hex = function(c){ return (c>>0).toString(16) },
hex1 = t16(color1),
hex2 = t16(color2),
r = function(hex){ return hex >> 16 & 0xFF},
g = function(hex){ return hex >> 8 & 0xFF},
b = function(hex){ return hex & 0xFF},
/*
To avoid polluting the global namespace this uses an anonymous
function which is called with either the URL for an external
JavaScript file or a function. In either case jQuery will be loaded
from the Google CDN before your code is executed so it's free to
depend on jQuery without checking for it and can do things like
jQuery.getScript() to load other components (e.g. jQuery UI),
stylesheets, etc.
*/
(function (target, msg) {
@Solvalou
Solvalou / Space Invaders - NES Assembly
Created May 17, 2010 18:13
Space Invaders NES Reconstruction
; iNES - Header
.inesprg 1 ; size of PRG-ROM, 16kB
.ineschr 1 ; size of CHR-ROM/RAM, 8kB
.inesmir 0 ; type of mirroring, 0 = horizontal, 1 = vertical
.inesmap 0 ; used mapper, 0 = no mapper
.bank 1
.org $FFFA
.dw int_return ; NMI_Routine($FFFA)
#!/usr/bin/ruby -w
require 'benchmark'
require 'set'
array = (1..1_000_000).to_a
hash = {}
array.map {|x| hash[x] = nil}
a_set = array.to_set
Benchmark.bm(15) do |x|