Skip to content

Instantly share code, notes, and snippets.

View rhalff's full-sized avatar

Robbert Halff rhalff

  • Robbert Halff
  • Netherlands
View GitHub Profile
@rhalff
rhalff / Canvas Clock
Last active August 29, 2015 13:57
Clock
title: Clock
DomImage(dom/image),DomQuerySelector(dom/querySelector),DomSetHtml(dom/setHtml),CanvasGetContext(canvas/getContext),CanvasDrawImage(canvas/drawImage),DomQuerySelector2(dom/querySelector),MathDegreesToRadians(math/degreesToRadians),DateCreate(date/create),DateGetSeconds(date/getSeconds),CanvasBeginPath(canvas/beginPath),CanvasMoveTo(canvas/moveTo),CanvasLineTo(canvas/lineTo),CanvasLineTo2(canvas/lineTo),CanvasLineTo3(canvas/lineTo),CanvasLineTo4(canvas/lineTo),CanvasStroke(canvas/stroke),MathMultiply(math/multiply),CanvasRotate(canvas/rotate),CanvasSetAttributes(canvas/setAttributes),CanvasFill(canvas/fill),CanvasTranslate(canvas/translate),UtilWait(util/wait),ConsoleLog(console/log),CanvasStrokeText(canvas/strokeText),CanvasSave(canvas/save),ConsoleLog2(console/log),DomAddMouseEvent(dom/addMouseEvent),DomAlert(dom/alert),DateCreate2(date/create),CanvasRestore(canvas/restore),CanvasSetAttributes2(canvas/setAttributes),SoundAlert(sound/alert)
"http://www.dhtmlgoodies.com/tutorials/canvas-clock/i
@binzhang
binzhang / about.md
Created November 8, 2011 13:47 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@inakiabt
inakiabt / extjs-capture.js
Created March 20, 2012 22:42 — forked from revolunet/extjs-capture.js
ExtJs debug : capture all events
// to capture ALL events use:
Ext.util.Observable.prototype.fireEvent = Ext.Function.createInterceptor(Ext.util.Observable.prototype.fireEvent, function(evt) {
var a=arguments;
console.log(this,' fired event ',evt,' with args ',Array.prototype.slice.call(a,1,a.length));
return true;
});
// to capture events for a particular component:
Ext.util.Observable.capture(
Ext.getCmp('my-comp'),
  • Distributed database with content-addressable values
  • Node types are blobs and trees.
  • Hashes use a secure hash (not sha1) since distributed p2p systems contain many untrusted nodes. (Or we could let security be a concern of a higher-level and just use this for the hard network scale problem)
  • The actual named refs can still be in a central server with user authorization. Making that secure in a distributed system is considerably harder.

For example, suppose I wanted to download the package foo at the version ~0.2.3. My package client would go to the central ref server and query the tags of foo. It would then see that foo has versions 0.2.3, 0.2.4, and 0.3.0. It would decide that 0.2.4 is the desired version based on the original range query. Along with the refs the central server also told it the hashes of the root tree node for these package versions. It now knows which hash contains the desired package.

Now to get the package, we need to query the distributed network for t

(function(){
"use strict";
Array.prototype.clean = function() {
for (var i = 0; i < this.length; i++) {
if (this[i] == null) {
this.splice(i, 1);
i--;
}
}

Accessing data through APIs

Update: my blog post The lie of the API details the issues with current APIs.

Background: I'm a researcher in semantic hypermedia, at the moment comparing different APIs for accessing metadata for human and machine consumption.

Story: I am browsing a cultural website and want to retrieve the metadata of the object I'm looking at in a machine-readable format. The steps below are the actual steps that I've undertaken on different sites.

Example: Cooper-Hewitt museum

I'm looking at the object http://collection.cooperhewitt.org/objects/35460799/.

// d8 --expose-gc --allow-natives-syntax --track-retaining-path weak-value-retaining-path.js
class SomeKey {
}
class Metadata {
constructor() {
this.large = new LargeObject();
}
}
@jtbonhomme
jtbonhomme / forkStream.js
Created September 13, 2016 14:36
This gist shows how to fork a nodejs stream into 2 streams
var spawn = require('child_process').spawn;
var pass = require('stream').PassThrough;
var a = spawn('echo', ['hi user']);
var b = new pass;
var c = new pass;
a.stdout.pipe(b);
a.stdout.pipe(c);
@JamieMason
JamieMason / migrate-to-lerna.sh
Last active April 25, 2019 18:58
Bash script to migrate multiple projects into one Lerna monorepo (https://lernajs.io)
#!/usr/bin/env bash
set -x
shopt -s extglob dotglob
cd "$HOME"
rm -rf "$HOME/TEMP_DIR"
mkdir "$HOME/TEMP_DIR"
cd "$HOME/TEMP_DIR"
git init
@shivampandey0
shivampandey0 / main.dart
Created August 15, 2019 16:11
Simple code snippet for Indian Flag (Add ashok_chakra.png in assets)
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: HomeScreen(),
));
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();