Skip to content

Instantly share code, notes, and snippets.

View suisho's full-sized avatar
🚫
Deprecated

Old account suisho

🚫
Deprecated
View GitHub Profile
@suisho
suisho / gist:2930802
Created June 14, 2012 14:50
convert wild card string to
function wildCardToRegexp(wildCardPattern){
var regexpOperator = '^$\\.+?()[]{}|';
for(var i = 0; i < regexpOperator.length; i++){
var operator = regexpOperator[i];
wildCardPattern = wildCardPattern.replace(operator,"\\"+operator);
}
return wildCardPattern.replace("*",".*");
}
@suisho
suisho / TsvOutputFormat.java
Created August 16, 2012 05:34
Output extension ".tsv" for Hadoop
import java.io.DataOutputStream;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.io.compress.CompressionCodec;
@suisho
suisho / cssinclude.js
Created November 6, 2012 15:57
extend '@import "some.css"' to css content
/**
* cssinclude.js
*
* extend syntax like @import "some.css"
* to actualy css file contents when imported css exist.
* If imported css file isn't exist, not execute replace.
*
* * usage *
* var cssString
* cssString = require('./cssinclude').extend(cssString);
@suisho
suisho / example.d.ts
Created November 12, 2012 19:55
typescript compiler that custom library
declare function exampleFunc() : int;
@suisho
suisho / Browser.java
Created November 14, 2012 04:36
Detect browser from user agent in hadoop pig UDF
package pigudf;
import java.io.IOException;
import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
/**
* Usage:
* log = LOAD logfile.txt AS (time:int, path:chararray, ua:chararray)
* log = FOREACH log GENERATE time, path, ua, pigudf(ua) AS browser;
@suisho
suisho / DependsOnPlatform.java
Created December 15, 2012 14:20
get annotation on junit setup
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface DependsOnPlatform {
public String value();
}
@suisho
suisho / hubot_call.js
Last active December 12, 2015 09:28
Call hubot only javascript
// set package.json and `npm init`
// or
// $npm install init;
// $npm install hubot --save
// $npm install coffee-script --save
var fork = require('child_process').fork
var fs = require("fs")
var env = {
//"HUBOT_IRC_SERVER" : "",
@suisho
suisho / load-script-recursive.coffee
Created February 20, 2013 16:13
Load hubot script recursive directory
# Description:
# Load script recursively
# Dependences:
# "glob": "~3.1.20"
Path = require "path"
Glob = require "glob"
module.exports = (robot) ->
robot.logger.info "read sub dir"
dirs = Glob.sync(__dirname+"/**/*/")
@suisho
suisho / long_path.js
Created February 23, 2013 19:58
windowsが対象パスが長すぎますとか言ってきてにっちもさっちもいかなくなったときにフォルダ名を一文字に変えてやるスクリプト。 npm install glob
var glob = require("glob");
var fs = require("fs");
var path = require("path")
glob("./LONG_FILE_NAME/**/",function(err, files){
files.reverse().forEach(function(f){
var newFsp = f.split("/")
newFsp.pop()
newFsp.pop()
@suisho
suisho / Default.sublime-keymap
Created February 24, 2013 05:50
[sublime text] unbind tab key
[
{ "keys": ["tab"], "command": "NULL" } ,
{ "keys": ["tab"], "command": "insert", "args": {"characters": "\t"} },
{ "keys": ["tab"], "command": "replace_completion_with_next_completion", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
},
{ "keys": ["tab"], "command": "reindent", "context":