Want to create a Gist from your editor, the command line, or the Services menu? Here's how.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
""" | |
os.walk is an awesome generator. | |
However, I needed the same functionality, | |
only I wanted to walk 'up' the | |
directory tree. | |
This allows seaching for files | |
in directories directly above |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Obsidian] | |
definition-foreground = #678CB1 | |
error-foreground = #FF0000 | |
string-background = #293134 | |
keyword-foreground = #93C763 | |
normal-foreground = #E0E2E4 | |
comment-background = #293134 | |
hit-foreground = #E0E2E4 | |
builtin-background = #293134 | |
stdout-foreground = #678CB1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtCore, QtGui | |
import maya.cmds as cmds | |
import maya.OpenMayaUI as mui | |
import sip | |
class MyDialog(QtGui.QDialog): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
from maya import cmds | |
def undo(func): | |
""" Puts the wrapped `func` into a single Maya Undo action, then | |
undoes it when the function enters the finally: block """ | |
@wraps(func) | |
def _undofunc(*args, **kwargs): | |
try: | |
# start an undo chunk |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
"""Convert CSV table to MindMap format | |
Usage: python csv_to_mm.py sometable.csv > mymap.mm | |
CSV format is rows representing tree leaves, e.g.: | |
A1, | |
A1,B1 | |
A1,B1,C1 | |
A1,B1,C2 |
struct
-like objects, i.e. ones that are largely the same as a Cstruct
instance, win in the memory department.- These tests do not try to determine what is best for very large sets of values, however; I direct the reader to http://stackoverflow.com/a/2670191 for an insight into that scenario when using a dictionary.
- Dictionaries beat out objects in access times.
- According to Wikipedia, the Python dictionary is highly optimised because it is used internally to implement namespaces. [citation needed]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-Symlink { | |
<# | |
.SYNOPSIS | |
Creates a symbolic link. | |
#> | |
param ( | |
[Parameter(Position=0, Mandatory=$true)] | |
[string] $Link, | |
[Parameter(Position=1, Mandatory=$true)] | |
[string] $Target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File Transfer for Pythonista | |
# ============================ | |
# This script allows you to transfer Python files from | |
# and to Pythonista via local Wifi. | |
# It starts a basic HTTP server that you can access | |
# as a web page from your browser. | |
# When you upload a file that already exists, it is | |
# renamed automatically. | |
# From Pythonista's settings, you can add this script | |
# to the actions menu of the editor for quick access. |
OlderNewer