Skip to content

Instantly share code, notes, and snippets.

View whoiscarlo's full-sized avatar

Carlo Nyte whoiscarlo

View GitHub Profile
@whoiscarlo
whoiscarlo / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@whoiscarlo
whoiscarlo / python_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

@whoiscarlo
whoiscarlo / listComprehension.py
Created September 9, 2014 18:06
List comprehension
## This is the same as
arr = ['test ', 'this', ' thing ']
[x.trim() for x in arr]
## This
vals = []
for x in arr
vals.append(x.trim())
return vals
@whoiscarlo
whoiscarlo / max_MultiThread.ms
Created September 23, 2014 19:00
How to run Multi Thread in Maxscript, although, currently it locks up the viewport =(
fn bkgWrkr =
( python.execute("
import thread;
import time;
def crap():
for i in range( 10):
print 'Love', i
print time.strftime( '%c')
time.sleep( 5)
@whoiscarlo
whoiscarlo / Callback.py
Created October 30, 2014 00:05
Maya Python Callback
class Callback(object):
def __init__(self, func, *args, **kwargs):
self.func = func
self.args = args
self.kwargs = kwargs
def __call__(self, *args):
return self.func( *self.args, **self.kwargs )
and this to call it
mc.menuItem(l='Remove set from scene', c=Callback(self.stripObject, obj, member, 1, selButton))
@whoiscarlo
whoiscarlo / PopupMenu.py
Last active August 29, 2015 14:16
Popup Menu in PyQt or Pyside
##Enable Right
self._category_table.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self._category_table.customContextMenuRequested.connect(self.show_category_table_Popup)
##Create Popup Menu
self._category_table_Popup = QtGui.QMenu(self)
self._category_table_Popup.addAction('Activate', lambda: self.changeStatus('table', 'Active'))
self._category_table_Popup.addAction('Ommit', lambda: self.changeStatus('table', 'Omitted'))
self._category_table_Popup.addAction('Delete', lambda: self.changeStatus('table', 'Delete'))
@whoiscarlo
whoiscarlo / getThisLine.py
Created February 26, 2015 20:41
Fucntion to grab the current line number python
"""This provides a lineno() function to make it easy to grab the line
number that we're on.
Danny Yoo ([email protected])
"""
import inspect
def lineno():
"""Returns the current line number in our program."""
@whoiscarlo
whoiscarlo / changeMayaWindowColor
Last active September 17, 2015 14:15
Change Maya Window Color
'''
Author: Greg Torrn
script: changeMayaWindowColor
'''from maya import cmds
import colorsys
import random
h = round(random.uniform(0.0, 1.0), 2)
s = round(random.uniform(0.0, 1.0), 2)
v = round(random.uniform(0.1, 0.5), 2)
@whoiscarlo
whoiscarlo / changeMayaWindowColor.py
Last active February 16, 2017 02:50
Change Maya Window Color
def changeMayaWindowColor(color=None):
"""
Colorize Maya background
"""
if not color:
randColor = random.randint(0, 128)
if 60< randColor > 75:
randColor = 80
randIndex = random.randint(0, 2)
colors = [50, 60, 65]
import OpenImageIO
exr_filPath = 'x:/project/testfolder/testImage.exr'
def edit_exr( exr_filPath):
#renames Channels
newimg = OpenImageIO.ImageBuf(exr_filPath)
#adds metadata
newimg.specmod().attribute("subRound","r2")