๐
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
| func openBrowser(url string) { | |
| var err error | |
| switch runtime.GOOS { | |
| case "linux": | |
| err = exec.Command("xdg-open", url).Start() | |
| case "windows": | |
| err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() | |
| case "darwin": | |
| err = exec.Command("open", url).Start() |
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
| import ( | |
| "runtime" | |
| "time" | |
| ) | |
| ... | |
| go func() { | |
| for { | |
| var m runtime.MemStats |
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
| import ( | |
| "archive/zip" | |
| "io" | |
| "os" | |
| "path/filepath" | |
| "strings" | |
| ) | |
| func zipit(source, target string) error { | |
| zipfile, err := os.Create(target) |
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
| function eachWithIdx(iterable, f) { var i = iterable.iterator(); var idx = 0; while (i.hasNext()) f(i.next(), idx++); } | |
| function mapEach(iterable, f) { var vs = []; eachWithIdx(iterable, function (i) { vs.push(f(i));}); return vs; } | |
| OUT.append(JSON.stringify( mapEach(ROWS, function(row, row_idx) { | |
| var r = {}; | |
| eachWithIdx(COLUMNS, function(col, col_idx) { r[ col.name() ] = row.value(col); }); | |
| return r; | |
| }))); |
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
| # Logic for forking connections | |
| # The forked process does not have access to static vars as far as I can discern, so I've done some stuff to check if the op threw an exception. | |
| def fork_with_new_connection | |
| # Store the ActiveRecord connection information | |
| config = ActiveRecord::Base.remove_connection | |
| pid = fork do | |
| # tracking if the op failed for the Process exit | |
| success = 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
| wget --recursive --no-clobber --page-requisites --adjust-extension --convert-links --restrict-file-names=unix --domains guides.rubyonrails.org --no-parent http://guides.rubyonrails.org/v2.3.11/ |