Skip to content

Instantly share code, notes, and snippets.

ゴッド 2.0 nahidakbar

  • CSIRO Data61
  • Sydney, Australia
Block or report user

Report or block nahidakbar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:c9a5ff1e743fa048d80e3b61298e23ad
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> {
View MySQL docker
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
View gist:8af43d5b84e5b7f323513a1d314b8a25
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) => {
View simpleFIlter
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
*/
View gist:b24bd8f3de5f1854db32
# 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
View gist:e28bd7507bd8c9033eb1
/**
* HDS File parser
*
* @todo add 64 bit value parsing.
*/
var loadHDS = function(binary, filename)
{
try
{
View gist:d2248dbb2c8411e03034
function Uint8ArrayListWriter(contentSize, filename)
{
var output, that = this, offset, errored;
function init(callback)
{
output = [];
offset = 0;
@nahidakbar
nahidakbar / gist:b3c26ddeb1f36c3f82ae
Last active Aug 29, 2015
ArrayBufferWriter for zip.js
View gist:b3c26ddeb1f36c3f82ae
/**
* @class custom Writer; zipjs one breaks in chrome for large binary files
*/
function ArrayBufferWriter(contentSize, filename)
{
var output, that = this, offset, errored;
function init(callback)
{
output = new Uint8Array(contentSize);
@nahidakbar
nahidakbar / gist:4dd4e3ae2eb40954f0f6
Last active Aug 29, 2015
Options/Software/Singleton/singleton.js
View gist:4dd4e3ae2eb40954f0f6
/**
* @author Nahid Akbar
* @date 19/10/14
*/
"use strict";
var singleton = function(BaseClass, instanceParent, instanceVarName)
{
instanceParent = instanceParent !== undefined ? instanceParent : BaseClass;
instanceVarName = instanceVarName !== undefined ? instanceVarName : 'instance';
return function()
View encoding decoding cells into a single number inside fixed dimension discrete rectangular grid
var dx = 10;
var dy = 10;
var dz = 3;
var decode = function(v)
{
var z = v % dz;
var xy = (v - z) / dz;
var y = xy % dy;
var x = (xy - y) / dy;
You can’t perform that action at this time.