Skip to content

Instantly share code, notes, and snippets.

Eric Jain ejain

Block or report user

Report or block ejain

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
@ejain
ejain / emfitqs.py
Created Jan 31, 2017
Retrieves sleep presence records from Emfit QS, and merges the records into a single spreadsheet.
View emfitqs.py
import io, re, requests, sys, time, zipfile
def get_device(token):
r = get("/api/v1/user/get", token)
device = r.json()["user"]["devices"]
print("Device: " + device, file = sys.stderr)
return device
def list_presences(token, device):
r = get("/v4/presence/{0}/latest".format(device), token)
@ejain
ejain / panel.txt
Created Jan 13, 2017
Arivale's clinical blood tests (as of August 2016)
View panel.txt
Homocysteine (serum)
Total cholesterol
LDL
LDL particle number
LDL small particle number
LDL size
Oxidized LDL
HDL
HDL particle number
Triglycerides
@ejain
ejain / AV15-xxxx.otuTable.tsv
Last active Jan 27, 2016
Converts Second Genome data files to a uBiome taxonomy file.
View AV15-xxxx.otuTable.tsv
dnOTU_15 AV15-1068 16733
dnOTU_16 AV15-1068 20403
dnOTU_17 AV15-1068 32939
@ejain
ejain / flights.groovy
Last active Dec 25, 2015
Concatenates tracklogs from FlightAware for import into Google Fusion Tables.
View flights.groovy
import groovy.xml.MarkupBuilder
new MarkupBuilder().kml(xmlns : 'http://www.opengis.net/kml/2.2') {
Document() {
new File(args?.size() ? args[0] : '.').eachFileMatch(~/.*\.flight\.kml/) { file ->
new XmlParser().parse(file).Document.Placemark.each { placemark ->
placemark.Point.each { point ->
Placemark {
name(placemark.name.text())
Point {
@ejain
ejain / LoopBenchmark.java
Last active Aug 29, 2015
A JMH microbenchmark comparing the performance of different looping constructs.
View LoopBenchmark.java
package benchmark;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
@ejain
ejain / SortBenchmark.java
Created Dec 18, 2014
A JMH microbenchmark comparing sorting performance on Ints.asList vs an actual List.
View SortBenchmark.java
package benchmark;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
@ejain
ejain / SyncBenchmark.java
Last active Aug 29, 2015
A JMH microbenchmark to determine how a JVM is optimizing calls to synchronized methods.
View SyncBenchmark.java
package benchmark;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
@ejain
ejain / ArithmeticBenchmark.java
Created Dec 10, 2014
A JMH microbenchmark to determine if a JVM is optimizing divisions by two.
View ArithmeticBenchmark.java
package benchmark;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
@ejain
ejain / gist:9522320
Created Mar 13, 2014
Block all IPs that requested a specific file, temporarily.
View gist:9522320
sudo grep xmlrpc /var/log/apache2/access.log \
| cut -d' ' -f1 | sort | uniq \
| xargs -I{} sudo iptables -A INPUT -s {} -j DROP
@ejain
ejain / build.g
Created Nov 15, 2013
Converts a directory of GPX files into a single KML file for import into Google Fusion Tables; includes some metadata based on the file name.
View build.g
import groovy.xml.MarkupBuilder
new MarkupBuilder().kml(xmlns : 'http://www.opengis.net/kml/2.2') {
new File(args?.size() ? args[0] : '.').eachFileMatch(~/.*\.gpx/) { file ->
new XmlParser().parse(file).trk.each { trk ->
trk.trkseg.each { trkseg ->
def geo = ""
trkseg.trkpt.each { trkpt ->
geo += "${trkpt.'@lon'},${trkpt.'@lat'}\n"
}
You can’t perform that action at this time.