Skip to content

Instantly share code, notes, and snippets.

This gist is a simple no-brainer description of the 3 ways (actually 2.5) the Web handle events.

<tag onclick />

The declarative inline HTML event listener is mostly an indirection of DOM Level 0 events, meaning this simply uses the equivalent of tag.onclick = listener behind the scene.

Example

click me
@marlun
marlun / index.js
Created December 13, 2016 20:33
Working example of selenium-webdriver and tape (I think)
test.only('Show error on missing credentials', function (t) {
t.plan(1);
browser.get('http://localhost:3000/');
browser.findElement({ className: 'login__submit' })
.click();
var error = browser.wait(Until.elementLocated({ className: 'login__error' }));
browser.wait(Until.elementIsVisible(error))
.then(function () {
t.ok(true);
});
@marlun
marlun / index.js
Created December 11, 2016 21:10
Testing with tape and selenium-webdriver (probably wrong)
test.only('Give error when username and password is missing', function (t) {
t.plan(1);
browser.get('http://localhost:3000/');
browser.findElement({ className: 'login__submit' })
.click();
browser.wait(Until.elementIsVisible(By.className('login__error')));
t.ok(true);
browser.quit();
});
@marlun
marlun / addChat.js
Last active September 20, 2016 04:14
Use less ES6
var defaults = require('lodash.defaults');
function addChat(options) {
var payload = defaults(options, {
id: cusid(),
msg: '',
user: 'Anonymous',
timeStamp: Date.now(),
});
return {
@marlun
marlun / muttrc.vim
Created April 23, 2016 13:28
Show reference manual for current word in muttrc
function! s:ShowDocForCurrentWord()
let word = expand("<cword>")
let query = substitute(word, "_", "-", "g")
echom query
let url = "http://www.mutt.org/doc/manual/#" . query
echom url
!open url
redraw!
endfunction
@marlun
marlun / index.js
Last active August 29, 2015 14:16
requirebin sketch
// hello world
var h = require('virtual-dom/h');
var stringify = require('virtual-dom-stringify');
var vnode = h('div');
console.log(stringify(vnode));
@marlun
marlun / readability.user.js
Last active July 25, 2016 02:33
Temporary fix for images not being loaded on readability.com
// On readability.com images are delivered through a secure-assets domain
// but for some reason they aren't loading. Every image is linked to their
// original source so I made this greasemonkey script which switches
// the src out for the original and it seems to work.
var imgs = document.querySelectorAll('img[src*="secure-asset"]');
for (var i = 0; i < imgs.length; i++) {
var oldImg = imgs[i];
var parentNode = oldImg.parentNode;
var newImg = new Image();
newImg.src = parentNode.href.match(/\/\/.*/)[0];
var tls = require('tls')
var fs = require('fs')
var parser = require('xml2json')
var options = {
host: 'epp.example.com',
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem'),
passphrase: 'pass'
}
var crypto = require('crypto')
var tar = require('tar')
var zlib = require('zlib')
var through = require('through')
var h = crypto.createHash('md5', { encoding: 'hex' })
var parser = tar.Parse()
parser.on('entry', function(e) {
if (e.type !== 'File') return
.include "linux.s"
.include "record-def.s"
.section .data
file_name:
.ascii "test.dat\0"
.section .bss
.lcomm record_buffer, RECORD_SIZE