Skip to content

Instantly share code, notes, and snippets.

@geraldstanje
geraldstanje / main.scala
Last active October 26, 2017 17:24
Send Email from AWS SES using Smtp
// 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
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
@geraldstanje
geraldstanje / main.go
Created February 21, 2017 17:27
sorting in go 1.8
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]
@geraldstanje
geraldstanje / main.go
Created January 3, 2017 20:10
True or false output based on a probability
package main
import (
"time"
"fmt"
"math/rand"
)
func Decision(probability float64) bool {
// randFloat64() returns a float64, `0.0 <= f < 1.0`
cut -f1,4 -d',' freq_1483051128.csv | sort | awk -F',' '{a[$1]+=$2}END{for (i in a){print i,a[i]}}'
@geraldstanje
geraldstanje / main.py
Last active October 21, 2016 16:10
Basic thread pool example whipped up quickly for #python
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()
package main
import (
"database/sql"
"gopkg.in/gorp.v1"
"log"
"strconv"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
33.5827844 -0.837060000000001 3.367104
33.5827844 -0.822270000000003 3.344952
33.5827844 -0.807480000000002 3.344952
33.5917065 -0.837060000000001 3.363412
33.5917065 -0.851850000000002 3.37818
33.5917065 -0.837060000000001 3.381872
33.5917065 -0.866640000000004 3.400332
33.5917065 -0.911010000000001 3.422484
33.6006286 -0.881430000000002 3.418792
33.6006286 -0.911010000000001 3.45202
library(wavelets)
load_data <- function(filename, row) {
data = read.csv(filename, header=FALSE, sep=",")
return(data[[row]])
}
wavelet_transform <- function(data) {
Wavelet_out = matrix(0, 1, 8)
import pywt
import csv
import pandas as pd
import numpy as np
def read_csv(filename):
columns = defaultdict(list) # each value in each column is appended to a list
with open(filename) as f:
reader = csv.DictReader(f) # read rows into a dictionary format