Skip to content

Instantly share code, notes, and snippets.

View adriengibrat's full-sized avatar
:octocat:
open sourcing when not too busy

Adrien Gibrat adriengibrat

:octocat:
open sourcing when not too busy
View GitHub Profile
@adriengibrat
adriengibrat / fiddle.html
Last active July 5, 2016 23:57 — forked from jed/LICENSE.txt
isSameOrigin
Page url: <span id="location"></span>
<div>
<span class="url">http://fiddle.jshell.net</span> <span>true</span></div>
<div><span class="url">http://fiddle.jshell.net:80</span> <span>true</span></div>
<div><span class="url">//fiddle.jshell.net</span> <span>true</span></div>
<div><span class="url">//fiddle.jshell.net:80</span> <span>true</span></div>
<div><span class="url">http://fiddle.jshell.net:81</span> <span>false</span></div>
<div><span class="url">https://fiddle.jshell.net</span> <span>false</span></div>
@adriengibrat
adriengibrat / dabblet.css
Created January 8, 2013 11:36
Gradient Background test
/**
* Gradient Background test
*/
body{
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
}
@adriengibrat
adriengibrat / l.php
Last active January 22, 2024 14:45
Extreme minification of shortest possible PSR-0 compliant autoloader, 5 lines !
<?php
//set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); // optional
spl_autoload_register(function ($class) {
$file = preg_replace('#\\\|_(?!.+\\\)#','/', $class) . '.php';
if (stream_resolve_include_path($file))
require $file;
});
@adriengibrat
adriengibrat / jquery.toascii.js
Last active December 17, 2015 04:49
Clean up diatrics from strings (convert to ascii)
(function($){
$.toAscii = $.extend(
function toAscii (string) {
$.each(toAscii.diacritics, function(){
string = string.replace(this[1], this[0]);
});
return string;
}, {
diacritics: [
['A', /[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]/g],
@adriengibrat
adriengibrat / jsonp.js
Last active August 29, 2015 13:56
Lightweight standalone jsonP utility (jQuery like)
window.jsonP = function ( url, callback, paramName ) {
var self = arguments.callee // this function
, queue = self.queue || ( self.queue = {} ) // callback queue
, name = 'jsonP' + Object.keys( queue ).length + '_' + Date.now() // unique callback name
, global = 'jsonP.queue.' + name // global callback name
, placeholder = /(=)\?(?=&|$)/ // placeholder pattern
, script = document.createElement( 'script' ) // script dom node
;
script.type = 'text/javascript';
script.src = placeholder.test( url ) ?
@adriengibrat
adriengibrat / Object.prototype.watch.js
Last active April 23, 2020 19:24
Object.prototype.watch "polyfill"
/**
* Object.prototype.watch polyfill
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch
*
* Known limitations:
* - `delete object[property]` will remove the watchpoint
*
* Based on Eli Grey gist https://gist.github.com/eligrey/384583
* Impovements based on Xose Lluis gist https://gist.github.com/XoseLluis/4750176
* This version is optimized for minification
@adriengibrat
adriengibrat / jquery.triggerBut.demo.js
Last active August 29, 2015 14:05
[Hack] jQuery2 method: trigger event handlers but the ones with given namespace
(function( $ ) {
var d = $(document),
log = function (event) { d.on(event, function(e) { console.log(event, e.type, e.namespace, e.namespace_re) }) }
log("test")
log("test.a")
log("test.b")
log("test.b.a")
log("test.c")
@adriengibrat
adriengibrat / how to
Last active August 29, 2015 14:26 — forked from albi90/how to
Compiling node-webkit on raspberry pi
cd ~
mkdir .gyp
nano .gyp/include.gypi
paste the following
{
'variables': {
'linux_use_gold_binary' : 0,
'linux_use_gold_flags' : 0,
'target_arch': 'arm',
'disable_nacl': 1, # NaCL does not build for ARM.
@adriengibrat
adriengibrat / bower.json
Last active March 13, 2022 00:39
Parse ISO 8601 duration as function that sums duration to a given date
{
"name": "parseDuration",
"version": "0.0.1",
"main": "./parseDuration.es5.js"
}
@adriengibrat
adriengibrat / plural.js
Last active May 30, 2017 08:14
simple CLDR plural rules parser
#!/usr/bin/env node
/**
* plural.js – simple CLDR plural rules parser
* https://gist.github.com/adriengibrat/817140a89cfd4893b4155a2ac913904d
*
* This program is free software. It comes without any warranty.
* Released under the WTFPL license – http://www.wtfpl.net
*
* Usage: