Skip to content

Instantly share code, notes, and snippets.

@tkawachi
tkawachi / install_phpunit.sh
Created April 18, 2011 13:46
Snow Leopard で $HOME/pear に pear と PHPUnit を入れる
#!/bin/sh
# install PHPUnit to $HOME/pear on Snow Leopard
cd $HOME
pear config-create $HOME .pearrc
pear install -o PEAR
./pear/pear channel-update pear.php.net
./pear/pear list
./pear/pear list-upgrades
./pear/pear channel-discover pear.phpunit.de
./pear/pear channel-discover pear.symfony-project.com
@tkawachi
tkawachi / hello.go
Created May 29, 2011 10:17
goroutine test on app engine
package hello
import (
"fmt"
"http"
"time"
)
func init() {
http.HandleFunc("/", handler)
package controllers;
import play.Logger;
import play.jobs.Job;
import play.mvc.Controller;
public class Test extends Controller {
public static void test() {
subFunction();
renderText("OK");
package controllers;
import java.util.HashMap;
import play.mvc.Controller;
public class Application extends Controller {
static String problematicMethod() {
final HashMap<String, String[]> map;
map = new HashMap<String, String[]>();
map.put("key", new String[] { "v1", "v2" });
@tkawachi
tkawachi / rds-utf8.sh
Created November 2, 2011 03:45
Set charset as utf8 for RDS
#!/usr/bin/env bash
set -u
set -e
GROUP="$1"
PARAMS="character_set_client character_set_connection character_set_database character_set_results character_set_server"
for param in $PARAMS; do
echo Set $param to utf8
rds-modify-db-parameter-group "$GROUP" -p "name=$param, value=utf8, method=immediate"
done
sudo port install mysql5
sudo -u mysql mysql_install_db5
(cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &)
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'YOUR_PASSWORD'
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
#!/usr/bin/env ruby
# require safariwatir gem.
require 'safariwatir'
browser = Watir::Safari.new
browser.goto 'http://tr.twipple.jp/hotword/'
# browser.goto 'http://tr.twipple.jp/talent/' # required another regexes
html = browser.html
chunk_regex = / START : (.+?) END : (.*)/m
rank_regex = /<div class="rankTtl"><a href="[^"]+\?q=([^"]+)" target="_blank">([^<]+)<\/a>(.*)/m
if(this.infoLabel.size.height > 28)
{
this.infoLabel.height = 28;
}
else
{
this.infoLabel.height = 'auto';
}
var tmp = tmp2 = Ti.App.tmp = {};
Ti.API.debug('eq1: ' + (Ti.App.tmp === tmp));
Ti.API.debug('eq2: ' + (tmp2 === tmp));
printf <- function(fmt, ...) {
cat(sprintf(fmt, ...))
}
VNTTRK <- function(csv_file) {
abet <- read.csv(csv_file, header=T, row.names=1)
abe <- data.frame(rank=1:nrow(abet), freq=abet)
par(mfrow=c(1,2))
plot(abe, type="l")
plot(log(abe), type="l")