Skip to content

Instantly share code, notes, and snippets.

@pratikmallya
pratikmallya / test_deco.py
Last active December 24, 2015 08:29
This piece of code is what I'm using to clarify certain function-related concepts in Python, especially those relating to decorators
# Test decorator functionality in Python
def log(F):
def print_args(*args, **kwargs):
print args, kwargs
return print_args
@log
def holy_smokes(a, b, c):
print a + b + c
// Popcorn Instance Methods
var p = Popcorn( "#video" )
p.play()
// Play the video (Native "pass through" method)
// Returns the Popcorn instance object
p.load()
// Load the video (Native "pass through" method)
// Returns the Popcorn instance object
@pratikmallya
pratikmallya / merge_manifold.m
Created October 17, 2013 12:29
Atlas merge code
function [atlas] = merge_manifold()
% merge atlas2 into atlas, return a new atlas
% this code performs a "Brute force" merge where all the charts of the second
% atlas are checked for nearness to the first atlas, and then merged in
atlas1 = coco_bd_read('cylinder1', 'atlas');
atlas2 = coco_bd_read('cylinder2', 'atlas');
atlas2charts = atlas2.charts{1:5};
atlas = atlas1;
for i = 1:numel(atlas2charts)
chart = atlas2.charts{i};
from traits.api import Enum, HasTraits
class A(HasTraits):
v = Enum('these', 'three','values')
prob = coco_prob();
prob = coco_add_func(prob, 'phi', @phi,...
[], 'zero', 'u0', [7.9829e-02 2.5133e+01 -2.0000e+00]);
prob = coco_add_func(prob, 'psi', @psi,...
[], 'inactive', 'mu1', 'uidx', [1:3]);
prob = coco_add_func(prob, 'iden1', @iden,...
[], 'active', 'mu2', 'uidx', [2]);
prob = coco_add_func(prob, 'iden2', @iden,...
[], 'active', 'mu3', 'uidx', [3]);
%prob = coco_set_parival(prob, 'mu1', 0);
1. Two space soft indents (fake tabs) OR tabs... BUT NEVER BOTH - DO NOT MIX
2. Whitespace, Parens, Braces, Linebreaks
if/else/for/while/try always have spaces, braces and multiple lines.
--------------------------------------------------------------------
@pratikmallya
pratikmallya / style-guide.py
Created December 20, 2013 18:19
A style guide to use for Python code
'''
Of course, you should always follow: http://www.python.org/dev/peps/pep-0008/
Here are some more style guideline to write a better, self-documented code
'''
'''
1. Function Descriptions:
Every function should have a comment string describing:
ffprobe -v quiet -print_format json -show_format -show_streams "lolwut.mp4" > "lolwut.mp4.json"
1. Two space soft indents (fake tabs) OR tabs... BUT NEVER BOTH - DO NOT MIX
2. Whitespace, Parens, Braces, Linebreaks
if/else/for/while/try always have spaces, braces and multiple lines.
--------------------------------------------------------------------