Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@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 / gowebserver.go
Last active September 18, 2015 22:15
Simple Webserver in Golang
package main
import (
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
@josephspurrier
josephspurrier / get_all_permissions.sh
Created September 21, 2012 15:53
This script creates a text file that contains all the current permissions of the entire linux system.
#!/bin/bash
### ——————————————————————– ###
# This script creates a text file that contains all the current permissions
# of the entire linux system.
# Run: sudo bash get_all_permissions.sh
# Location: http://virtualparadise.wordpress.com/2010/04/29/linux-repair-permissions
@josephspurrier
josephspurrier / script.sh
Created October 12, 2015 19:19
Setup Golang on AWS Ubuntu
###############################################################################
# New Server - AWS
###############################################################################
# Update software
sudo apt-get update
sudo apt-get upgrade
# Install Apps
sudo apt-get install unzip
@josephspurrier
josephspurrier / replaceall.go
Created October 31, 2015 14:31
Replace all text in a folder
// 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 / appworker.go
Last active October 31, 2015 17:42
Golang Master and Worker - Kill Detection
package main
/*
Run and it will create appmaster.exe which will create a new appworker.exe if it is shutdown.
Must delete appmaster.exe before each run.
Only tested on Windows.
Should build with: -ldflags -H windowsgui
*/
import (
{
"Database": {
...
"MongoDB": {
"URL": "127.0.0.1",
"Database": "gowebapp"
}
},
...
}
@josephspurrier
josephspurrier / txt2json.go
Created February 1, 2016 22:26
Encode File Contents as JSON String
package main
import (
"encoding/json"
"flag"
"io"
"io/ioutil"
"log"
"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
@josephspurrier
josephspurrier / flappybird.swift
Created May 4, 2016 19:23
Flappy Bird in Swift
//
// GameScene.swift
// Flappy Bird
//
// Created on 4/20/16.
// Copyright (c) 2016 Joseph Spurrier. All rights reserved.
//
import SpriteKit