Skip to content

Instantly share code, notes, and snippets.

@taiansu
taiansu / about_method.rb
Last active August 29, 2015 14:04
Explaination
# puts something 等同於 puts something.to_s 所以都會自動轉字串
# p something 等同於 puts something.inspect 會印出比較詳細的資料,通常是 debug 用。
# 當你在
def method
"aaa"
end
# 等同於
def method
defmodule Chat.Client do
def join(server) do
client_send server, :join
end
def say(server, message) do
client_send server, { :say, message }
end
def leave(server) do
@taiansu
taiansu / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@taiansu
taiansu / webpack.config.js
Last active August 29, 2015 14:11
webpack config template
module.exports = {
entry: "./main.coffee",
output: {
path: __dirname,
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{ test: /\.coffee$/, loader: "coffee" },
@taiansu
taiansu / no_null_value.js
Last active August 29, 2015 14:16
null_value_checker
//var _ = require('underscore');
var goodData = {a: 1, b: 2, c: 3};
var badData = {a: null, b: 1, c: 2};
var noNullValue = function(data, checkKeys){
// check all keys unless pass an array
checkKeys = checkKeys || _.keys(data);
// will be something like [true, false, false], true means there is a null value on our checkKeys.
@taiansu
taiansu / atomic_weight.json
Created March 27, 2015 14:38
Chemical atomic weight json
{
"H": 1.008,
"He": 4.00260,
"Li": 6.94,
"Be": 9.012182,
"B": 10.81,
"C": 12.011,
"N": 14.007,
"O": 15.999,
"F": 18.9984032,
@taiansu
taiansu / keybase.md
Created May 12, 2015 05:05
keybase.md

Keybase proof

I hereby claim:

  • I am taiansu on github.
  • I am taiansu (https://keybase.io/taiansu) on keybase.
  • I have a public key whose fingerprint is C106 EE56 DA03 DC21 EE39 E951 5511 57E2 7F47 C2EE

To claim this, I am signing this object:

import React from 'react';
const Item = React.createClass({
handleClick() {
this.props.itemClicked(this.props.index);
},
render() {
return <li onClick={this.handleClick} className={this.props.className}>
<span>{this.props.item.email}</span>
@taiansu
taiansu / JsAssert.html
Created August 3, 2011 18:47
Javascript assert
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>JavaScript Testing Lab</title>
<style>
.pass:before {
content: 'PASS: ';
color: blue;
font-weight: bold;
@taiansu
taiansu / .bash_profile
Created August 8, 2011 07:01 — forked from ihower/gist:897951
bash_profile setting
export CLICOLOR=1;
export LSCOLORS=ExFxCxDxBxegedabagacad;
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;