Skip to content

Instantly share code, notes, and snippets.

View WebReflection's full-sized avatar
🎯
Focusing

Andrea Giammarchi WebReflection

🎯
Focusing
View GitHub Profile
@endolith
endolith / Has weird right-to-left characters.txt
Last active May 23, 2024 11:02
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@WebReflection
WebReflection / mutations.js
Created January 13, 2012 07:09
DOM MutationEvent Feature Detection
var mutations = (function (document) {
// (C) WebReflection - Mit Style License
var
type = [
"DOMSubtreeModified",
"DOMNodeInserted",
"DOMNodeRemoved",
"DOMNodeRemovedFromDocument",
"DOMNodeInsertedIntoDocument",
"DOMAttrModified",
@Alligator
Alligator / gist:3960707
Created October 26, 2012 18:56
jsweekly bingo
JSWEEKLY BINGO
+-------------------------------+-------------------------------+-------------------------------+
| An atricle from someone who | | |
| just figured out | Baby's first functional | How to do this one very |
| prototype-based OO and thinks | programming | specific thing in Node.js |
| everyone else needs telling | | |
+-------------------------------+-------------------------------+-------------------------------+
| | | |
| A new jQuery release | A job in San Francisco | An introduction to an MVC |
| | | framework |
@WebReflection
WebReflection / writeInGithub.js
Last active January 13, 2021 04:33
a silly script to write in your github timeline
/**
* so here the thing ... you go in your github page
* as example I go here: https://github.com/WebReflection
* you open your console
* you copy and paste this shit
* then you write and execute in the console
* write("Hi There!");
* NOTE: Pixel Font from a 2006 project of mine :-) http://devpro.it/pixelfont/
*/
function write(text, color, start) {
@dfkaye
dfkaye / es6-timeout.md
Last active December 15, 2015 14:49
ES6 needs a timeout - I reserve the right to change my mind about this

2013-3-30

Some recent activity from active contributors regarding ES6 proposals threaten to undermine its acceptance from the community at large.

ES6 proposals include the fat arrow, destructured assignment, splat args, let/block scope, class syntax, class-based inheritance, setters/getters with export, the module loader syntax, weak maps, weak events, @symbols, and so forth.

That is a lot for a community user of the language to comprehend. It is a lot for a single iteration of any project.

The sheer amount of change is at root of the confusion apparent even among the es-discuss mailing list ~ [see this conversation for an example] (https://twitter.com/kangax/status/315863525899780096 ""that was removed from the spec", "I thought it was back in", "it's on the table", "'on the table' does not mean 'in the spec'"").

@WebReflection
WebReflection / gist:5282385
Last active December 15, 2015 15:29
`__proto__` is dangerous

Object.setPrototypeOf() polyfills

Non greedy in 95 bytes (function(O,P){P in O||(O[P]=function(o,p){o.__proto__=p;return o})})(Object,'setPrototypeOf');

Or via self reassignment in 91 bytes (function(O,P){O[P]=O[P]||function(o,p){o.__proto__=p;return o}})(Object,"setPrototypeOf");

Or direct call, 65 bytes, for you closure! var p=Object.setPrototypeOf||function(o,p){o.__proto__=p;return o};

@WebReflection
WebReflection / __proto__.js
Last active August 18, 2016 16:41
just __proto__ and all shenanigans it can bring to any environment
// all IE < 11 browsers:
// there is no __proto__
if (!('__proto__' in {})) {
console.log('you gonna have hard time');
// we need extra logic to be able to work
// as meant in IE too. IE9 ain't disappearing
// any time soon in both desktop and mobile
// neither will IE10
}
// all Mobile WebKit browsers:
@WebReflection
WebReflection / WeakMap.js
Last active December 30, 2022 13:52
An alternative, less memory greedy, more robust WeakMap polyfill.
var WeakMap = WeakMap || (function (Object) {
/*! (C) Andrea Giammarchi - Mit Style License */
var
dP = Object.defineProperty,
hOP = Object.hasOwnProperty,
WeakMapPrototype = WeakMap.prototype,
i = 0
;
@WebReflection
WebReflection / CustomEvent.js
Last active June 7, 2018 18:29
CustomEvent for IE8 or other old browsers that do not implement it. `new CustomEvent('type', {bubbles:true, detail:{what:'ever'}})`
try{new CustomEvent('?')}catch(o_O){
/*!(C) Andrea Giammarchi -- WTFPL License*/
this.CustomEvent = function(
eventName,
defaultInitDict
){
// the infamous substitute
function CustomEvent(type, eventInitDict) {
var event = document.createEvent(eventName);
@WebReflection
WebReflection / Object.prototype.watch.js
Last active September 15, 2016 15:38
There is a reason Firefox still uses `Object.prototype.watch` … it's freaking useful if you know how to use it.
(function(Object){
/*! (C) Andrea Giammarchi - Mit Style License */
/////////////////////////////////////////////////////////////////
//
// compatibility
// native: Firefox Desktop and Mobile
// partial: IE8 works with DOM nodes only
// simulated: all other browsers except IE < 8