Skip to content

Instantly share code, notes, and snippets.

@kathawala
kathawala / simpsons_places_test_data.json
Created January 3, 2021 19:17
Some example place data which can be used in a mapping application, includes fun details about the places (all little jokes from The Simpsons) as well as the places' latitude and longitude (just random spots in SF)
[
{
"name": "Turban Outfitters",
"description": "Headgear for the fashion-forward man. Located at Springfield Squidport",
"info": "Clothing Store",
"address": "Unit #234, Springfield Squidport, opposite Barney's Bowlarama",
"imageURI": "./assets/turban_outfitters.png",
"products": [
{
"name": "Beard Oil",
@kathawala
kathawala / datetime_to_cron.py
Created April 21, 2020 22:23
Converts a python datetime to a crontab expression which fires once (at the date+time specified in the python datetime object)
from datetime import datetime
def datetime_to_cron(dt):
# FYI: not all cron implementations accept the final parameter (year)
return f"cron({dt.minute} {dt.hour} {dt.day} {dt.month} ? {dt.year})"
@kathawala
kathawala / gpu_keccak.js
Created August 30, 2017 19:20
Works fully, all rounds, all inputs
// requires "webgl.js" file for webgl utilities like "createProgramWithShaders"
// areas for speedup: using uniform buffers | replacing keccakf_rndc texture with
// a uniform that changes each round
"use strict";
const KECCAK_ROUNDS = 24;
var theta_chi = new Int8Array([ //RGBA8I
4, 1, 1, 2,
@kathawala
kathawala / webgl.js
Created August 30, 2017 19:20
WebGL utilities
"use strict";
function setupWebGLFromCanvas(canvas) {
var gl = canvas.getContext("webgl2");
if (!gl) {
console.log("ERROR: canvas.getContext('webgl2'); failed, perhaps no webgl2 enabled...");
return null;
}
return gl;
}
@kathawala
kathawala / gpu_keccak.js
Created August 27, 2017 22:53
Works all 24 rounds without paddin (essentially just keccakf)
"use strict";
const KECCAK_ROUNDS = 24;
var input = new Uint32Array([
1063097118, 728099034, 2853146927, 1330851092, 209328888,
904790539, 786070775, 1411619771, 1176535054, 1708240850,
1280969794, 3252320020, 3814437729, 900990975, 3404197392,
3203136532, 317488412, 1753212407, 1201418786, 3729619196,
1635356607, 2938933362, 3579979232, 3308551012, 3620133985,
@kathawala
kathawala / js_keccak.js
Created August 26, 2017 14:43
Fully works for all rounds
// TODO: Finish this up, test speed vs GPU vs emscripten transpiled C->asm.js
// Currently looking at the keccak function, which is given as input:
// input - in our case the "caveat emptor" string
// inlen - length of input = 13
// md - the buffer of 200 bytes we want to fill up
// stlen - length of uint64_t array with 25 elements = 200 bytes
// ( aka: output length we desire )
// Reading through the code there is:
// a temp buffer of 144 bytes
#include <stdio.h>
#include <stdint.h>
#include <emmintrin.h>
void print128_num(__m128i var)
{
int64_t *v64val = (int64_t*) &var;
printf("%.16lld %.16lld\n", v64val[1], v64val[0]);
}
This file has been truncated, but you can view the full file.
[INFO ] Performing some trivial sanity checks
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
[DEBUG] Testing '! ( -n )'
DEPARTMENT OF PUBLIC HEALTH AND HUMAN SERVICES 3453120796.51963
DEPARTMENT OF ADMINISTRATION 1983264368.54001
DEPARTMENT OF REVENUE 1188770273.22
DEPARTMENT OF TRANSPORTATION 1155573633.10006
OFFICE OF PUBLIC INSTRUCTION 386687157.71
MONTANA STATE FUND 369182943.830003
DEPARTMENT OF LABOR AND INDUSTRY 355608948.120002
DEPARTMENT OF COMMERCE 314240103.909999
COMMISSIONER OF HIGHER EDUCATION 272604043.789999
DEPARTMENT OF CORRECTIONS 249557846.739999
DEPARTMENT OF PUBLIC HEALTH AND HUMAN SERVICES 64452167.7
DEPARTMENT OF MILITARY AFFAIRS 48257568.71
DEPARTMENT OF TRANSPORTATION 35059150.2999999
DEPARTMENT OF COMMERCE 23508309.5
DEPARTMENT OF REVENUE 23050949.27
OFFICE OF PUBLIC INSTRUCTION 21802641.8
DEPARTMENT OF ADMINISTRATION 18824438.3
DEPARTMENT OF LABOR AND INDUSTRY 13225353.4
MONTANA STATE FUND 10814640.2
COMMISSIONER OF HIGHER EDUCATION 6793189.5