Skip to content

Instantly share code, notes, and snippets.

View zackproser's full-sized avatar
💭
Studying 📖

Zack Proser zackproser

💭
Studying 📖
View GitHub Profile
@zackproser
zackproser / stage-docker.sh
Created August 30, 2017 17:39
Dockerized website staging script
#!/usr/bin/env bash
# This script will build and stage a docker image on a linux box
# Be sure to change STAGING_IP to the IP address of your staging machine
#
# This script also assumes you have configured ssh for your staging machine
echo "This will stage the branch: $(git rev-parse --abbrev-ref HEAD
)"

Keybase proof

I hereby claim:

  • I am zackproser on github.
  • I am zackproser (https://keybase.io/zackproser) on keybase.
  • I have a public key whose fingerprint is 3758 1700 61C5 E6A6 B4E7 585A 74AF E48B 525E B91D

To claim this, I am signing this object:

@zackproser
zackproser / cobra-command-setup.go
Created October 20, 2019 15:59
Cobra command setup
var rootCmd = &cobra.Command{
Use: "super-catfacts",
Short: "Catfacts prank service",
Long: "Super catfacts is a full featured catfacts SMS and phone pranking service capable of running multiple simultaneous attacks.",
PersistentPreRun: persistentPreRun,
}
@zackproser
zackproser / cobra-read-config.go
Created October 20, 2019 16:03
Example of reading a config file with Cobra
func init() {
cobra.OnInitialize(initConfig)
}
func initConfig() {
log.SetLevel(logrus.DebugLevel)
// Look for a config file in the working directory
viper.SetConfigName("config")
if Config.Twilio.APIKey == "" {
log.Fatal("Twilio API Key is a required argument")
}
log.WithFields(logrus.Fields{
"Raw": Config.Server.Admins[i],
"Valid": valid,
"Formatted": formatted,
"Parsed": Config.Server.Admins,
}).Debug("Parsing authorized server administrators")
func initServer() {
attackMgr = new(AttackManager)
attackMgr.Initialize()
attackMgr.Run()
router := httprouter.New()
// AttackManager is a client for starting, stopping and tracking attacks
type AttackManager struct {
repository []*Attack
}
// Attack represents a currently running prank against a target phone number
type Attack struct {
ID int `json:id`
Target string `json:target`
StartTime time.Time `json:starttime`
MsgCount int `json:msgcount`
}
// Add commences a new attack
func (a *AttackManager) Add(atk *Attack) (*Attack, error) {
valid, num := validateNumber(atk.Target)
if valid == false {
return nil, errors.New("Invalid attack target:" + atk.Target)
}
running, attack := a.attackRunning(num)
if running == true {
return nil, errors.New("Attack already running on " + attack.Target + " count: ")
}