This file contains 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 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 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:" |
This file contains 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 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 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 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
# Demonstration of perspective projection | |
# | |
import sys, time | |
from pyglet.gl import * | |
window = pyglet.window.Window() | |
keys = pyglet.window.key.KeyStateHandler() | |
window.push_handlers(keys) | |
glLineWidth(5.0) |
This file contains 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
# Demonstration of depth buffering | |
# When depth buffering is active, the orbiting yellow planet | |
# will be properly hidden by the blue and red planets as it | |
# passes behind them. | |
# Depth buffering is toggled on & off by pressing the space bar. | |
import sys | |
import time | |
from pyglet.gl import * |
This file contains 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
#pragma strict | |
// Script to warp an existing mesh. | |
// This can be attached to any GameObject that includes a Mesh Filter. | |
// It will move the vertices up and down in Y, based on the sine of the X | |
// value + the time. | |
private var originalVerts : Vector3[]; | |
function Start () |
This file contains 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
#pragma strict | |
// Script to create a mesh with 2 triangles. | |
// This should be attached to an empty GameObject. | |
// It assumes the existence of a custom shader to use the vertex colors | |
// without texture or lighting. | |
function Start () | |
{ | |
gameObject.AddComponent.<MeshFilter>(); |
OlderNewer