Skip to content

Instantly share code, notes, and snippets.

View ngsilverman's full-sized avatar
👋

Nathanael Silverman ngsilverman

👋
View GitHub Profile
@ngsilverman
ngsilverman / Android_Emulator_AWS_EC2_ARM64_2022.txt
Last active January 10, 2023 19:09 — forked from atyachin/Android_Emulator_AWS_EC2_ARM64_2022.txt
Running headless android emulator on AWS EC2 Ubuntu instance (ARM64 / aarch64) - 2022
Android Emulator (ARM64) on EC2 - 2022
---------------------------------------
1. Launch EC2 ARM based Instance (a1.metal / a1.2xlarge): (16 Gb RAM, 32Gb Disk), Ubuntu Server 22.04 LTS (HVM) ARM x64
2. sudo apt update && sudo apt upgrade
3. sudo apt install default-jdk python3-pip repo python-is-python3 unzip libpcre2-dev adb
4. wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip
5. unzip commandlinetools-linux-8512546_latest.zip -d android-sdk
6. sudo mv android-sdk /opt/
7. mkdir /opt/android-sdk/cmdline-tools/latest
8. mv /opt/android-sdk/cmdline-tools/* /opt/android-sdk/cmdline-tools/latest (ignore the error)
//...
boolean isLocationAccurateEnough = newLocationAccuracy < Math.pow(previousLocationAge * 5, 1.2);
//...
/*
* This is some of the logic that decides whether to save a newly acquired
* location as part of a streamlined location history. It's a balancing act
* between freshness and accuracy.
*/
long previousLocationAge = newLocation.getTime() - previousLocation.getTime();
float newLocationAccuracy = newLocation.getAccuracy();
// Note accuracy is in meters, bigger = less accurate
boolean isLocationAccurateEnough =
@ngsilverman
ngsilverman / correlation.java
Last active November 29, 2015 17:51
Calculating a correlation on Android
/*
* We've collected a week's worth of data about ice cream consumption
* and general happiness for a particular individual
*/
double[] iceCreamPerDay = new double[] {
1, // Day one, had 1 ice cream
0, // Day two, no ice cream :(
0, // Etc
1,