View kms_encrypt_decrypt.sh
#!/usr/bin/env bash
if [ -z ${KMS_KEY_ID} ]; then
echo "KMS_KEY_ID unset! Exiting";
exit 1
fi
aws kms encrypt --key-id $KMS_KEY_ID --plaintext "hello" --output text --query CiphertextBlob > output.kms.yml
encrypted=$(<output.kms.yml)
echo "Encrypted: $encrypted"
View kms-vault
#!/usr/bin/env bash
# License: MIT - https://opensource.org/licenses/MIT
#
# Usage:
#
# Encrypt a file:
# kms-vault encrypt My-Key-Alias some-file-i-want-encrypted.txt > topsecret.asc
#
View Makefile
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
View main.scala
// make sure the receiver emails are verified:
// https://console.aws.amazon.com/ses/home?region=us-east-1#verified-senders-email:
import javax.activation.DataHandler
import javax.activation.DataSource
import javax.activation.FileDataSource
import javax.mail.Session
import javax.mail.Message
import javax.mail.MessagingException
import javax.mail.internet.AddressException
View gist:5adedf63b7ac9108453572a6351e72f6
import javax.activation.DataHandler
import javax.activation.DataSource
import javax.activation.FileDataSource
import javax.mail.Message
import javax.mail.MessagingException
import javax.mail.internet.AddressException
import javax.mail.internet.InternetAddress
import javax.mail.internet.MimeBodyPart
import javax.mail.internet.MimeMessage
import javax.mail.internet.MimeMultipart
View main.go
package main
import (
"fmt"
"sort"
)
func tokensByAscending(t []int) func(i, j int) bool {
return func(i, j int) bool {
return t[i] < t[j]
View main.go
package main
import (
"time"
"fmt"
"math/rand"
)
func Decision(probability float64) bool {
// randFloat64() returns a float64, `0.0 <= f < 1.0`
View gist:0134ac365f8b414bf2ef9e0efca150e5
cut -f1,4 -d',' freq_1483051128.csv | sort | awk -F',' '{a[$1]+=$2}END{for (i in a){print i,a[i]}}'
View main.py
import threading
import Queue
import time
QUEUE_TIMEOUT_s = 0.1
WORKER_COUNT = 200 # play with this! If switching to multiprocessing, use ncores+1 (or 2)
NUM_TASKS = 1000
SLOW_ADD_TIME_s = 0.1
done_event = threading.Event()
View main.go
package main
import (
"database/sql"
"gopkg.in/gorp.v1"
"log"
"strconv"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"