Skip to content

Instantly share code, notes, and snippets.

geraldstanje

Block or report user

Report or block geraldstanje

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
@geraldstanje
geraldstanje / main.go
Created Feb 21, 2017
sorting in go 1.8
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]
@geraldstanje
geraldstanje / main.go
Created Jan 3, 2017
True or false output based on a probability
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]}}'
@geraldstanje
geraldstanje / main.py
Last active Oct 21, 2016
Basic thread pool example whipped up quickly for #python
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"
View wavelet_test.csv
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
View wavelet_test.R
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)
View wavelet_test.py
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
View gist:64f8238aa6e5233f8f5ee82bd43f0226
https://www.cs.swarthmore.edu/~turnbull/cs67/s09/labs/lab05.pdf
http://nxn.se/post/90198924975/extract-cluster-elements-by-color-in-python
https://joernhees.de/blog/2015/08/26/scipy-hierarchical-clustering-and-dendrogram-tutorial/
http://databasefaq.com/index.php/answer/205523/python-scipy-hierarchical-clustering-dendrogram-cutting-scipy-hierarchical-dendrogram-into-clusters-via-a-threshold-value
http://brandonrose.org/clustering
You can’t perform that action at this time.