Skip to content

Instantly share code, notes, and snippets.

Joseph Spurrier josephspurrier

Block or report user

Report or block josephspurrier

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@josephspurrier
josephspurrier / values_pointers.go
Last active Feb 23, 2020
Golang - Asterisk and Ampersand Cheatsheet
View values_pointers.go
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@josephspurrier
josephspurrier / etc-init.d-hello-world
Last active Feb 22, 2020
/etc/init.d Script for Go Application
View etc-init.d-hello-world
#!/bin/bash
#
# chkconfig: 35 95 05
# description: Hello world application.
# Run at startup: sudo chkconfig hello-world on
# Load functions from library
. /etc/init.d/functions
@josephspurrier
josephspurrier / aescmd.go
Created Dec 23, 2014
Golang - Encrypt, Decrypt, File Read, File Write, Readline
View aescmd.go
package main
import (
"bufio"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"io/ioutil"
@josephspurrier
josephspurrier / bitmask.go
Created Feb 1, 2015
Golang - Determine if bitmask is set
View bitmask.go
/*
fmt.Println(Bitmask(0x6).IsSet(0x2))
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListDescriptions(charValues))
fmt.Println(Bitmask(f.FileHeader.Characteristics).ListValues(charValues))
*/
type Bitmask uint16
// BitValue is a value and a description
type BitValue struct {
@josephspurrier
josephspurrier / structs_interface.go
Last active Feb 12, 2020
Golang - Understand Structs and Interfaces
View structs_interface.go
// Also available at: https://play.golang.org/p/yTTpB5gB6C
package main
import (
"fmt"
)
// *****************************************************************************
// Example 1 - Struct vs Struct with Embedded Type
@josephspurrier
josephspurrier / loadCSV.php
Last active Feb 3, 2020
Parse a CSV file in PHP, remove hidden characters, escape fields to prepare for MySQL, and return an associative array.
View loadCSV.php
// Auto detect line endings
ini_set('auto_detect_line_endings', true);
function loadCSV($file)
{
// Create an array to hold the data
$arrData = array();
// Create a variable to hold the header information
$header = NULL;
@josephspurrier
josephspurrier / sshremote.go
Last active Jan 15, 2020
Golang Remote Execution
View sshremote.go
package main
/*
// Example
sci := ServerConnInfo{
"127.0.0.1",
"22",
"ubuntu",
`key.pem`,
}
@josephspurrier
josephspurrier / md5.go
Created Aug 26, 2015
MD5 Hash Generator in Golang
View md5.go
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 / webserver.go
Created Mar 21, 2017
Simple Web Server in Go
View webserver.go
package main
import (
"io"
"net/http"
)
func main() {
http.HandleFunc("/", index)
http.ListenAndServe(":8080", nil)
@josephspurrier
josephspurrier / .bash_profile
Last active Nov 17, 2019
macOS Bash Profile
View .bash_profile
#################################################################################
#
# Bash Configurations and Aliases for OS X
#
# Latest: https://gist.github.com/josephspurrier/acf7327726df6587a56ff2c2062314fa
# This was modified so it can be included in your ~/.zshrc file with the command:
# source ~/.bash_profile
#
# It's recommended to use oh-my-zsh:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
You can’t perform that action at this time.