This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const path = require("path"); | |
const FILE_REGEXP = /^([a-z]+)-([a-z_]+)-.*[.]csv$/; | |
const filename = process.argv[process.argv.length - 1] || ''; | |
const basename = path.basename(filename); | |
if (!filename || !basename || !basename.match(FILE_REGEXP)) { | |
throw Error('A csv file input must be specified of the format <centreId>-<parkerType>-<date>.csv. E.g. kotara-westfield_secondary-2021-01-01.csv'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extend size of disk and then boot into vm. | |
# fix up partition size | |
sudo parted -l | |
Fix | |
# file up partition | |
sudo fdisk /dev/sda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [ns, s] = process.hrtime(); | |
const nsTime = (s * 1e6 + ns); | |
function encode(num, digits = 15, off = 0) { | |
const rand = off ? Math.random().toString(26).substring(1, 1 + off) : ''; | |
const str = (num.toString(26) + rand).split(''); | |
let input = str.map(ch => ch === '.' ? '-' : (parseInt(ch, 26) + 10).toString(36)).join('').toUpperCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// produces unique enough base36 serial based on nanosecond time | |
function makeUpgradeCode() { | |
const [nanoseconds, seconds] = process.hrtime(); | |
const time = (seconds * 1e6 + nanoseconds) | |
.toString(26) | |
.split('') | |
.map(x => (parseInt(x, 26) + 10).toString(36)) | |
.concat(Math.random().toString(10).substring(2).split('')) | |
.slice(0, 12); | |
const [a, b, c, d, e, f, g, h, i, j, k, l] = time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const EVENTS_AT_A_TIME = 10; | |
const MAX_CHECK_INTERVAL = 500; | |
const WAIT_PER_EVENT = MAX_CHECK_INTERVAL / EVENTS_AT_A_TIME; | |
export function listenToEvents(knex, table, name, callback) { | |
let lastEventId; | |
const cursor = table + "::" + name; | |
async function getCursorPosition(): Promise<number> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mysql:5.6 | |
COPY dump.sql /docker-entrypoint-initdb.d | |
RUN chmod 755 /docker-entrypoint-initdb.d/* | |
ENV MYSQL_ROOT_PASSWORD test | |
# docker build . -t db && docker run --network=host db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get("/all", USER, async function(req, res) { | |
// get summary | |
let all = await database.getContentSummary(); | |
// filter out by query | |
all = simpleFilter(all, (item: any) => item.id, req.query.id); | |
all = simpleFilter(all, (item: any) => item.type, req.query.type); | |
// filter out privates and non-configurable | |
all = all.filter((item: any) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const wildcard = require("wildcard"); | |
/** | |
* Filter an array of object by wildcard filters. | |
* | |
* @param {any[]} items list of input objects to filter | |
* @param {any=>string} field function that will return a string to filter given an input object | |
* @param {string|string[]} filters wildcard filter or filters to test. Items will be returned if any of the filters match. | |
* @return {any[]} list of filtered items | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# squash git commits | |
# https://wincent.com/wiki/Squashing_all_Git_commits_into_a_single_commit | |
git update-ref -d refs/heads/master | |
git commit -s -m shovel | |
#!/bin/bash | |
# Delete all containers | |
docker rm $(docker ps -a -q) | |
# Delete all images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* HDS File parser | |
* | |
* @todo add 64 bit value parsing. | |
*/ | |
var loadHDS = function(binary, filename) | |
{ | |
try | |
{ |
NewerOlder