Skip to content

Instantly share code, notes, and snippets.

View Cycymomo's full-sized avatar

Cyril Moreau Cycymomo

View GitHub Profile
@Cycymomo
Cycymomo / logGlobals.js
Last active December 25, 2015 01:49
logGlobals.js : list of global var
// bookmarklet, logGlobals
javascript:console.log(function(d,i,s,c,o){i=(d=document).body.appendChild(s=d.createElement('iframe')).contentWindow,c=Object.create(null);d.body.removeChild(s);for(o in this)o in i||(c[o]=this[o]);return c}())
@Cycymomo
Cycymomo / toArray.js
Last active December 24, 2015 11:28
toArray - convert array like javascript
(function () {
'use strict';
var _slice = Array.prototype.slice;
try {
_slice.call(document.documentElement); // Can't be used with DOM elements in IE < 9
}
catch (e) { // Fails in IE < 9
Array.prototype.slice = function (begin, end) {
var i, arrl = this.length, a = [];
@Cycymomo
Cycymomo / live_vs_static_lists.js
Last active December 24, 2015 09:59
live vs static lists
/*
* Fiddle : http://jsfiddle.net/nzmwfufk/
* Réf : https://developer.mozilla.org/en-US/docs/Web/API/NodeList#A_.22live.22_collection
*/
/* test page : "chrome://apps/" 01/10/2013 */
var divs = document.querySelectorAll("div");
console.log('avant : ' + divs.length + ' items');
@Cycymomo
Cycymomo / LICENSE.txt
Created September 26, 2013 07:53 — forked from atk/LICENSE.txt
140bytes, isArray polyfill
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Alex Kloss <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Cycymomo
Cycymomo / LICENSE.txt
Created September 26, 2013 07:53
140bytes, completeObjectClone polyfill
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@Cycymomo
Cycymomo / flushPage.js
Created September 24, 2013 11:38
flushPage.js by @Lcf.vs
(function(d,e){
w=d.createTreeWalker(d.body,4);while(n=w.nextNode())n.data=n.data.replace(e,'')
})(document, /[\w\d\.()=;,'{}/]/gi);
@Cycymomo
Cycymomo / domExtending.js
Last active December 23, 2015 17:19
domExtending
var myDOM = (function(){
var myDOM = function(elems){
return new MyDOMConstruct(elems);
}, MyDOMConstruct = function(elems) {
this.collection = elems[1] ? Array.prototype.slice.call(elems) : [elems];
return this;
};
myDOM.fn = MyDOMConstruct.prototype = {
forEach : function(fn) {
var elems = this.collection;
@Cycymomo
Cycymomo / World.js
Last active December 23, 2015 08:19
World by @aemkei, refacto original : http://aem1k.com/world/
// run this function to update the spinning globe for another iteration
var updateWorld = function updateWorld() {
var e, x, r, t;
var newSource = "<pre>";
var worldParts = [
"zw2",
"l6k\n",
"e3t",
"jnt",
"qj2",
@Cycymomo
Cycymomo / domready.js
Created August 26, 2013 13:49 — forked from ded/domready.js
domready.js
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
console.log(extractTagNamesES5('<a> and <b> or <c>')); // [ 'a', 'b', 'c' ]
// If exec() is invoked on a regular expression whose flag /g is set
// then the regular expression is abused as an iterator:
// Its property `lastIndex` tracks how far along the iteration is
// and must be reset. It also means that the regular expression can’t be frozen.
var regexES5 = /<(.*?)>/g;
function extractTagNamesES5(str) {
regexES5.lastIndex = 0; // to be safe
var results = [];