Skip to content

Instantly share code, notes, and snippets.

View alexdunae's full-sized avatar

Alex Dunae alexdunae

View GitHub Profile
@alexdunae
alexdunae / day01.cr
Last active December 2, 2021 19:51
Advent of Code 2021 Ruby vs Crystal
file = "input.txt"
increases = 0
last_window = nil
a = nil
b = nil
c = nil
File.each_line(file) do |measurement|
@alexdunae
alexdunae / README.md
Last active September 21, 2021 01:58

BC COVID-19 Vaccine Passport

BC's COVID-19 vaccine passport is encoded as a JSON web token following the SMART Health Card open spec.

I made a little write up about how to decode the data.

Vax codes

You can inspect the http://snomed.info/sct coding key to see which type of vaccines were recorded:

import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
const EventSalesReport = props => {
const [open, setOpen] = useState(false);
const [count, setCount] = useState(0);
console.log(`render: open is ${open}`);
const handleDocumentClick = function(event) {
@alexdunae
alexdunae / ReactNativeJson.java
Last active May 13, 2018 18:04 — forked from viperwarp/ReactNativeJson.java
React-Native Module, ReadableMap/Array to Java JSON objects
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
<?php
add_action( 'rest_api_init', function () {
register_rest_route( 'salmon/v1', '/salmonnames', array(
'methods' => 'GET',
'callback' => 'get_salmon_names',
) );
} );
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# from https://github.com/drKreso/guerrilla_patch
class Allocate
attr_accessor :amount
attr_accessor :ratios
def self.evenly(amount, number_of_slices)
Allocate.new.tap do |a|
a.amount = amount
a.ratios = (1..number_of_slices).map { 1.to_d/number_of_slices }
end.divided