Skip to content

Instantly share code, notes, and snippets.

View pcote's full-sized avatar
🏠
Working from home

Emma Cote pcote

🏠
Working from home
View GitHub Profile
@pcote
pcote / grease_pencil_scripting.py
Created October 23, 2011 18:06
An example of Python scripting using gease pencil scripting for Blender. A partial re-invention of the "Convert Grease Pencil" operator.
def make_basic_curve():
crv = bpy.data.curves.new("crv", type="CURVE")
crv_ob = bpy.data.objects.new("crv_ob", crv)
return crv, crv_ob
scnobs = bpy.context.scene.objects
pencil = bpy.data.grease_pencil[0]
for i, stroke in enumerate(pencil.layers[0].active_frame.strokes):
@pcote
pcote / reddit_test.py
Created March 8, 2012 01:13
An experiment working with the reddit web services api
# reddit_test.py
import urllib.request
import json
from pdb import set_trace
from time import sleep, time
def timeit( func2wrap ):
def wrapped_func(*args):
start_time = time()
res = func2wrap(*args)
@pcote
pcote / top_200_pony_entries.py
Created March 11, 2012 21:57
Grabs the top 200 submission entries from the My Little Pony Subreddit at reddit.com and throws is into a MySQL database where I can analyze the data.
#top_200_pony_entries.py
import urllib
from pdb import set_trace
import time
import MySQLdb
import json
import pickle
mysql = MySQLdb
@pcote
pcote / lamps_on_verts.py
Created March 29, 2012 23:43
Sticks lamps on verts of a mesh object. Kind of a silly project, actually.
import bpy
# lamps_on_verts.py
# desc: throws a point lamp on every vert of a selected object.
class LampVertOperator(bpy.types.Operator):
'''Tooltip'''
bl_idname = "object.lamp_vert_operator"
bl_label = "Lamp on Verts Operator"
@pcote
pcote / bmesh_quat_samp.py
Created April 24, 2012 08:14
Sample Mesh Generation using Quaternions and BMesh
import bmesh
import bpy
from mathutils import Quaternion, Vector
bm = bmesh.new()
axis = (0,0,-1)
quats = [Quaternion(axis,x) for x in range(1,11)]
vecs = [quat * Vector((1,0,0)) for quat in quats]
for vec in vecs:
@pcote
pcote / bezier_coil.py
Created May 9, 2012 19:43
Blender addon that generates coiled bezier curves.
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@pcote
pcote / matrix_op.py
Created June 16, 2012 03:55
A simple experimental operator for messing with matrix basics.
"""
matrix_op.py
A simple experimental operator for messing with matrix basics.
"""
import bpy
from bpy.props import FloatProperty
from math import pi
class MatrixOp(bpy.types.Operator):
@pcote
pcote / hn_screen_scraper.py
Created June 28, 2012 19:52
Screen scraper that Pulls URLs and Titles from the Front Page of Hacker News
# hn_screen_scraper.py
# A screen scraper for the front page of hacker news done out of a fit of boredom.
from urllib import request
import re
# read in the data and split it into a raw list of entries
url_path = "http://news.ycombinator.com"
sock = request.urlopen(url_path)
raw_data = str(sock.read())
data_set = re.split("arrow\.gif", raw_data)
@pcote
pcote / post_test.py
Created August 6, 2012 19:43
Python 3 example script for sending data to a web application using the post method.
"""
post_test.py
An example script that shows how to send data by post-method from
command-line to a web application.
"""
import urllib.request as request
import urllib.response as response
import urllib.parse as parse
url_string = "http://localhost:8085/A_WebApp/targetservlet"
@pcote
pcote / image_collector.py
Created August 15, 2012 01:32
An image collecting screen scraper built as an interesting example usage of Beautiful Soup. Done with Python 2.7
"""
image_collector.py
A script to screen scrape an image archive and then download those images
one by one to a local folder. Interesting example usage of BeautifulSoup.
Modify as needed for the site you intend to scrape.
Use only with permission of site owner!!!
Geeky Note: