Skip to content

Instantly share code, notes, and snippets.

View ChenLiZhan's full-sized avatar

Lee Chen ChenLiZhan

View GitHub Profile
@ChenLiZhan
ChenLiZhan / AWS EBS.md
Last active January 22, 2017 07:35
The note of Amazon Elastic Block Store (EBS)

Introduction of EBS

@ChenLiZhan
ChenLiZhan / Error Message
Last active August 29, 2015 14:17
Express todo list
undefined is not a function
undefined
TypeError: undefined is not a function
at exports.current_user (/Users/chenlizhan/Desktop/Lee/Programming/node/Web/expresss4/todo/routes/index.js:62:34)
at Layer.handle [as handle_request] (/Users/chenlizhan/Desktop/Lee/Programming/node/Web/expresss4/todo/node_modules/express/lib/router/layer.js:82:5)
at trim_prefix (/Users/chenlizhan/Desktop/Lee/Programming/node/Web/expresss4/todo/node_modules/express/lib/router/index.js:302:13)
at /Users/chenlizhan/Desktop/Lee/Programming/node/Web/expresss4/todo/node_modules/express/lib/router/index.js:270:7
at Function.proto.process_params (/Users/chenlizhan/Desktop/Lee/Programming/node/Web/expresss4/todo/node_modules/express/lib/router/index.js:321:12)
# Author: Lee Chen(chung1350@gmail.com)
# XorHelper provides an encode method to xor a file with a key
module XorHelper
# XOR encodes/decodes a document with a key
# Parameters:
# doc: string
# key: string
# Returns: string
@ChenLiZhan
ChenLiZhan / gist:06c7c261571fe7072460
Created December 2, 2014 08:01
SciRuby/nmatirx problems
$ bundle exec rake compile
cd tmp/x86_64-darwin14/nmatrix/2.2.0
/Users/chenlizhan/.rvm/rubies/ruby-head/bin/ruby -I. ../../../../ext/nmatrix/extconf.rb
using C++ standard... c++11
g++ reports version... gcc
checking for main() in -lclapack... *** ../../../../ext/nmatrix/extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
@ChenLiZhan
ChenLiZhan / fizzbuzz.rb
Created September 28, 2014 07:33
fizzbuzz rewrite
# see http://en.wikipedia.org/wiki/Fizz_buzz for details on FizzBuzz game
# Naive fizzbuzz method that yields fizzbuzz game results one at a time
def fizzbuzz(size)
[*1..size].each do |number|
number = 'fizzbuzz' if number % 15 == 0
number = 'fizz' if number % 3 == 0
number = 'buzz' if number % 5 == 0
yield number.to_s
end
@ChenLiZhan
ChenLiZhan / TSV_to_YAML.rb
Last active August 29, 2015 14:06
Convert .tsv to .yml
# Our bonus application is available at https://gist.github.com/ChenLiZhan/278863a90703dcc8f87c
require 'yaml'
def read_tsv(input_file)
content, head, informations = [], [], []
File.open(input_file, 'r') do |file|
head = file.readline.gsub("\n", '').split("\t")
file.each_line do |line|
content << line.gsub("\n", '').split("\t")
@ChenLiZhan
ChenLiZhan / YAML_to_TSV.rb
Created September 28, 2014 01:01
Convert .yml to .tsv
require 'yaml'
def get_head(informations)
informations[0].keys.join("\t")
end
def get_content(informations)
info = ''
informations.each do |information|
info << information.values.join("\t") << "\n"
@ChenLiZhan
ChenLiZhan / Testing Notes
Created September 21, 2014 15:32
Testing Notes
The methods we can use when testing:
METHODS = [
:request,
:get,
:post,
:put,
:patch,
:delete,
:options,
:head,
@ChenLiZhan
ChenLiZhan / Sinatra Notes
Created September 16, 2014 17:02
Some Notes about Sinatra
Change the default assets directory (Change to assets from public)
- set :public_folder, File.dirname(__FILE) + '/assets'
@ChenLiZhan
ChenLiZhan / bundle problems
Created September 16, 2014 15:54
some problems I faced when doing some bundle command
bundle install
- Install the dependencies specified in your Gemfile.
bundle exec
- This command making all gems specified in Gemfile avaliable to require in Ruby programs.