Skip to content

Instantly share code, notes, and snippets.

View hokaccha's full-sized avatar

Kazuhito Hokamura hokaccha

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use Text::Markdown 'markdown';
use HTML::TreeBuilder;
use List::Util 'max';
@hokaccha
hokaccha / assert.js
Created December 5, 2011 13:57
node.js aseert for client side javascript
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the 'Software'), to
// deal in the Software without restriction, including without limitation the
@hokaccha
hokaccha / nodebrew
Created November 13, 2011 15:05
node package manager
#!/usr/bin/env perl
# nodebrew
#
# Install:
#
# 1. このスクリプトをダウンロードして実行権限つけてパスが通ってるところにおく
# 2. 以下にパスを通す
# $HOME/.nodebrew/current/bin
#
@hokaccha
hokaccha / app.js
Created November 10, 2011 10:58
express mapRouter
var express = require('express')
, mapRouter = require('./express-mapRouter')
, app = express.createServer()
, routesDir = __dirname + '/routes';
// 'GET /' : 'root:index' はこれと同じ
// var root = require('./routes/root');
// app.get('/', root.index);
var routesMap = {
'GET /' : 'root:index'
@hokaccha
hokaccha / routes.js
Created October 15, 2011 02:32 — forked from tj/routes.js
Express routes
var app = require('../app');
var colors = require('colors');
function format(method) {
switch (method) {
case 'get': return 'GET '.grey;
case 'post': return 'POST '.cyan;
case 'put': return 'PUT '.green;
case 'delete': return 'DELETE '.magenta;
default: return method.toUpperCase();
@hokaccha
hokaccha / spua.js
Created August 24, 2011 03:11
spua.js
var ua = {};
var _ua = navigator.userAgent;
if (_ua.indexOf('Android') !== -1) {
ua.android = true;
ua.mobile = _ua.indexOf('Mobile') !== -1;
}
else if (_ua.indexOf('iPad') !== -1) {
ua.ios = true;
@hokaccha
hokaccha / gist:951652
Created May 2, 2011 14:08 — forked from tacamy/gist:951646
JavaScript UA Navigator(Android+'Mobile')
if ((navigator.userAgent.indexOf('iPhone') !== -1 && navigator.userAgent.indexOf('iPad') === -1) || navigator.userAgent.indexOf('iPod') !== -1 || /Android.+Mobile/.test(navigator.userAgent)) {
location.href = '/hoge/';
}
@hokaccha
hokaccha / gist:951634
Created May 2, 2011 13:53
android_ua_judge.js
var navigator = {
userAgent: 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
};
if (/Android.+Mobile/.test(navigator.userAgent)) {
console.log('Android!');
}
@hokaccha
hokaccha / jquery.smarthistory.js
Created February 23, 2011 07:56
Page transition jQuery plugin, useing history.pushState.
/*
* jquery.smarthistory.js
*
* Copyright (c) 2010 Kazuhito Hokamura
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* @author Kazuhito Hokamura (http://webtech-walker.com/)
* @version 0.0.1
*
// define namespage
(function(global) {
function ns(namespace, val) {
var o = global,
names = namespace.split('.'),
i = 0,
len = names.length,
name;