Skip to content

Instantly share code, notes, and snippets.

@Sebmaster
Sebmaster / domains-by-async.js
Last active October 4, 2017 16:42
How domains can be emulated with async_hooks
const hooks = async_hooks.create()
setTimeout(() => { // some async task
setImmediate(() => { // another one
throw new Error(); // woops!
})
}, 1000)
/*
With hooks:
"use strict";
const conversions = require("webidl-conversions");
const Impl = require("../implementation/EventTarget.js");
const initialized = require("./utils.js").initialized;
class EventTarget {
constructor() {
if (arguments[0] !== module.exports.secret && !this[initialized]) {
@Sebmaster
Sebmaster / urltestdata.txt
Created July 10, 2015 01:57
platform-tests
# FORMAT NOT DOCUMENTED YET (parser is urltestparser.js)
# Based on http://trac.webkit.org/browser/trunk/LayoutTests/fast/url/script-tests/segments.js
http://example\t.\norg http://example.org/foo/bar s:http h:example.org p:/
http://user:pass@foo:21/bar;par?b#c s:http u:user pass:pass h:foo port:21 p:/bar;par q:?b f:#c
http:foo.com s:http h:example.org p:/foo/foo.com
\t\s\s\s:foo.com\s\s\s\n s:http h:example.org p:/foo/:foo.com
\sfoo.com\s\s s:http h:example.org p:/foo/foo.com
a:\t\sfoo.com s:a p:\sfoo.com
http://f:21/\sb\s?\sd\s#\se\s s:http h:f port:21 p:/%20b%20 q:?%20d%20 f:#\se
@Sebmaster
Sebmaster / Output
Last active August 29, 2015 14:20
JS weirdness
%00.com
%00.com
exec 7 %00.com %00.com 7 %00.com
exec3
@Sebmaster
Sebmaster / gist:336574d2d07f0bd753e5
Last active August 29, 2015 14:20
WHATWG-URL respec
"use strict";
const URL = require("../lib/url").URL;
console.log(
new URL("/", "file:///C:/Users/Domenic/Dropbox/Programming/GitHub/jsdom/test/jsdom/index.js").href
); // file:///C:/
> new URL("http://a.com", "about:blank").parsedURL
{ scheme: 'http',
scheme_data: '',
username: '',
password: null,
host: 'a.com',
port: '',
path: [ '' ],
query: null,
fragment: null,
@Sebmaster
Sebmaster / Document.js
Last active August 29, 2015 14:03
jsdom new structure
var WeakMap = require("weak-map");
var utils = require("./utils");
var Node = require("./Node");
var instances = new WeakMap();
function Document() {
throw new TypeError("Illegal constructor");
}
utils.inherits(Document, Node.Node);
@Sebmaster
Sebmaster / keybase.md
Created April 11, 2014 21:44
keybase.md

Keybase proof

I hereby claim:

  • I am sebmaster on github.
  • I am sebmaster (https://keybase.io/sebmaster) on keybase.
  • I have a public key whose fingerprint is 493C C4FB CE67 6003 1CF2 993C 0F90 E025 C735 E038

To claim this, I am signing this object:

@Sebmaster
Sebmaster / Azure-Copy-Used-Blob.ps1
Last active December 22, 2015 04:28
A script to allow copying blobs which are currently in use
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$SrcStorageAccount,
[Parameter(Mandatory=$True)]
[string]$SrcStorageKey,
[Parameter(Mandatory=$True)]
[string]$SrcContainer,
@Sebmaster
Sebmaster / Ctrl.js
Created April 25, 2013 07:10
Integrate racer.js into an angular application
angular.module('MyApp', ['racer.js']).
config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
//$locationProvider.html5Mode(true);
$routeProvider.
when('/', { templateUrl: 'partials/home.htm', controller: IndexCtrl, resolve: IndexCtrl.resolve })
otherwise({redirectTo: '/'});
}]);
function Ctrl($scope, model) {