Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / godownload.go
Created September 20, 2015 19:31
File Downloader in Golang
package main
import (
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
)
@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 (
@josephspurrier
josephspurrier / sshclient.go
Last active September 10, 2022 02:23
Golang SSH Client
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"
@josephspurrier
josephspurrier / sshremote.go
Last active May 27, 2021 19:54
Golang Remote Execution
package main
/*
// Example
sci := ServerConnInfo{
"127.0.0.1",
"22",
"ubuntu",
`key.pem`,
}
@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 / ticker.go
Last active October 29, 2020 14:43
Ticker on the Minute
package main
import (
"log"
"time"
)
func main() {
log.Println("Started ticker")
@josephspurrier
josephspurrier / addimport.go
Last active October 28, 2022 14:34
Add Import using ast in Go
// Source: https://gitlab.pro/googlesource/tools/blob/ae534bcb6ccdd13487d0491c2194d10ebcd30ff3/astutil/imports.go
// Source: https://golang.org/src/go/doc/example.go#L262
package main
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
@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