Skip to content

Instantly share code, notes, and snippets.

View Cycymomo's full-sized avatar

Cyril Moreau Cycymomo

View GitHub Profile
@Cycymomo
Cycymomo / Pattern observer.md
Last active December 30, 2015 23:29 — forked from addyosmani/examples.md
Pattern observer

What are we trying to observe? Raw object data.

// Objects
var obj = { id: 2 };
obj.id = 3; // obj == { id: 3 }
 
// Arrays
var arr = ['foo', 'bar'];
arr.splice(1, 1, 'baz'); // arr == ['foo', 'baz'];
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@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 <alexthkloss@web.de>
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 / 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 = [];
@Cycymomo
Cycymomo / LICENSE.txt
Created August 1, 2013 09:21 — forked from aemkei/LICENSE.txt
140bytes - Converts a latin character string into [leetspeak]
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 / formatPrice.js
Last active December 19, 2015 22:39 — forked from codylindley/format price (US)
format price (US)
function formatUSprice(amount)
{
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
@Cycymomo
Cycymomo / assert.js
Created April 27, 2013 09:40 — forked from ianb/assert.js
function AssertionError(msg) {
this.message = msg || "";
this.name = "AssertionError";
}
AssertionError.prototype = Error.prototype;
/* Call assert(cond, description1, ...)
An AssertionError will be thrown if the cond is false. All parameters will be logged to the console,
and be part of the error.
*/