This file contains hidden or 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
| ################################################################################ | |
| # Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved. # | |
| # Leap Motion proprietary and confidential. Not for distribution. # | |
| # Use subject to the terms of the Leap Motion SDK Agreement available at # | |
| # https://developer.leapmotion.com/sdk_agreement, or another agreement # | |
| # between Leap Motion and you, your company or other organization. # | |
| ################################################################################ | |
| import Leap, sys | |
| from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture |
This file contains hidden or 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
| # | |
| # Receive hand & finger data from "LeapSample.py" via UDP and render it in 2D | |
| # | |
| from pyglet.gl import * | |
| # Create a UDP socket to receive the data | |
| import socket | |
| insock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| # Listen to port 5000 | |
| insock.bind(('',5000)) |
This file contains hidden or 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 pyglet.gl import * | |
| window = pyglet.window.Window() | |
| class Hand: | |
| def __init__(self): | |
| self.pos = [0,0,0] | |
| self.ori = [0,0,0] | |
| self.geom = pyglet.graphics.vertex_list(4, ('v2f', [-15,-10, 15,-10, 20,10, -20,10])) | |
| def draw(self): |
This file contains hidden or 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 pyglet.gl import * | |
| from math import * | |
| tex = pyglet.image.load('biosphere.png').get_texture() | |
| vlists = [] | |
| for lat in range(-90,90,30): | |
| verts = [] | |
| texc = [] | |
| for lon in range(-180,181,30): |
This file contains hidden or 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
| # Query the example "world" database using MySQLdb | |
| import MySQLdb | |
| db = MySQLdb.connect(host='localhost', port=3306, user='myusername', passwd='mypassword', db='world') | |
| cur = db.cursor() | |
| cur.execute("SELECT ID, Name, Population from City order by Name limit 3") |
This file contains hidden or 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
| # Perform an 'update' query on the sample database, with data input by the user | |
| import MySQLdb | |
| db = MySQLdb.connect(host='localhost', port=3306, user='myusername', passwd='mypassword', db='world') | |
| cur = db.cursor() | |
| print 'enter new name for City 1:' | |
| newname = raw_input() |
This file contains hidden or 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 | |
| # Simple CGI python script that generates a web page dynamically | |
| print '''Content-type: text/html | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>HTML form example</title> | |
| </head> | |
| <body> | |
| <form method="post" action="world.cgi"> | |
| Country name? <input type="text" name="name" size="40" value=""> | |
| <br> |
This file contains hidden or 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 | |
| # Query the 'world' database for a country whose name (or partial name) was entered via queryform.html | |
| import MySQLdb | |
| db = MySQLdb.connect(host='localhost', port=3306, user='myusername', passwd='mypassword', db='world') | |
| cur = db.cursor() | |
| cur.execute("set names 'utf8'") |
This file contains hidden or 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
| # Script to insert a new city into the example 'world' database | |
| import MySQLdb | |
| db = MySQLdb.connect(host='localhost', port=3306, user='myusername', passwd='mypassword', db='world') | |
| cur = db.cursor() | |
| print "enter new city's name:" | |
| name = raw_input() | |
| print "enter new city's country code:" |