This file contains hidden or 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 ( | |
| "bytes" | |
| "fmt" | |
| ) | |
| func main() { | |
| var buffer bytes.Buffer |
This file contains hidden or 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
| // Exists reports whether the named file or directory exists. | |
| func Exists(name string) bool { | |
| if _, err := os.Stat(name); err != nil { | |
| if os.IsNotExist(err) { | |
| return false | |
| } | |
| } | |
| return true | |
| } |
This file contains hidden or 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
| sudo C_INCLUDE_PATH=/usr/local/Cellar/imagemagick/6.9.0-10/include/ImageMagick-6/wand/ PKG_CONFIG_PATH=/usr/local/Cellar/imagemagick/6.9.0-10/lib/pkgconfig/ gem install rmagick |
This file contains hidden or 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
| $ brew tap homebrew/versions | |
| $ brew install postgresql92 | |
| $ brew switch postgresql 9.2.8 |
This file contains hidden or 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
| curl -u ':uname' 'https://api.github.com/repos/:org/:repo/issues' > issues.json |
This file contains hidden or 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
| # Add the remote, call it "upstream": | |
| git remote add upstream https://github.com/whoever/whatever.git | |
| # Fetch all the branches of that remote into remote-tracking branches, | |
| # such as upstream/master: | |
| git fetch upstream | |
| # Make sure that you're on your master branch: |
This file contains hidden or 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" | |
| "time" | |
| ) | |
| type generator struct { | |
| generateNext chan struct{} | |
| sendCh chan int |
This file contains hidden or 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" | |
| "reflect" | |
| ) | |
| func main() { | |
| var i = [...]uint8{0, 7, 16, 22, 28} // array, compiler counts elements |
This file contains hidden or 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
| // imageFormat returns the image format. | |
| func imageFormat(file *os.File) string { | |
| bytes := make([]byte, 4) | |
| n, _ := file.ReadAt(bytes, 0) | |
| file.Seek(0, 0) | |
| if n < 4 { | |
| return "" | |
| } | |
| if bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47 { | |
| return "png" |