Skip to content

Instantly share code, notes, and snippets.

View Valve's full-sized avatar
🏠
Working from home

Valve

🏠
Working from home
  • Fingerprint.com
  • Chicago, USA
View GitHub Profile
@Valve
Valve / jwt.go
Last active September 18, 2024 14:32
Generate JWT token in Go without using 3rd party libraries
header := encodeSegment([]byte(`{"alg":"HS256","typ":"JWT"}`))
// token is valid for 60 seconds
payloadJSON := fmt.Sprintf(`{"userId":"2718281828459","iat":%d}`, time.Now().Add(60*time.Second).Unix())
payload := encodeSegment([]byte(payloadJSON))
key := "secret"
hmac := hmac.New(sha256.New, []byte(key))
hmac.Write([]byte(header + "." + payload))
signature := encodeSegment(hmac.Sum(nil))
token := header + "." + payload + "." + signature
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Usage: $0 <host> <port> <pattern> <seconds>"
exit 1
fi
cursor=-1
keys=""
<script async src="https://yourdomain.fpjs.pro/fp.js"></script>
<script>
window.fpLayer = window.fpLayer || [];
function fp() { fpLayer.push(arguments); }
fp('config', 'client', 'client-id');
// if you want to send data
// automatically on page load
fp('config', 'autoSend', true);
</script>
@Valve
Valve / sixpack-production-setup.md
Last active February 4, 2017 20:32
Sixpack, Gunicorn, Nginx, Supervisord, Ubuntu setup

1. Create a new EC2 instance, add TCP ports 22, 80 and 8080 to the security group

2. I did everything on Ubuntu 14.04.2 server 64bit
3. Log in
sudo apt-get update
sudo apt-get upgrade

redis