Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / showwinpe.go
Created February 1, 2015 10:28
Golang - Output PE Info
// 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"
@josephspurrier
josephspurrier / httprouterwrapper.go
Last active April 13, 2017 16:08
Golang - Making julienschmidt/httprouter compatible using gorilla/context
// 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"
@josephspurrier
josephspurrier / replaceall.go
Created June 29, 2015 01:07
Replace All Text Recursively in Files and File Names
// 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"
@josephspurrier
josephspurrier / primecounter.go
Last active August 29, 2015 14:27
Prime Number Counter in Golang
/*
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 (
@josephspurrier
josephspurrier / primecounter.java
Created August 25, 2015 16:30
Prime Number Counter in Java
/*
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};
@josephspurrier
josephspurrier / md5.go
Created August 26, 2015 21:44
MD5 Hash Generator in Golang
package main
// Source: https://www.socketloop.com/tutorials/how-to-generate-checksum-for-file-in-go
import (
"crypto/md5"
"fmt"
"io"
"math"
"os"
@josephspurrier
josephspurrier / sha1.go
Created August 26, 2015 22:08
SHA1 Hash Generator in Golang
package main
import (
"crypto/sha1"
"fmt"
"io"
"math"
"os"
)
@josephspurrier
josephspurrier / useful_commands.sh
Last active March 8, 2016 17:26
Userful Commands on Linux
# 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
{
"Database": {
...
"MongoDB": {
"URL": "127.0.0.1",
"Database": "gowebapp"
}
},
...
}
@josephspurrier
josephspurrier / gowebserver.go
Last active September 18, 2015 22:15
Simple Webserver in Golang
package main
import (
"fmt"
"log"
"net/http"
"os"
"strings"
"time"