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
<?
// 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 / 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>
@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 / 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 / dataModel.coffee
Created August 11, 2014 16:00
A simple class for manipulating key/value pairs, and applying associated callbacks.
class DataModel
constructor: () ->
@data = {}
@callbacks =
set: []
unset: []
return
applyCallbacks: (action, args) ->
for cb in @callbacks[action]
@evitolins
evitolins / commandPort.py
Created August 31, 2014 17:42
Maya CommandPort methods to assist with MayaSublime package integration.
import maya.cmds as cmds
def activateCommandPort(host='127.0.0.1', port='7002', language="python"):
path = host + ":" + port
active = cmds.commandPort(path, q=True)
if not active:
cmds.commandPort(name=path, sourceType=language)
else:
print("%s is already active" % path)
@evitolins
evitolins / RRM_utils.py
Last active December 21, 2023 18:45
Maya Python Snippets
'''
This fixes a RRM bug (v1.4.7) where saved RRM setups do not preserve a
module's 'pinned' status.
'''
import maya.cmds as cmds
import maya.mel
def RRM_fixPinBug(objs):
for obj in objs:
trans = cmds.xform(obj,q=True, r=True, translation=True)
maya.mel.eval("RRM_PinProxies(1, 0);")
@evitolins
evitolins / README.md
Last active August 29, 2015 14:07
Python: Modules, Classes & Objects

Python: Modules, Classes & Objects

So in Python you have 3 major tools for code organization…Modules, Classes, & Objects

Modules:

Python modules are pretty much just a single python file. You can think about it as giving your variables and functions a specific namespace to reference within another python script. For example: The code below imports the contents of "mySampleModule.py" to allow all it's contents to be used in another python script under it's namespace (by default, the filename).

import mySampleModule

@evitolins
evitolins / php2json.php
Last active August 29, 2015 14:07
Simple PHP -> JSON Usage
<?
/**
*
* Returns an array as JSON formatted data
*
*/
// Automatically Gather Images from a directory
$autoImageList = array();
foreach(glob('./images/*.{jpg,png,gif}') as $filename){
@evitolins
evitolins / getFilteredList.py
Last active March 8, 2017 06:29
Python: Filter list by prefix and/or suffix
def getFilteredList(list=[], pfx='', sfx=''):
filteredList = []
for item in list:
isMatch = False
if pfx and not sfx: isMatch = item.startswith(pfx)
if not pfx and sfx: isMatch = item.endswith(sfx)
if pfx and sfx: isMatch = item.startswith(pfx) and item.endswith(sfx)
if isMatch: filteredList.append(item)
return filteredList