Skip to content

Instantly share code, notes, and snippets.

View zeffii's full-sized avatar

Dealga McArdle zeffii

View GitHub Profile
@beniwohli
beniwohli / greek_alphabet.py
Created January 4, 2011 19:29
A Python dictionary mapping the Unicode codes of the greek alphabet to their names
greek_alphabet = {
u'\u0391': 'Alpha',
u'\u0392': 'Beta',
u'\u0393': 'Gamma',
u'\u0394': 'Delta',
u'\u0395': 'Epsilon',
u'\u0396': 'Zeta',
u'\u0397': 'Eta',
u'\u0398': 'Theta',
u'\u0399': 'Iota',
@zeffii
zeffii / blender_polyline.py
Created August 9, 2011 06:41
adding polyline in blender 2.5
import bpy
from mathutils import Vector
listOfVectors = [((0,0,0,1)),((1,0,0,1)),((2,0,0,1)),((2,3,0,1)),((0,2,0,1))]
# create a spline curve from a number of points
def MakePolyLine(objname, curvename, cList):
curvedata = bpy.data.curves.new(name=curvename, type='CURVE')
curvedata.dimensions = '2D'
@zeffii
zeffii / scripting_shapekeys_kframe.py
Created August 9, 2011 13:45
i dont understand how to script keyframe ShapeKeys
import bpy
from mathutils import Vector
listOfVectors = [((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((0,1,0,1))]
shapes = [ [((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((0,1,0,1))],
[((0,0,0,1)),((2,0,0,1)),((1,1,0,1)),((0,1,0,1))],
[((0,0,0,1)),((1,0,0,1)),((1,2,0,1)),((0,1,0,1))],
[((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((-1,1,0,1))]
]
@zeffii
zeffii / shapekeys_blender_curve.py
Created August 9, 2011 15:49
almost creating shapekeys from a list
import bpy
from mathutils import Vector
listOfVectors = [((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((0,1,0,1))]
shapes = [ [((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((0,1,0,1))],
[((0,0,0,1)),((2,0,0,1)),((1,1,0,1)),((0,1,0,1))],
[((0,0,0,1)),((1,0,0,1)),((1,2,0,1)),((0,1,0,1))],
[((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((-1,1,0,1))]
]
@zeffii
zeffii / shapekeys_blender_scripting.py
Created August 10, 2011 12:45
scripting shapekey blender 2.5
import bpy
from mathutils import Vector
listOfVectors = [((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((0,1,0,1))]
shapes = [ [((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((0,1,0,1))],
[((0,0,0,1)),((2,0,0,1)),((1,1,0,1)),((0,1,0,1))],
[((0,0,0,1)),((1,0,0,1)),((1,2,0,1)),((0,1,0,1))],
[((0,0,0,1)),((1,0,0,1)),((1,1,0,1)),((-1,1,0,1))]
]
@zeffii
zeffii / example_modified.pde
Created December 9, 2011 22:15
super class and inheritance
// super class
import java.util.ArrayList;
class GraphicsObject {
PVector pos;
int overthreshold = 2;
GraphicsObject(PVector _pos) {
pos = _pos;
}
@zeffii
zeffii / imgur_upload_v001.py
Created February 19, 2012 13:07
imgur upload python 3 without external modules
from xml.dom import minidom
from urllib.parse import urlencode
from urllib.request import urlopen
import base64
import os
def upload_image(path_to_image):
url = 'http://api.imgur.com/2/upload.xml'
apikey = '-------- your API key ---------'
@davidchambers
davidchambers / to_hash.coffee
Created April 1, 2012 06:02
Dictionary comprehensions in CoffeeScript
to_hash = (pairs) ->
hash = {}
hash[key] = value for [key, value] in pairs
hash
# usage:
to_hash ([n, n * n] for n in [0..5]) # {0:0, 1:1, 2:4, 3:9, 4:16, 5:25}
@zeffii
zeffii / vertex_colour_remap.py
Created June 16, 2012 19:12
vertex_colors_bmesh_remapping_to_height
# vertex_color_from_z_height.py
import bpy
import random
from mathutils import Color, Vector
def remap(current, lower_old, upper_old, lower_new, upper_new):
'''
Remaps one range of values to another range of values, types must be float
@zeffii
zeffii / terminal_colours.py
Created June 17, 2012 10:16
colour printing in terminal.py
# http://www.linuxhomenetworking.com/forums/showthread.php/1095-Linux-console-Colors-And-Other-Trick-s
def printWarning(input):
print("\033[31m%s\033[0m" % input)
def funkyprint(input):
print("\033[36m%s\033[0m" % input)