Skip to content

Instantly share code, notes, and snippets.

View ghoullier's full-sized avatar
🧙‍♂️
TypeScript everything

Grégory Houllier ghoullier

🧙‍♂️
TypeScript everything
View GitHub Profile
@ghoullier
ghoullier / DomBuilder.js
Created February 17, 2014 13:28
DomBuilder comparison (Native vs String) : http://jsperf.com/test-dom-builder
;(function(root, doc) {
function AbstractDomBuilder(tagName, attrs, innerHTML) {
this.tagName = tagName || 'div'
this.attrs = attrs || {}
this.innerHTML = innerHTML || ''
}
AbstractDomBuilder.prototype.build = function() {}
function NativeDomBuilder() {
AbstractDomBuilder.apply(this, arguments)
@ghoullier
ghoullier / WeakMap.js
Last active August 29, 2015 13:56
WeakMap polyfill
;(function(root) {
function WeakMap() {
if (!(this instanceof WeakMap)) {
throw new TypeError('Illegal invocation')
}
var indexes = []
, values = []
this.has = _has.bind(this, indexes, values)
this.set = _set.bind(this, indexes, values)
this.get = _get.bind(this, indexes, values)
@ghoullier
ghoullier / globals.js
Last active December 28, 2015 19:09
List non-inherited global variables
;(function (root, doc) {
'use strict'
var element = doc.documentElement
, iframe = doc.createElement('iframe')
, globals = Object.keys(root)
// Append iframe to the DOM
element.appendChild(iframe)
// Get inherited global variables
var inherited = Object.keys(iframe.contentWindow)
// Detach iframe
@ghoullier
ghoullier / manifest-proxy.html
Created October 18, 2013 15:59
Iframe manifest proxy, avoid main page caching
<!DOCTYPE html>
<html manifest="manifest.appcache">
<body>
<script>
(function (root) {
// Local variables
var parent = root.parent,
location = root.location;
// Add event when root is loaded
root.addEventListener('load', function onRootLoad() {
@ghoullier
ghoullier / countCSSRules.js
Last active December 20, 2015 20:59 — forked from psebborn/countCSSRules.js
Count CSS Rules
;(function () {
var results = [],
log = [],
list = document.styleSheets;
if (!list) {
return;
}
for (var i = 0, x = list.length; i < x; i++) {
countSheet(list[i]);
}
@ghoullier
ghoullier / gist:5893414
Created June 30, 2013 01:35
CasperJS file to download manga from scan-mx.com
// Casper JS Instance
var casper = require('casper').create();
// Scan-mx domain
var domain = 'http://www.scan-mx.com';
// URL Separator
var separator = '/';
// Command Line Argument: Manga
var manga = casper.cli.get(0) || 'naruto';
// Command Line Argument: Episode Number
var episode = casper.cli.get(1) || 1;
@ghoullier
ghoullier / QueryString
Created February 7, 2013 07:15
Provide Simple Class to QueryString
(function(global) {
var QueryString = (function() {
function Class(){
if (this instanceof Class) {
} else {
throw new Error("Illegal constructor");
}
};
Class.get = function(/*String*/name) {