Skip to content

Instantly share code, notes, and snippets.

@huydx
huydx / AMD.js
Created April 14, 2013 00:34
AMD
define(["alpha"], function (alpha) {
return {
verb: function(){
return alpha.verb() + 2;
}
};
});
@huydx
huydx / script loader
Created April 13, 2013 15:47
script loader
(function(){
var scList = new Array();
scList[0] = 'http://cdnjs.cloudflare.com/ajax/libs/ace/0.2.0/ace.js';
scList[1] = 'http://cdnjs.cloudflare.com/ajax/libs/alloy-ui/1.0.1/aui-min.js';
scList[2] = 'http://cdnjs.cloudflare.com/ajax/libs/barman/0.2.2/barman.min.js';
var len = scList.length;
for (var i=0; i<len; i++) {
var script = document.createElement('script');
var firstScript = document.getElementsByTagName('script')[0];
script.src = scList[i];
@huydx
huydx / drop all table
Created April 13, 2013 13:50
dropmysqltbl.sh
#!/bin/bash
MUSER="$1"
MPASS="$2"
MDB="$3"
# Detect paths
MYSQL=$(which mysql)
AWK=$(which awk)
GREP=$(which grep)
@huydx
huydx / gist:5378245
Created April 13, 2013 12:37
sql create new user with pw
GRANT ALL PRIVILEGES ON *.* TO 'usrname'@'localhost' IDENTIFIED BY 'pw' WITH GRANT OPTION

GitHub Flow

31 Aug 2011

git-flowの問題点 (Issues with git-flow)

私は人々にGitを教えるためにあちこちを飛び回っているが、最近のほぼすべてのクラスやワークショップでgit-flowについてどう思うかを尋ねられた。私はいつも、git-flowは素晴らしいと思うと答えている。何百万ものワークフローを持ったシステム(Git)を提供し、ドキュメントもあるし、よくテストされている。フレキシブルなワークフローは、実に容易なやり方で多くの開発者の役に立つ。標準的なものになりつつあり、開発者はプロジェクトや企業の間を移動しつつこの標準的なワークフローに馴染むことができる。

@huydx
huydx / gist:5329449
Created April 7, 2013 07:35
scala coursera course week 2
package funsets
import common._
/**
* 2. Purely Functional Sets.
*/
object FunSets {
/**
* We represent a set by its characteristic function, i.e.
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@huydx
huydx / gist:5219891
Last active December 15, 2015 06:59
prompt scheme
export PS1='\e[0;36m\u⌘ \e[0;35m\W \e[0;33m`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\e[m\]'
@huydx
huydx / gist:5031184
Created February 25, 2013 16:46
convert text to html with simple format
raw sanitize(simple_format(post.content), :tag => %w(br p))
require 'benchmark'
require 'ruby-prof'
names = ["matz", "rossum", "ryal", "ritchie", "brendan"]
n = 5000
class Array
def method_missing name, *argv
super unless name =~ /^sort_by_(¥w+)_(asc|desc)$/
condition = ($2 == "asc" ? "{ |a, b| a.%s <=> b.%s }" : "{ |a, b| b.%s <=> a.%s }") % [$1, $1]