Skip to content

Instantly share code, notes, and snippets.

Michael Ficarra michaelficarra

Block or report user

Report or block michaelficarra

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 index.js
const safeApply = Date.call.bind(Date.apply);
const randomName = () => Math.random().toString(36).slice(2).toLowerCase();
class RevokedCapabilityException extends Error {}
class Capability {
constructor(behaviour, { name = randomName() } = {}) {
this.behaviour = behaviour;
this.name = Object.freeze([].concat(name));
}
@michaelficarra
michaelficarra / SetUsingHashCode.js
Last active Jun 10, 2017
Set using hashCode via ECMAScript interfaces proposal
View SetUsingHashCode.js
// https://github.com/michaelficarra/ecmascript-interfaces-proposal
interface HasHashCode {
hashCode;
}
class SetUsingHashCode extends Set {
constructor(iterable) {
super();
this.#map = new Map;
for (let x of iterable) {
View purescript#2434.diff
diff --git c/purescript.cabal i/purescript.cabal
index 4f4fcabd..699e8440 100644
--- c/purescript.cabal
+++ i/purescript.cabal
@@ -231,6 +231,7 @@ library
Language.PureScript.Sugar.TypeClasses
Language.PureScript.Sugar.TypeClasses.Deriving
Language.PureScript.Sugar.TypeDeclarations
+ Language.PureScript.Terms
Language.PureScript.Traversals
@michaelficarra
michaelficarra / append-template-tag.js
Created May 30, 2016
chainable template tag for joining a bunch of strings over many lines
View append-template-tag.js
function append(separator) {
return typeof separator === "string" ? appender(separator, "") : appender("", "").apply(this, arguments);
}
function appender(separator, s) {
return function tag(literalParts, ...computedParts) {
s += literalParts[0];
for (let i = 1; i < literalParts.length; ++i) {
s += computedParts[i - 1] + literalParts[i];
}
@michaelficarra
michaelficarra / getGlobal.js
Last active Jun 2, 2016
get the global object as reliably as possible
View getGlobal.js
var getGlobal = (function(g) {
if (g == null) {
if (typeof System !== 'undefined' && System != null && System.global != null && System.global.System === System) g = System.global;
else if (typeof self !== 'undefined' && self != null && self.self === self) g = self;
else if (typeof window !== 'undefined' && window != null && window.window === window) g = window;
else if (typeof global !== 'undefined' && global != null && global.global === global) g = global;
}
return function() { return g; };
}(this));
View es2016-normative-changes.txt
commit e6284b9bd6977ca282bdf13d13fab4d8bf6be71b
Normative: Add [?Yield] to PropertyName in AssignmentProperty
commit f0ef98ae9ecdfd1ed1e14721e795f6188a3107ee
Normative: Fix yield * semantics when calling .throw
commit 6ba35eb8fb9aad699efdd1766c52bc9f6401d039
Normative: update Annex B regexp grammar
commit d96e60a99a40fab2de0df329b3e5445ac27b8a8e
Normative: Remove [[Enumerate]] and associated reflective capabilities
commit 24dad16327b7cbbdf67805e45e58c54abe558f63
Normative: Require Unicode 8.0.0
View gist:4f8c25a6aaa87420803a
$ eshost host --list
┌──────────────┬─────────┬──────────────────────────────────────────────────┬──────┐
│ name │ type │ path │ args │
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤
│ nashorn │ nashorn │ /usr/java/jdk1.8.0_66/bin/jjs │ │
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤
│ v8 │ d8 │ /usr/bin/d8 │ │
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤
│ jsc │ jsc │ /usr/bin/jsc │ │
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤
@michaelficarra
michaelficarra / rt.js
Last active Feb 1, 2016
Rotten Tomatoes ratings exfiltrator
View rt.js
console.log(JSON.stringify([].map.call(document.querySelectorAll('.content_body .media-body'), function(ratingEl){
return {
title: ratingEl.childNodes[3].childNodes[1].textContent,
year: parseInt(ratingEl.childNodes[3].childNodes[2].textContent.slice(1, -1), 10),
rt_link: ratingEl.childNodes[3].childNodes[1].href,
rating: 20 * ratingEl.childNodes[5].querySelectorAll('.glyphicon-star').length + (/½/.test(ratingEl.childNodes[5].textContent) ? 10 : 0),
};
}).sort(function(a, b){ return a.title > b.title ? 1 : -1; })));
View es6-fd-block-scoping.js
(function () {
var g, h;
function x() { f = ""; /* var-scoped f gets value "" */ }
function y() { g = f; /* g gets value of var-scoped f */ }
{
/* var-scoped f is undefined, let-scoped f is a function */
h = f; /* h gets value of let-scoped f, a function */
f = 1; /* let-scoped f gets value 1 */
x();
y();
@michaelficarra
michaelficarra / pseudo-privates.es5.js
Last active Oct 12, 2015
pseudo-private methods using a capabilities-based approach
View pseudo-privates.es5.js
var ClassName = (function() {
var PRIVATE = {};
function ClassName(state) {
this.state = state;
}
ClassName.prototype.publicMethod = function publicMethod() {
this.privateMethod(PRIVATE, "...");
};
You can’t perform that action at this time.