Skip to content

Instantly share code, notes, and snippets.

View evitolins's full-sized avatar
🏠
Working from home

Eriks Vitolins evitolins

🏠
Working from home
View GitHub Profile
@evitolins
evitolins / DataModel.js
Last active August 29, 2015 14:05
A simple class to manipulate key/value data, and execute a defined array callbacks.
var DataModel = function () { "use strict";
var data = {},
callbacks = {
'set' : [],
'unset' : []
},
applyCallbacks = function (action, args) {
var cb, len, i;
if (callbacks[action] === undefined) return;
len = callbacks[action].length;
@evitolins
evitolins / README.md
Last active August 29, 2015 14:01
StoreFront - A wrapper for store-js adding both local variable usage, and schema/default value definition.

StoreFront

What?

StoreFront allows users to set a schema/default values for store.js.

StoreFront also acts as a buffer between store.js and your application. All your '''get()''' queries access a synced object instead of constantly utilizing the browser's storage API. In theory, this should speed up performance when data is accessed frequently.

Why?

StoreFront allows users to easily store and retrieve key pair values, while store-js maintains and restores the data for later sessions. If store-js is not found, StoreFront functions the same, but without leveraging the browser's local storage features.

@evitolins
evitolins / FontAwesome Layer Icon
Last active August 29, 2015 13:56
FontAwesome Layer Icon Hack using stacked approach. http://jsbin.com/pikeb/2/edit?html,output
<span class="fa-stack fa-rotate-90" style='font-size:40px'>
<i class="fa fa-square fa-stack-1x" style="top: 0; left: 0;"></i>
<i class="fa fa-square fa-stack-1x" style="top: .1em;left: .1em;color:#fff;"></i>
<i class="fa fa-square fa-stack-1x" style="top: .2em;left: .2em;"></i>
<i class="fa fa-square fa-stack-1x" style="top: .3em;left: .3em;color:#fff;"></i>
<i class="fa fa-square fa-stack-1x" style="top: .4em;left: .4em;"></i>
</span>
<?
// Source:
// http://www.encoding.com/help/sub_category/category/error_codes
$encoding_errorCodes = array(
"ECOM00229" => "S3 upload error: We encountered an internal error. Please try again.",
"ECOM00228" => "S3 upload error: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.",
"ECOM00230" => "Creating the dir/file failed: No such file or directory.",
@evitolins
evitolins / appendLog.php
Created February 4, 2014 23:00
Simple way to append data to a log file. Can be used for PHP troubleshooting.
<?
$path = '/var/www/myWebsite/myLog.log';
$data = 'myData';
file_put_contents ($path , PHP_EOL . time() .' - ' . $data, FILE_APPEND | LOCK_EX );
?>
@evitolins
evitolins / httpErrorMessage.js
Created December 5, 2013 19:46
A quick way to display human-readable HTTP errors.
// Quick and easy HTTP Error Messages
// @ https://gist.github.com/aidilfbk/1363383
var get_http_error_message = function (code) {
var http_errors = {
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Checkpoint",
122: "Request-URI too long",
@evitolins
evitolins / check_rebase.sh
Created December 4, 2013 05:05 — forked from schnell18/check_rebase.sh
Bash script to determine if current branch need rebase changes from the integration branch.
#!/bin/bash
# Bash script to determine if current branch(default HEAD)
# need rebase the changes from the integration
# branch(default master)
# Author: Justin Zhang <fgz@qad.com>
# Created: 2013-12-04
#
# Usage:
# check_rebase.sh [current branch] [integration branch]
#
@evitolins
evitolins / dir2iso.sh
Created November 29, 2013 07:12
OSX Folder to hybrid .iso file. Personally using this to easily gain access to files stored on OSX filesystem from within a VirtualBox session.
function dir2iso() {
echo "Generating ISO: ${1} -> ${1}.iso"
hdiutil makehybrid -iso -joliet -o ${1}.iso ${1}
}
alias dir2iso=dir2iso
@evitolins
evitolins / getElementsByIds.js
Last active December 29, 2015 07:39
A simple function to simplify the act of gathering DOM elements for manipulation.
/**
* Returns an object of elements, from a given list of ids (ev)
* @return {object} Object containing any matching element ids, assigning
* the id as the key
*/
var getElementsByIds = function() { "use strict";
var r = {},
a = [].slice.call(arguments),
e,id,i;
for (i=0; i<a.length; i++) {
@evitolins
evitolins / SingleEvent.js
Last active December 28, 2015 11:39
A simple, single-use Javascript eventListener class. (http://jsbin.com/ADeZAHe/2/edit)
/**
* This class allows you to assign an eventListener to be utilzed only once, before
* it removes itself.
*
* # Usage Example:
* var elem = document.createElement('div');
* var onetimer = new SingleEvent(elem, "click", function(){alert("Well, I'll never do THAT again...");});
* document.body.appendChild(elem);
*/