Skip to content

Instantly share code, notes, and snippets.

@wtnabe
wtnabe / README
Created August 21, 2010 07:45
Geohash Visualizer
1. rake fetch_lib
2. edit config.yaml ( skip OK )
3. rake open
@wtnabe
wtnabe / str_and.php
Created September 2, 2010 23:06
PHP's pseudo String#&&
<?php
/**
* return string from string A AND string B
*
* Similar Ruby's String#&&, but different. Ruby's behaves character
* by character.
*
* @since 2010-09-01
* @param string $str1
* @param string $str2
@@ -27,35 +27,41 @@ class Geomobilejp_Mobile
return (strlen($this->latitude) > 1 && strlen($this->longitude) > 1);
}
+ public function normalize( $params ) {
+ return array_combine( array_map( 'strtolower', array_keys( $params ) ),
+ array_values( $params ) );
+ }
+
protected function parse()
@wtnabe
wtnabe / singleton.php
Created September 19, 2010 14:07
A Testing Object for Singleton Pattern written in PHP
<?php
/**
* Empty Singleton Class
*
* @since 2010-09-19
* @require PHP >= 5.0.0
*/
class Singleton {
private function __construct() {
@wtnabe
wtnabe / MEMO
Created September 24, 2010 15:02
Geohash Visualizer 2, multiple geohashes can be drawn on google maps
仕様
====
* 複数の geohash を google map 上に描画するツール
* 基準となる住所は human readable で与えることができる
* 住所を geocoding で encode して map の位置を変更できる
* textarea を parse できる
* textarea に 1行1つの geohash を入力できる
@wtnabe
wtnabe / gist:620129
Created October 11, 2010 06:38
My elisp snippet for Tramp's 'sshx' method
;; tramp
(require 'tramp)
(setq tramp-default-method "sshx")
(add-to-list
'tramp-multi-connection-function-alist
'("sshx" tramp-multi-connect-rlogin "ssh -t -t %h -l %u -F ~/.ssh/config /bin/sh%n"))
@wtnabe
wtnabe / .my-carbon.el
Created October 24, 2010 15:25
My elisp snippet for CarbonEmacs with Window System
;; keybindings
(mac-key-mode t)
(setq mac-command-modifier 'alt)
(setq mac-control-modifier 'control)
(setq mac-option-modifier 'meta)
@wtnabe
wtnabe / doxyfile.diff
Created November 25, 2010 01:06
Doxyfile for PHP-based site
@@ -38,7 +38,7 @@
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY =
+OUTPUT_DIRECTORY = /PATH/TO/DEST
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
@@ -60,7 +60,7 @@
@wtnabe
wtnabe / QUnit_example_without_jQuery.html
Created December 6, 2010 13:18
QUnit example without jQuery
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="http://github.com/jquery/qunit/raw/master/qunit/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://github.com/jquery/qunit/raw/master/qunit/qunit.js"></script>
<script>
test("a basic test example", function() {
@wtnabe
wtnabe / jpmobile_conflicts_casein
Created December 7, 2010 08:59
jpmobile_conflicts_casein
uninitialized constant ActionController::Request
.../vendor/ruby/1.8/gems/jpmobile-0.1.3/lib/jpmobile/hook_action_controller.rb:31
.../vendor/ruby/1.8/gems/jpmobile-0.1.3/lib/jpmobile/rails.rb:6
.../vendor/ruby/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
.../vendor/ruby/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
.../vendor/ruby/1.8/gems/activesupport-3.0.3/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
.../vendor/ruby/1.8/gems/jpmobile-0.1.3/lib/jpmobile/rails.rb:2
.../vendor/ruby/1.8/gems/jpmobile-0.1.3/lib/jpmobile.rb:55
/opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
/opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'