Skip to content

Instantly share code, notes, and snippets.

http://www.somacon.com/p542.php
http://codepen.io/anon/pen/yYjqYv?editors=110
@puiutucutu
puiutucutu / sublime settings
Created October 29, 2015 22:19
sublime settings
{
"color_scheme": "Packages/Dayle Rees Color Schemes/sublime/contrast/laravel-contrast.tmTheme",
"font_options":
[
"directwrite",
"subpixel_antialias"
],
"font_size": 9,
"ignored_packages":
[
@puiutucutu
puiutucutu / gist:145cab8a6fa7e7e582e7
Created November 1, 2015 05:11
Regex for extracting between HTML / XML tags
$pattern = '/<vt:lpstr>(.*?)<\/vt:lpstr>/';
@puiutucutu
puiutucutu / gist:1e09c6f8f157c4fc21ca
Created November 1, 2015 06:56
php xml speed test
// create an object representation of the XML file
$xmlFile = $this->readFile('xl/workbook.xml');
$xmlObject = new SimpleXMLElement($xmlFile);
// extract worksheet names
foreach ($xmlObject->sheets->sheet as $sheetObject)
$sheetnames[] = (string) $sheetObject->attributes()->name;
// debug($sheetnames);
@puiutucutu
puiutucutu / looping.js
Last active November 9, 2015 18:37
Looping through array in JavaScript
// looping an HTMLCollection using for
var TheadRows = document.getElementById('table').tHead.rows[0].cells
for (var i = 0; i < TheadRows.length; i++) {
console.log(TheadRows[i].innerText)
};
// looping with Array.prototype.forEach (only for HTMLCollection object)
@puiutucutu
puiutucutu / gist:0b1956572ee72f320583
Created November 2, 2015 17:52
JavaScript Reads
http://christianalfoni.github.io/javascript/2014/08/01/why-javascript-inheritance-is-so-difficult-to-understand.html
@puiutucutu
puiutucutu / gist:fbbae901f13e51b06444
Last active November 2, 2015 19:34
JavaScript test if array
var anArray = [1,2,3,4,5];
// all work and return true
console.dir(anArray.constructor === Array)
console.dir(anArray.__proto__ === Array.prototype)
console.dir(anArray.__proto__ === anArray.constructor.prototype)
console.dir(anArray instanceof Array)
@puiutucutu
puiutucutu / gist:7d63726273d4984cd157
Created November 4, 2015 14:22
JavaScript - Map vs Loop
iMapped = []
// you dont need to use map, you can do it yourself
for (var i = 0; i < userSortColumn.length; i++) {
// create object that contains the column celll value and the cells row index position
iMapped[i] = {
rowId: i,
value: userSortColumn[i]
}
};
@puiutucutu
puiutucutu / loops.js
Last active November 5, 2015 17:39
JavaScript Loops
var i = rows.length
while(i--) { }
for (var i = rows.length - 1; i >= 0; --i) {
for (var i = rows.length; i--; null) {
// these are all apparently really fast, with the shift beind 2nd and the arr reverse and pop being fastest
while( i = arr.pop() ) {
someFn(i);