Skip to content

Instantly share code, notes, and snippets.

View evanhalley's full-sized avatar

Evan Halley evanhalley

View GitHub Profile
@evanhalley
evanhalley / scratch.java
Created December 12, 2022 17:50
Naive Leaky Bucket Algorithm Implementation
import java.util.LinkedList;
import java.util.stream.Stream;
class Scratch {
public static void main(String[] args) throws InterruptedException {
int rate = Integer.parseInt(args[0]);
int maxBucketSize = Integer.parseInt(args[1]);
LinkedList<Integer> requestStream = new LinkedList<>(Stream.of(args[2].split(","))
.map(Integer::parseInt)
.toList());
@evanhalley
evanhalley / gulpfile.js
Created March 24, 2020 18:20
Small example of using the very basics of gulp.
const { series, src, dest } = require('gulp');
const tap = require('gulp-tap');
function helloWorld(cb) {
console.log('hello world');
cb();
}
function helloWorldPromise() {
return new Promise((resolve, reject) => {
@evanhalley
evanhalley / gulpfile.js
Created March 24, 2020 18:20
Small example of using the very basics of gulp.
const { series, src, dest } = require('gulp');
const tap = require('gulp-tap');
function helloWorld(cb) {
console.log('hello world');
cb();
}
function helloWorldPromise() {
return new Promise((resolve, reject) => {
@evanhalley
evanhalley / build_deploy.yml
Created January 26, 2020 02:38
Building and deploying a Hugo generated static HTML site to Firebase hosting.
name: Build & deploy
on:
push:
branches:
- master
jobs:
build:

hello world

@evanhalley
evanhalley / TodoistCompletedTasksReport.gs
Created August 9, 2019 15:01
Google Script that uses the Todoist API to retrieve completed tasks, then builds and emails a report.
var COMPLETED_TASKS_ENDPOINT = 'https://api.todoist.com/sync/v8/completed/get_all?since=[SINCE]&until=[UNTIL]';
var EMAIL_SUBJECT = 'Todoist Completed Tasks Report for [DATE]';
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
function main() {
var yesterday = getYesterday();
var tasks = getCompletedTasks(yesterday);
if (tasks) {
processCompletedTasks(tasks, yesterday);
@evanhalley
evanhalley / verify.js
Last active August 23, 2018 07:35
Using JavaScript / Node.js to do server side IAB signature verification
var crypto = require('crypto');
// the Base64 encoded Google Play license key / Base64-encoded RSA public key from the Google Play Dev Console
var publicKey = "ABCEDF1234....";
/** sample
{
"orderId":"12999763169054705758.1371079406387615",
"packageName":"com.example.app",
"productId":"exampleSku",
package com.emuneee.tensorandflow
import android.graphics.*
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import android.graphics.Bitmap
import com.emuneee.tensorandflow.classifier.Classifier
import com.emuneee.tensorandflow.classifier.TFMobileClassifier
import com.emuneee.tensorandflow.view.CanvasView
[{
"filename": "1495332407.63.jpg",
"is_congested": -1
}, {
"filename": "1495332973.66.jpg",
"is_congested": -1
}, {
"filename": "1495333131.12.jpg",
"is_congested": -1
}, {
@evanhalley
evanhalley / generate_list.py
Created June 7, 2017 13:10
Reads a list of images in a directory then builds a JSON object representation with some additional metadata
from os import listdir
import json
files = listdir('./traffic_images')
data = []
# loop over the list of files and write it to an array
for image_file in files:
row = {}
row['filename'] = image_file