Skip to content

Instantly share code, notes, and snippets.

View fukata's full-sized avatar

fukata fukata

View GitHub Profile
@fukata
fukata / app.coffee
Created April 21, 2011 07:50
Rewrite app.js of Expressjs to CoffeeScript.
###
Module dependencies.
###
express = require 'express'
app = module.exports = express.createServer()
###
Configuration
@fukata
fukata / extends_object.js
Created April 25, 2011 09:41
JavaScriptによる継承もどき(子と親の繋がりは無)
> var parent = function(){this.hoge = 'foo';};
> parent.prototype.p = function() { this.px(this.hoge);};
[Function]
> parent.prototype.px = function(x) { console.log(x);};
[Function]
> var child = function(){parent.apply(this); this.events=['foo'];};
> child.prototype = parent.prototype;
{ p: [Function], px: [Function] }
> var c = new child();
> c.p();
@fukata
fukata / RefererCount.java
Created May 4, 2011 11:07
ApacheLogHadoopExample
package org.fukata.hadoop;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
#!/usr/bin/env python
#############################################
# Eratosthenes's Sieve
#
# see http://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
#
# Usage
# arg1: int Integer limit
#
@fukata
fukata / random_chars.py
Created May 6, 2011 13:01
Random Characters
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def random_chars(num=36):
import random
chars = "asdfghjkqwertyuopzxcvbnm1234567890ASDFGHJKLZXCVBNMQWERTYUOP"
strs = [random.choice(chars) for x in range(num)]
return ''.join(strs)
@fukata
fukata / site-thermography-example.js
Created May 8, 2011 11:09
サイトサーモグラフィの設置サンプル
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript">
var _st = {"activate_code":"[アクティベートコード]"};
</script>
<script type="text/javascript" src="http://site-thermography.appspot.com/media/js/thermography.js"></script>
@fukata
fukata / release2wp.sh
Created May 14, 2011 18:14
Release to WordPress plugin.
#!/bin/bash
########################################################
#
# 普段、gitなどで開発し、WordPressプラグインリポジトリの
# tagsディレクトリをリリース目的のみに利用している人用のスクリプト
#
# Usage:
# ./release2wp.sh repo release_dir tag [msg]
#
@fukata
fukata / atnd
Created May 15, 2011 14:33
Attendance memo tool.
#!/bin/bash
###########################################################
#
# Clone repo:
# git clone git://gist.github.com/973205.git attendance
#
# Create Database:
# mysqladmin -u root atnd
# mysql -u root atnd < attendance/ddl.sql
@fukata
fukata / implements_display_icon.diff
Created May 22, 2011 08:35
Google Ajax Translation implements display icon.
diff --git a/ajaxtranslation.php b/ajaxtranslation.php
index 1baf716..70f313e 100644
--- a/ajaxtranslation.php
+++ b/ajaxtranslation.php
@@ -723,6 +723,51 @@ if (!class_exists('GoogleTranslation')) {
return $translate_block;
}
+ /**
+ * get a translate button that can be used anywhere in a post or page as needed by a custom theme. This should be in the WordPress loop.
@fukata
fukata / automatic_close_notification.js
Created June 14, 2011 17:36
Automatic close Google Chrome Desktop Notification
var notification = webkitNotifications.createNotification(
'icon-48.png',
'TITLE',
'BODY'
);
notification.ondisplay = function(){
var self = this;
var close_interval = 5000;
setTimeout(function(){