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
// Copyright 2015 Joseph Spurrier | |
// Author: Joseph Spurrier (http://josephspurrier.com) | |
// License: http://www.apache.org/licenses/LICENSE-2.0.html | |
package main | |
import ( | |
"debug/pe" | |
"flag" | |
"fmt" |
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
// Source: http://nicolasmerouze.com/guide-routers-golang/ | |
// Package httprouterwrapper allows the use of http.HandlerFunc compatible funcs with julienschmidt/httprouter | |
package httprouterwrapper | |
import ( | |
"net/http" | |
"github.com/gorilla/context" | |
"github.com/julienschmidt/httprouter" |
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
// Source: https://gist.github.com/tdegrunt/045f6b3377f3f7ffa408 | |
// Example: replaceall.exe -find="cordove" -replace="gowebapp" -extension="*.go" -filename=true -write=false | |
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" |
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
/* | |
I was able to achieve these speeds on my laptop: Intel Core i7-4500U @ 1.80GHZ | |
2015/08/20 09:28:05 Test 1: 664579 took 47.0074ms | |
2015/08/20 09:28:05 Test 2: 5761455 took 626.9954ms | |
2015/08/20 09:28:13 Test 3: 50847534 took 8.0860009s | |
*/ | |
package main | |
import ( |
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
/* | |
I was able to achieve these speeds on my laptop: Intel Core i7-4500U @ 1.80GHZ | |
Test 1: 664579 took 56ms | |
Test 2: 5761455 took 702ms | |
Test 3: 50847534 took 9.062s | |
*/ | |
public class PrimeCounter { | |
public static void main(String[] args) { | |
int[] times = new int[]{10000000, 100000000, 1000000000}; |
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 | |
// Source: https://www.socketloop.com/tutorials/how-to-generate-checksum-for-file-in-go | |
import ( | |
"crypto/md5" | |
"fmt" | |
"io" | |
"math" | |
"os" |
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 ( | |
"crypto/sha1" | |
"fmt" | |
"io" | |
"math" | |
"os" | |
) |
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
# Find all files containing text | |
grep -Ril "text to find" / | |
# Write test to file using sudo | |
echo 'This is the test.' | sudo tee /etc/configfile | |
# Send a log using curl | |
curl -X POST -T file.txt https://example.com/file_upload; | |
# Check supported ciphers on server |
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
{ | |
"Database": { | |
... | |
"MongoDB": { | |
"URL": "127.0.0.1", | |
"Database": "gowebapp" | |
} | |
}, | |
... | |
} |
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" | |
"log" | |
"net/http" | |
"os" | |
"strings" | |
"time" |