Skip to content

Instantly share code, notes, and snippets.

View brydavis's full-sized avatar

Bryan Davis brydavis

View GitHub Profile
{
sample := "%&546!Hello, playground 09892&#%^"
re1 := regexp.MustCompile(`\W+`)
s := re1.ReplaceAllString(sample, `_`)
re2 := regexp.MustCompile(`[0-9]`)
s2 := re2.ReplaceAllString(s, `*`)
s3 := strings.Trim(strings.ToLower(s2), "_")
Install s3fs on Mac OS X
1 - Install Homebrew - http://brew.sh/
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
2 - Use Homebrew to install s3fs + dependencies
brew install s3fs
3 - Do some custom stuff. I only used the first step from here -> https://gist.github.com/fukayatsu/3910097
sudo /bin/cp -rfX /usr/local/Cellar/fuse4x-kext/0.9.2/Library/Extensions/fuse4x.kext /Library/Extensions
@brydavis
brydavis / bandcamp_security_job.md
Last active July 4, 2019 05:51
Steps for Completing Skill Challenge for Bandcamp Job

Came across the following job posting at Bandcamp in the afternoon of Friday, January 11, 2019.

Senior Fraud/Risk Engineer

Bandcamp seeks an experienced fraud/risk engineer keen to track, restrain, and outwit an ever-mutating assortment of platform abusers. You’ll be the primary developer and expert authority on potential risks, playing a key role in growing a nascent team into a dedicated, effective, well-run operation...

To apply, gather the crumbs (starting with your cookies).

/* HSL */
$color1: hsla(51%, 70%, 65%, 1);
$color2: hsla(215%, 53%, 42%, 1);
$color3: hsla(180%, 7%, 91%, 1);
$color4: hsla(240%, 18%, 21%, 1);
$color5: hsla(356%, 70%, 51%, 1);
/* RGB */
$color1: rgba(228, 210, 104, 1);
$color2: rgba(51, 99, 164, 1);
@brydavis
brydavis / demo_email_smtp_send.py
Created December 7, 2018 22:37
Sending email via SMTP in Python
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
sender_email_address = "[email protected]"
sender_email_password = "Pass12345"
receiver_email_address = ["[email protected]","[email protected]"]
@brydavis
brydavis / dir_size.go
Created November 6, 2018 07:11
recursively measuring the size of the a directory / subdirectory
package main
import "filepath"
import "os"
func main() {
dirSize("path/to/folder")
}
func dirSize(path string) (int64, error) {
@brydavis
brydavis / create_aws_session_string_creds.go
Created November 5, 2018 22:57
Create an AWS SDK session from string credentials (say, you retrieve your creds from a database)
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)
func main() {
@brydavis
brydavis / get_aws_account_id.go
Created November 5, 2018 22:55
Get the account ID for an AWS account (assuming that credentials file is present)
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
)
@brydavis
brydavis / pumpkin_color.go
Created November 5, 2018 08:07
extracting color samples from a picture of a big pumpkin
// https://www.devdungeon.com/content/working-images-go#reading_image_from_file
// https://socketloop.com/tutorials/golang-get-rgba-values-of-each-image-pixel
package main
import (
"fmt"
"image"
"image/jpeg"
"os"
package main
import (
"fmt"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())