Skip to content

Instantly share code, notes, and snippets.

View n2p5's full-sized avatar

Nathan Toups n2p5

View GitHub Profile
@n2p5
n2p5 / gist:655d8bbecb285509a804
Created December 10, 2014 20:14
craft-allow
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
@n2p5
n2p5 / gist:30e36f9595cf9ae9ca0c
Last active August 29, 2015 14:15
pull name and email from parse and send to zopim (no error checking)
var currentUser = {
'firstName': Parse.User._currentUser.get("firstName"),
'lastName': Parse.User._currentUser.get("lastName"),
'email' : Parse.User._currentUser.getEmail(),
'fullName': function() {return this.firstName + " " + this.lastName}
};
$zopim.livechat.setName(currentUser.fullName());
$zopim.livechat.setEmail(currentUser.email);
@n2p5
n2p5 / keybase.md
Last active June 25, 2016 22:21
keybase.md

Keybase proof

I hereby claim:

  • I am rjrbt on github.
  • I am rjrbt (https://keybase.io/rjrbt) on keybase.
  • I have a public key ASD2lQc2rKmx7Qt9EiZhTqGyjMhLkSL2UKbo3tNAwlGw-wo

To claim this, I am signing this object:

@n2p5
n2p5 / grab-version.sh
Last active December 14, 2016 06:38
grab version number from package.json in the bash shell
# grab the version number from package.json
awk '/version/{ gsub(/"|[",]/,""); print $2; exit;}' package.json
@n2p5
n2p5 / 10digitprimes.go
Created September 3, 2020 00:30
calc all 10 digit primes
package main
import (
"fmt"
"math/big"
"sync/atomic"
)
func main() {
start := 1000000001
@n2p5
n2p5 / remove-delete-marker-s3.sh
Created September 30, 2020 04:33
undelete s3 objects that are marked for delete from versioned s3
aws s3api list-object-versions \
--bucket "${BUCKET}" \
--prefix "${PREFIX}" \
--output text | grep "DELETEMARKERS" | while read obj
do
KEY=$( echo "${obj}"| awk '{print "${3}"}')
VERSION_ID=$( echo "${obj}" | awk '{print "${5}"}')
echo "${KEY}"
echo "${VERSION_ID}"
aws s3api delete-object \
@n2p5
n2p5 / list_nested_dict_toy.py
Last active October 24, 2020 05:38
Toy recursive function that turns a list of keys and a value into a nested dict
"""
This is a toy version of recursive function I wrote to update a value in an arbitrary
place in a nested dictionary.
I originally wrote something similar to this to handle writing to a TOML file
so that I could use a CLI tool such as
`my_tool set a.b.c.d hello` and it would write:
[a]
[a.b]
[a.b.c]
@n2p5
n2p5 / go_func_yourself.go
Created May 24, 2021 20:21
go func() { your <- self }()
package main
import "fmt"
func main() {
your := make(chan func(), 1)
go func() { your <- self }()
(<-your)()
}
@n2p5
n2p5 / entropy.go
Last active June 30, 2023 14:43
Shannon Entropy example from a post on Functionally Imperative found here: https://functionallyimperative.com/t/entropy
// Shannon Entropy example from a post on Functionally Imperative
// https://functionallyimperative.com/t/entropy
package main
import (
"crypto/rand"
"fmt"
"math"
)