This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Performant nodelist to array cast. Source: http://stackoverflow.com/a/15144269/370786 | |
* @param nl {NodeList} NodeList to convert. Might work with other data types (Array?) but that needs further testing. | |
*/ | |
function toArray(nl) | |
{ | |
var arr = []; | |
if(isNaN(nl.length)) { | |
throw "Cannot get length"; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/** | |
* {hello: 1, another: 2} => hello=1&another=2 | |
*/ | |
var encodeQueryString = function (obj) | |
{ | |
return (Object.keys(obj).reduce(function(acc, k, i){ | |
return acc + (i?'&':'') + encodeURI(k) + "=" + encodeURI(obj[k]); | |
}, '')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var fs = require('fs'); | |
var originalsPath = 'pics/originals'; | |
var originalFiles = {}; | |
fs.readdir('pics/originals',function(err, files){ | |
originalFiles = files; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Parses a GET-style query string into a key/value object | |
* example: | |
* decodeQueryString("?sdf=ABC&xyz=jj%C3%BC"); | |
* Object {sdf: "ABC", xyz: "jjü"} | |
* | |
* @param {String} s The query string | |
*/ | |
function decodeQueryString(s) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var fs = require('fs'); | |
var localIP = "127.0.0.1"; | |
var port = 8080; | |
var indexFile = './index.html'; | |
var process = function(req, res) { | |
fs.readFile(indexFile, function(err, data) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Source: | |
http://stackoverflow.com/a/30743013/370786 | |
*/ | |
/***** Attribute Hacks ******/ | |
/* IE6 */ | |
#once { _color: blue } | |
/* IE6, IE7 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// credit: https://codepen.io/gabrieleromanato/pen/LpLVeQ | |
function parseInputs( elements ) { | |
var obj = {}; | |
for( var i = 0; i < elements.length; ++i ) { | |
var element = elements[i]; | |
var name = element.name; | |
var value = element.value; | |
if( name ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates html element based on a d-structure | |
* d-structure is: | |
* [ string tagname | HtmlElement root_element, | |
* object attributes, | |
* [child] | string text, | |
* funcion callback(el) | |
* ] | |
* child is: | |
* d-structure | string text | HtmlElement element |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// override XMLHttpRequest | |
// source: https://gist.github.com/icodejs/3183154 | |
var open = window.XMLHttpRequest.prototype.open, | |
send = window.XMLHttpRequest.prototype.send; | |
function openReplacement(method, url, async, user, password) { | |
return open.apply(this, arguments); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Side effects (usually unwanted) | |
- Sometimes impractical: eg: vertical-align | |
- Sometimes too high level / opinionated and inflexible (related to all of above) | |
- Cascading - most of the inhertiance is unwanted | |
- Global-variable-like issues | |
- Overriding | |
__Improvements | |
I think it would be an important improvement, to be able to compound CSS blocks. A bit like less mixins, but at a native level. At the moment, if we are not using a pre-processor, we have to add multiple classes on elements (eg: <div class="col-2 pad-1 size-3">). That is neither powerful nor semantic. |
OlderNewer