Skip to content

Instantly share code, notes, and snippets.

View fkei's full-sized avatar
😀

fkei fkei

😀
View GitHub Profile
@fkei
fkei / git-feature-start
Created February 4, 2014 02:40
Git リポジトリディレクトリで、指定したブランチ名でブランチを作成し、合わせてリモートブランチも作成するコマンド
#!/bin/bash
#
# git-feature-start - Git リポジトリディレクトリで、指定したブランチ名でブランチを作成し、合わせてリモートブランチも作成するコマンド
#
pushd `dirname $0` >/dev/null 2>&1
[ $? -eq 1 ] && exit 1
__script_dir=`pwd`
popd >/dev/null 2>&1
__base_dir=`dirname ${__script_dir}`
@fkei
fkei / bash-multiline
Created February 4, 2014 02:42
Bash でヒアドキュメント
cat <<__EOF__
hoge
foo
__EOF__
@fkei
fkei / maxfilesize-pre-commit.md
Created February 26, 2014 04:33
git#pre-commit : This command prevent commit if total file size exceeds error is occured.
$ cat .git/hooks/pre-commit
#!/bin/bash
#
# This command prevent commit if total file size exceeds error is occured.
#
@fkei
fkei / gruntjshint-precommit
Created February 26, 2014 05:48
git#pre-commit : precommit grunt-jshint checker
#!/bin/bash
#
grunt jshint
[ $? -ne 0 ] && echo "grunt jshint error" && exit 1
exit 0
@fkei
fkei / log4js.js.patch
Created March 4, 2011 01:47
Array type check
--- lib/log4js.js.orig 2011-03-04 10:32:06.000000000 +0900
+++ lib/log4js.js 2011-03-04 10:42:24.000000000 +0900
@@ -134,8 +134,8 @@
args = [ ALL_CATEGORIES ];
}
//argument may already be an array
- if (args[0].forEach) {
- args = args[0];
+ if (args[0].constructor.name === 'Array') {
+ args = args[0];
@fkei
fkei / The system's IP address is obtained
Created March 4, 2011 04:59
Mac OSX and Linux support.
#!/usr/bin/env node
var os = require('os');
var osType = os.type();
var search = function() {};
if (osType === 'Darwin') {
var nic = 'en0'; // Mac OSX
@fkei
fkei / node-websocket-server 1.4.03 patch
Created March 31, 2011 09:01
Changes in 1.4.01 from 1.4.02, multibyte character "Connection.prototype.write (data)" has stopped working.
--- lib/ws/connection.js.orig 2011-03-31 16:43:40.000000000 +0900
+++ lib/ws/connection.js 2011-03-31 16:45:33.000000000 +0900
@@ -182,10 +182,10 @@
/*-----------------------------------------------
Various utility style functions:
-----------------------------------------------*/
-function write(connection, data) {
+function write(connection, data, encoding) {
debug(connection.id, 'write: ', (new Buffer(data)).inspect());
if (connection._socket.writable) {
@fkei
fkei / APPNAME
Created July 3, 2011 09:41 — forked from shimondoodkin/APPNAME
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@fkei
fkei / test.js
Created May 31, 2012 01:59 — forked from shigeki/test.js
socket.io memoryUsage profile with heatbeat by manually gc
var io = require('socket.io').listen(8081);
var parser = require('socket.io').parser;
io.sockets.on('connection', function(socket) {
var pre;
var i = 0;
io.transports[socket.id].parser.on('data', function(p) {
var packet = parser.decodePacket(p);
if(packet.type === 'heartbeat') {
if(global.gc) global.gc();
var memoryUsage = process.memoryUsage();
@fkei
fkei / eventlet_gs_uploader.py
Created July 27, 2012 15:34 — forked from batok/eventlet_gs_uploader.py
A python script to do asynchronous upload to google storage using boto and eventlet libraries
# this program uploads to google storage using boto and eventlet all the jpg files of a selected folder
import eventlet
bcon = eventlet.import_patched("boto.gs.connection")
import glob
FOLDER = "/Users/myself/Documents/" # replace this with your chosen folder
BUCKET_NAME = "whateveryourbucketname" # replace this with your bucket name
def upload(myfile):
c = bcon.GSConnection()