Skip to content

Instantly share code, notes, and snippets.

@huydx
huydx / file0.txt
Created June 5, 2013 06:59
Rubyで間違いやすい配列の範囲指定 ref: http://qiita.com/items/7f9737a191bb92cca81d
arr = [1,2,3,4,5,6]
arr[1..2]
arr[1,2]
@huydx
huydx / hamlconvert.sh
Created May 29, 2013 13:27
haml conversion
for i in `find app/views/devise/ -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; rm $i ; done
@huydx
huydx / stack.js
Created May 11, 2013 17:14
stack function
function foo(i) {
if (i < 0)
return;
document.writeln('begin:' + i);
foo(i - 1);
document.writeln('end:' + i);
}
foo(3);
@huydx
huydx / benchmark.rb
Created May 11, 2013 14:17
mongo benchmark
%self total self wait child calls name
3.65 0.405 0.254 0.000 0.151 3001 Mongo::Cursor#initialize
3.53 0.791 0.246 0.000 0.545 12001 *Mutex#synchronize
3.51 0.904 0.245 0.000 0.660 3000 Mongo::Collection#find
3.44 0.240 0.240 0.000 0.000 8116 <Class::IO>#select
2.95 0.775 0.205 0.000 0.570 3001 Mongo::Collection#initialize
2.52 0.226 0.175 0.000 0.051 9003 BSON::ByteBuffer#put_binary
2.05 0.546 0.143 0.000 0.403 3001 Mongo::Networking#read_documents
1.82 0.466 0.126 0.000 0.340 8116 Mongo::TCPSocket#read
1.77 1.552 0.123 0.000 1.429 16075 *Class#new
@huydx
huydx / recommender.rb
Created May 10, 2013 14:45
recommender
# -*- coding: utf-8 -*-
$:.unshift File.dirname(__FILE__)
require 'yaml'
require 'bundler'
require 'rgl/adjacency'
require 'rgl/bidirectional'
#load all necessary environment related things
def loadenv
config = YAML.load_file('config.yml')
@huydx
huydx / visualizer.js
Created May 5, 2013 14:51
visualizer.js
(function(){
window.onload = init;
function init() {
var context = new webkitAudioContext();
var audiobuffer;
var sourceNode;
var analyzer;
window.javascriptnode = null;
@huydx
huydx / rules.md
Last active December 16, 2015 18:39 — forked from radar/rules.md

Asking questions, the right way

First, #vruby focuses in technical side, we should not chit/chat or talk too much about subjects not relate to technical side

Second, hen asking questions in the #vruby channel, please follow these 12 simple rules. Can't count that high? The first 7 will get you in most people's good books.

  1. Do your research before hand. Your question may be answerable with a quick Google search or by simply experimenting. If you're using a method in Rails, look it up in the API Docs or in the Official Guides.
  2. If you've tried Googling, explain what terms you've tried to use so people can better help you.
  3. Clearly explain what is happening and create a Gist (http://gist.github.com) or Pastie (http://pastie.org) of the code that is causing the problem you are encountering, as well as any useful output like stacktraces. A "Full Trace" as opposed to the default "Application Trace" is preferred. *NO FAKE CODE. If you're
@huydx
huydx / bash_profile.sh
Last active December 16, 2015 16:48
bash_profile
export PATH=/usr/local/bin:$PATH
export SSL_CERT_FILE=~/.cert/cacert.pem
. ~/.nvm/nvm.sh
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
export SSL_CERT_FILE=~/.cert/cacert.pem
export CLI_COLOR=1
export LSCOLORS=DxFxBxDxCxcgcdabagacad

Python Number Conversion Chart

From To Expression
@huydx
huydx / eval.py
Created April 20, 2013 03:21
eval security test
eval(''.join(['',u'\u005F',u'\u005F',chr(105),chr(109),chr(112),chr(111),chr(114),chr(116),u'\u005F',u'\u005F']) + "('os')").listdir(".")