Skip to content

Instantly share code, notes, and snippets.

@cjc
cjc / mutationobserver-watch-attributes-of-children.htm
Created July 19, 2021 11:13
A reliable (probably) utility for watching attribute changes on immediate children of a dom element
<h1>Watch attribute changes of the immediate children of an element</h1>
<p>Utility for easily watching for attribute changes of the immediate children of a given element without paying the performance penalty of <code>subtree</code></p>
<ul>
<li>On startup, watches any existing children of the asset for attribute changes</li>
<li>Also watches for changes to the childlist of the asset</li>
<li>When a new asset is added to the asset, starts observing it for attribute changes</li>
</ul>
@cjc
cjc / simple-shadow-dom-slot.htm
Last active July 17, 2021 10:54
Webcomponent reference and boilerplates
<test-component>
<span>Slotted</span>
</test-component>
<!-------------------------->
<template id="test">
<style>
:host {
display:inline-block;

#A

http image

or

![inline image](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAACW9GRnMAAAAAAAAABQCnXUKLAAAACXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAwAAAAOgA0AWTdAAAUgUlEQVRo3p2ZeXRUdZbHP++92quSqiyVylJZSQgQQhISVlkDyCK0oijgOi2totM9vWhvYy+0bS+K3dPtNt16psUFV0RABxRlVRAIBEiAQCCBbGRfKkvt7/3mj4RADIjO75x36pyqV/d37/d+7/397r2SCHcKrrckidaLNXy64RUWrfge7773IX//2ws47BGUlp0hrGpI1xUydImBZ/b0Cax5/PtYjTrSRuVhdyYifQtpyprf/GLNdd+SZUr3buPogX10h/Q8++xL3H33cqZNm8L2T/cQVtVvbcCl9+samjh95gJdPV7OnDqJ3mAkKSUVNA2k60vVfZPNwn4fBoOB9HE38LOfP0FLeydNjY28884HeAPBb638lUaoqsa+Q0fZd+goAlhacoJ/vTYGe3QsqOHry/haCgkBkoSQJIQaYu0f/oSnq5PjZWf4ZNf+fuf8P5UfttUlRHUKtyy5kQce/C43zJiBXq9HU8MoOj3SVTwyfH/RL0pIEkgSfp+XXdu3s+5/1lF2vJzCokJq6y8i4LrICyB8hXLX84YEhMMq736wjdtuu5dn/ryWjpZ6Th/9Ak9781V3HEqhAcRVNUxrw3kcMXFUV9ewevWPOF9zkaR4J5IEdfWNyFcRdykwpYHPSJuFMaOzqKg4S3ev9xtRTQIUoMfr589rn6e1tY07l91Ic/15HM6EYWgM9YAkIYSgtrKMXk8nBpOFYDCIpmpoQH1

$ node test.js
cjcbufferprotoprop
cjcstringprotoprop
cjcdateprotoprop
$ node
> require('./proto')
{}
> new Buffer(1).cjc
'cjcbufferprotoprop'
> new String('1').cjc
@cjc
cjc / testjson
Created January 22, 2011 04:53
Test json for youtube subsection playback instructions
{
videoId : 'zweomSUBfjA',
segments: [
{from:'5s',for:'5s'},
{from:'0s',for:'18s'}
]
}
@cjc
cjc / sha256.js
Created October 16, 2010 08:19
SHA256 tests
var crypto = require("crypto"),
assert = require("assert");
assert.equal(
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
crypto.createHash("sha256").update("").digest("hex"))
assert.equal(
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad',
crypto.createHash("sha256").update("abc").digest("hex"))
var crypto = require("crypto"),
assert = require("assert");
var hexstr2bytearray = function(str) {
var bytestrs = [];
for(var i=0;i<str.length;i+=2) {
bytestrs.push(str.substr(i,2));
}
return eval("[0x" + bytestrs.join(",0x") + "]");
}
@cjc
cjc / wuh
Created September 12, 2010 02:50
@eeebox:~/webshell$ npm ls xml
npm info it worked if it ends with ok
npm info version 0.2.0
npm ERR! Error: Failed to make /usr/local/lib/node/.npm/.tmp while ensuring /usr/local/lib/node/.npm/.tmp
npm ERR! EACCES, Permission denied '/usr/local/lib/node/.npm/.tmp'
npm ERR! at MKDIRCB (/usr/local/lib/node/.npm/npm/0.2.0/package/lib/utils/mkdir-p.js:33:29)
npm ERR! at cb (/usr/local/lib/node/.npm/npm/0.2.0/package/lib/utils/graceful-fs.js:28:9)
npm ERR! at node.js:769:9
npm ERR! try running: 'npm help ls'
npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
root@eeebox:~/google_appengine# apt-get install python2.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python2.5 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python2.5-minimal
E: Package python2.5 has no installation candidate