This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p "foo testing..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/60033/what-is-the-easiest-way-to-duplicate-an-activerecord-record | |
# rails < 3.1 | |
new_record = old_record.clone | |
#rails >= 3.1 | |
new_record = old_record.dup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to find out where a method comes from. | |
# Learned this from Dave Thomas while teaching Advanced Ruby Studio | |
# Makes the case for separating method definitions into | |
# modules, especially when enhancing built-in classes. | |
module Perpetrator | |
def crime | |
end | |
end | |
class Fixnum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://stackoverflow.com/questions/1628563/git-move-recent-commit-to-a-new-branch | |
git branch newbranch | |
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work. | |
git checkout newbranch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to add remote repo in git, the example is following: | |
git remote add origin git@github.com:caius/foo.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For a specific file use: | |
git checkout path/to/file/to/revert | |
# For all unstaged files use(Make sure to include the period at the end.): | |
git checkout -- . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<!-- IF PEN IS PRIVATE --> | |
<!-- <meta name="robots" content="noindex"> --> | |
<!-- END --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function () { var main = document.getElementsByTagName('frame')[2], selects = main.contentDocument.getElementsByTagName('select'); for (var i = 1; i < selects.length; i++) { selects.item(i).value = Math.random() > 0.5 ? "5(良好)" : "4(优秀)"; } main.contentDocument.getElementById('Button1').click();})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func GetStructField(f interface{},path []string) interface{} { | |
rangeOver := f.( map[string]interface{}) | |
counter := 0 | |
maxLen := len(path)-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cp | |
import ( | |
"io" | |
"os" | |
) | |
func cp(dst, src string) error { | |
s, err := os.Open(src) | |
if err != nil { |
OlderNewer