Skip to content

Instantly share code, notes, and snippets.

View bloodyowl's full-sized avatar
🦉

Matthias Le Brun bloodyowl

🦉
View GitHub Profile
var nativeConcat = [].concat
function createCurried(fn, args, length, thisValue){
function curried(){
var currentArgs = nativeConcat.apply(args, arguments)
if(length - currentArgs.length <= 0) {
return fn.apply(thisValue === void 0 ? this : thisValue, currentArgs)
}
return createCurried(fn, currentArgs, length, thisValue)
}
@bloodyowl
bloodyowl / gist:7010866
Created October 16, 2013 16:37
sneak peek
;(function(craft){
var supportsProto = typeof {}.__proto__ == "object"
, fragment = doc.createDocumentFragment()
, nodeList = supportsProto ? [] : getExternalArray()
, createNodeList
function getExternalArray(){
var context = doc.createElement("iframe")
, proto, contextDoc
@bloodyowl
bloodyowl / gist:6973181
Last active December 25, 2015 11:59
Snippet: from an instance method to a static one.
/*
Sometimes in JavaScript you want a method to be
accessible in multiple contexts.
For instance as a static and instance method.
Here comes a little example.
*/
var app = {}
/*
How to make a domReady function
*/
;(function(win){
var doc = win.document
/*
We'll use the document.readyState string
to define weather or not the dom is ready.
The RegExp matches all the states we can

events.js

var a = events.create()

a.listen("click:app", foo)
a.listen("click:app", foo)
a.listen("click:app", bar)
@bloodyowl
bloodyowl / gist:6560525
Created September 14, 2013 09:34
caenJS
/**
hop!
*/
;([]+{})[+!![]+!![]+!![]+!![]+!![]]+([]+![])[+!![]]+([]+[][[]])[+!![]+!![]+!![]]+([]+[][[]])[+!![]]+([]+{})[+!![]+!![]+!![]]+([]+![])[+!![]+!![]+!![]]
@bloodyowl
bloodyowl / p.html
Created August 29, 2013 17:43
{P!}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{P!}</title>
<style>
.logo {
position: relative;
height: 10em;
width: 10em;
@bloodyowl
bloodyowl / gist:6261816
Created August 18, 2013 14:01
Syntax differences between jQuery and craft

jQuery

$( "button.continue" ).html( "Next Step..." )

craft

var buttons = craft.$$("button.continue")
@bloodyowl
bloodyowl / example.js
Created December 18, 2015 12:35
fetchURL.js
fetchURL("/").then(({ responseText }) => console.log(responseText))
const request = fetchURL("/")
request.cancel()
request.then(() => console.log("NOT HAPPENING"))
@bloodyowl
bloodyowl / gist:6040648
Last active December 20, 2015 00:19
Object.prototype utils
;(function(root){
var _toString = {}.toString
, ARRAY_CLASS = "[object Array]"
, STRING_CLASS = "[object String]"
/**
Collection utilities
*/