Skip to content

Instantly share code, notes, and snippets.

@internetimagery
internetimagery / crossajax
Created April 12, 2015 22:55
Crossdomain json ajax
crossDomainLoad: (url, callback)->
$.get "http://query.yahooapis.com/v1/public/yql", {
q: "select * from json where url = \"#{url}\""
format: "json"
}, (data)->
if data.query.results
callback data.query.results.json
@internetimagery
internetimagery / window.py
Last active August 29, 2015 14:19
maya docking window template
##############################################
# Dockable window template
# Created: 15/4/15
# Jason Dixon (jason.dixon.email[AT]gmail.com)
##############################################
import maya.cmds as cmds
from functools import wraps
import sys
@internetimagery
internetimagery / FileInfo.py
Last active August 29, 2015 14:19
maya fileInfo wrapper in a dict (use like a dictionary)
import maya.cmds as cmds
import collections
import cPickle
class FileInfo(collections.MutableMapping):
"""
Dictionary style interface for fileInfo
"""
def _encode(s, txt):
@internetimagery
internetimagery / gist:5605f1ecc2f390161c85
Last active August 29, 2015 14:27
TELIMS Maya 2015 SP6 Install on Ubuntu 14.04
#References:
#http://forums.autodesk.com/t5/installation-licensing/installing-maya-on-ubuntu/td-p/4905036
#http://askubuntu.com/questions/392806/installing-maya-on-ubuntu-linux
#https://gist.github.com/insomniacUNDERSCORElemon/5555214
#http://nealbuerger.com/2013/05/ubuntu-13-04-maya-2014-install-script/
#http://www.nkoubi.com/blog/tutorial/how-to-install-autodesk-maya-2011-on-debian-ubuntu/
#http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=GUID-E7E054E1-0E32-4B3C-88F9-BF820EB45BE5
#http://www.andrewhazelden.com/blog/2014/10/autodesk-nlm-licensing-issues-with-maya-2015-and-max-2015/
@internetimagery
internetimagery / __init__.py
Last active October 6, 2015 16:16
Auto load submodules in a package as they're used
# Stick the following in the bottom of your __init__.py, then simply import the base package. Use submodules as you need them and they'll be imported as you go.
import sys as _sys
class Package(object):
def __init__(s, local):
import os.path
s.cache = {}
s.local = dict((k, local[k]) for k in local)
s.root = os.path.realpath(os.path.dirname(s.local["__file__"]))
def __getattr__(s, k):
if k in s.local: return s.local[k]
@internetimagery
internetimagery / dict.py
Last active October 9, 2015 11:50
Reversable Dict. Accessible via key or value.
import collections
class Dict(collections.MutableMapping):
def __init__(s, *args, **kwargs):
s.fwd = dict(*args, **kwargs)
s.rev = dict((v, k) for k, v in s.fwd.items())
def __delitem__(s, k):
if k in s.fwd: return s.rev.pop(s.fwd.pop(k))
if k in s.rev: return s.fwd.pop(s.rev.pop(k))
raise KeyError, "%s not found." % k
def __getitem__(s, k):
@internetimagery
internetimagery / err.py
Created October 10, 2015 21:53
Error handle catchall
import sys
import traceback
try:
raise something
except:
traceback.print_exception(*sys.exc_info())
@internetimagery
internetimagery / anim.py
Last active October 14, 2015 14:57
animated image maya
import time
import threading
import maya.cmds as cmds
import maya.utils as utils
class Animation(object):
def __init__(s, frames):
s.frames = frames
s.img = cmds.iconTextStaticLabel(style="iconOnly")
s.frame = 0
@internetimagery
internetimagery / nestedDict.py
Created October 15, 2015 10:54
nested dict
# http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python/19829714#19829714
class Dict(dict):
def __missing__(s, k):
v = s[k] = type(s)()
return v
@internetimagery
internetimagery / template.py
Last active October 16, 2015 13:29
Mutable Templates
import collections
class Dict(collections.MutableMapping):
def __init__(s, *args, **kwargs):
s.data = dict(*args, **kwargs)
def __getitem__(s, k): return s.data[k]
def __setitem__(s, k, v): s.data[k] = v
def __delitem__(s, k): del s.data[k]
def __iter__(s): return iter(s.data)
def __repr__(s): return repr(s.data)