Skip to content

Instantly share code, notes, and snippets.

@aaronstaves
aaronstaves / example_funcs.go
Created June 5, 2020 14:58
Go methods vs funcs - funcs
func DoDBThing(newrelic *newrelic.Application, myDB dynamo.IClient, querythinger string) error {
newrelic.txn() // whatever
myDB.query(querythinger, s.newrelic)
}
func DoServiceThing(newrelic *newrelic.Application, myService *sling.Sling, querythinger string) error {
newrelic.txn() // whatever
myService.Do(querythinger, newrelic)
}
@aaronstaves
aaronstaves / example_methods.go
Created June 5, 2020 14:55
Go methods vs funcs - methods
// MyHandler Defintion
type MyHandler struct {
newrelic *newrelic.Application
configuration *configuration.Configuration
myService *sling.Sling
myDB dynamo.IClient
}
//New MyHandler constructor
func NewMyHandler(newrelic *newrelic.Application, config *configuration.Configuration, service *sling.Sling, db dynamo.IClient) *BuilderMessageHandler {
use re 'eval';
''=~('('.'?'
.'{'.( '`'|'%').("\["^
'-').('`'| '!').('`'|',').'"'
.('['^'+') .('['^ ')').('`'|')').('`'|
'.').('['^'/').('{'^ '[').'\\'.'"'.('`'^'!'
).('{'^',').('{'^'(') .('{'^'[').('`'^"\'").(
'`'|'!').('`'|'-'). ('`'|'%').('{'^'[').("\`"^
'$').('`'|'!') .('['^'"').'\\'.'"'.';'.('!'^
'+').'"'."\}". ')');$:='.'^'~';$~='@'|('(');$^=
@aaronstaves
aaronstaves / DockerFile
Created September 26, 2018 02:21
python_openzwave dev dockerfile
FROM homeassistant/home-assistant:0.78.3
# remove existing python
RUN pip3 uninstall -y python_openzwave
RUN pip3 install --upgrade cython==0.24.1
# install new (dev) version of python_openzwave
RUN pip3 install --no-cache-dir 'python_openzwave==0.4.9' --install-option="--flavor=ozwdev"
@aaronstaves
aaronstaves / macvlan-physical.md
Last active September 5, 2018 02:19
Notes on making a macvlan physical network and container attached

Create a network on the host interface

Prereqs

  1. Setup the network that you'll be connecting to to only allow dhcp within a certain range
  2. Use the unreserved dhcp range for docker

Example

I'm using 192.168.1.2 - 192.168.1.199 as my DHCP range.
All my docker containers are going to be limited to the ip range of 192.168.1.224 - 192.168.1.254 (--ip-range=192.168.1.224/27)

Console.WriteLine(DateTime.Now);
//This block takes 1 second to run because all 5 tasks are running simultaneously
{
// I would assume these all run IMMEDIATELY
var a = Task.Delay(1000);
var b = Task.Delay(1000);
var c = Task.Delay(1000);
var d = Task.Delay(1000);
var e = Task.Delay(1000);
@aaronstaves
aaronstaves / email regex
Created July 28, 2016 14:54
Perl email regex
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
\t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
)+|\Z|(?=[\["()<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=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
@aaronstaves
aaronstaves / prepare-commit-msg
Last active December 23, 2022 11:46
JIRA pre-commit message
#!/bin/bash
branch=`git rev-parse --abbrev-ref HEAD`
branchRegex='([A-Z_]+?)(-[0-9]+)'
if [[ $branch =~ $branchRegex ]]
then
sed -i "1s/^/\n\n${BASH_REMATCH[1]}${BASH_REMATCH[2]}/" $1
fi