Skip to content

Instantly share code, notes, and snippets.

View FuruholmAnton's full-sized avatar

Anton Furuholm FuruholmAnton

View GitHub Profile
var gallery = {
container: null,
containerPadding:0,
containerWidth:0,
itemsArray:[],
itemMargin:0,
items:[], // Array of all the <img>
count:[],
maxWidth:0,
/**
*
* Author: Anton Furuholm
* An Easy and lightweight library for writing faster JavaScript
*
*/
/**
*
* Functions:
<?php
function listFolderFiles($dir){
$foldersAndFiles = scandir($dir);
foreach($foldersAndFiles as $item){
if (!in_array($item,array(".",".."))){ // scandir() adds . and .. to the array
// Write it out if its an image
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@FuruholmAnton
FuruholmAnton / .jscsrc
Last active March 28, 2017 14:12
npm install -g jscs
{
"preset": "google",
//"preset": "airbnb",
"validateIndentation": 4,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requireNewlineBeforeSingleStatementsInIf": true,
"requireObjectKeysOnNewLine": true,
"requireOperatorBeforeLineBreak": [
"?",
var src = document.querySelector("video");
src.addEventListener("click", function() {
this.paused === true ? this.play() : this.pause();
});
// extend.js
// Written by Andrew Dupont, optimized by Addy Osmani
function extend( destination, source ) {
var toString = Object.prototype.toString,
objTest = toString.call({});
for ( var property in source ) {
if ( source[property] && objTest === toString.call(source[property]) ) {
@FuruholmAnton
FuruholmAnton / Poll
Last active April 6, 2016 07:39
Sometimes you don't get to plug into an event to signify a desired state -- if the event doesn't exist, you need to check for your desired state at intervals: (Source: https://davidwalsh.name/essential-javascript-functions)
function poll(fn, callback, errback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if(fn()) {
callback();
}
// If the condition isn't met but the timeout hasn't elapsed, go again
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
return result;
var getAbsoluteUrl = (function() {
var a;
return function(url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();