Skip to content

Instantly share code, notes, and snippets.

View satishgoda's full-sized avatar

Satish Goda satishgoda

View GitHub Profile
# -*- coding: utf-8 -*-
def foo(a, b="B", c=[], *args, **kwargs):
print(a, b, c)
if not args:
print("No *args passed")
else:
print(args)
@satishgoda
satishgoda / py_dict_fail.py
Last active August 29, 2015 13:56
python dict fail
def foo():
l = []
return l[:]
#attr_map = dict.fromkeys(prefixes_unique, foo())
attr_map = dict.fromkeys(prefixes_unique, [])
for key in attr_map:
print(key, id(attr_map[key]))
#!/bin/sh
VALUE_ICON=`cygpath -d "$HOME/pict/terminal.png"`
VALUE_TITLE="terminal"
VALUE_MESSAGE="Ha!!"
while getopts hi:t:m: OPT
do
case $OPT in
@satishgoda
satishgoda / example1.py
Created September 18, 2014 13:45
operator.methodcaller
import operator
last = operator.itemgetter(-1)
l1 = []
l2 = [1,2,3]
l3 = [-100, 10, 400]
def gaurdedLast(l):
return (last(l) if l else None)
@satishgoda
satishgoda / newinstance.py
Created September 23, 2014 16:04
__call__, __new__ and __init__ in Python
"""
"""
"""
In this interactive tutorial we are going to take a look at the process of the
creation of an instance object by calling an user-defined class.
"""
"""
We will be running the sample program via the ipython interpreter and in a
@satishgoda
satishgoda / SCREEN_OT_toggle_grid.py
Last active December 10, 2015 06:28
SCREEN_OT_toggle_grid.py : Blender 2.65a Python Operator : Toggles the Grid display in all 3D Views for the current screen"
# http://learningblender3dsoftware.blogspot.in/2012/12/learning-about-operators-2-screen.html
import bpy
def main(context):
screen = context.screen
for area in screen.areas:
if area.type == 'VIEW_3D':
active_space = area.spaces[0]
attrs = ['show_floor', 'show_axis_x', 'show_axis_y', 'show_axis_z']
@satishgoda
satishgoda / Makefile
Last active December 10, 2015 11:19
A simple Makefile that I have written and use for my toy projects. http://www.gnu.org/software/make/ http://www.gnu.org/software/make/manual/make.html
# Name of the project
# The binary file will use the name of the project!
PROJECT := $(shell basename $(shell pwd))
# Header files
HEADERS = -I../../util/
# C++ source files
SOURCES := $(shell find ./ -name "*.cpp")
@satishgoda
satishgoda / c++11Features1.cpp
Last active December 11, 2015 15:18
A quick example program that is using some of the new features that are part of C++11. Tested and compiled with gcc 4.7.1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//----------------------------------------------------------------------------
using VectorOfIntPointers = vector<const int *>;
void printPointersToElements(const VectorOfIntPointers& pointers)
# Create a bezier curve object
>>> bpy.ops.curve.primitive_bezier_curve_add()
{'FINISHED'}
# Get a reference to the curve object
>>> curve_object = bpy.context.active_object
# Print out its data path
import bge
controller = bge.logic.getCurrentController()
owner = controller.owner
print(type(owner))
print(owner.getPropertyNames())