Skip to content

Instantly share code, notes, and snippets.

View pdpinch's full-sized avatar

Peter Pinch pdpinch

View GitHub Profile
@pdpinch
pdpinch / index.html
Created March 31, 2012 15:05
Test of LRMI application to MIT OCW 14.01SC
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Traditional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" xmlns:fb="http://www.facebook.com/2008/fbml"
xmlns:og="http://opengraphprotocol.org/schema/">
@pdpinch
pdpinch / rps.py
Created September 25, 2012 11:57
6.189 Exercise 1.7
# Exercise 1.7
# Rock, Paper Scissors game
## TODO: lower case user input
player1 = raw_input('Player 1? ')
# make sure player1's play is one of rock, paper or scissors
while (player1 != 'rock' and player1 != 'paper' and player1 != 'scissors'):
print "You wrote: " + player1
player1 = raw_input('Please enter one of the following, "rock", "paper" or "scissors": ')
@pdpinch
pdpinch / cipher.py
Created September 29, 2012 01:27
6.189 Exercise Opt.2
# OPT.2 from http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-189-a-gentle-introduction-to-programming-using-python-january-iap-2011/assignments/MIT6_189IAP11_hw1.pdf
# Secret Messages
phrase = raw_input("Enter sentence to encrypt: ")
shift = input("Enter shift value: ")
encoded_phrase = ''
for c in phrase:
ascii = ord(c)
if 97 <= ascii < (97+26):
# ********** Exercise 2.5 **********
# code for roots function
# given the coefficients for a quadratic equation
# returns the two roots
# if the roots are complex, exit
def find_roots(a,b,c):
# give up if the roots are complex
assert not roots_are_complex(a,b,c)
d = math.sqrt(b**2 - 4*a*c)
@pdpinch
pdpinch / gist:3950247
Created October 25, 2012 03:23
old /about page
<div style="padding-left: 7px; background-image: url(&quot;/about/about-banner.jpg&quot;); background-repeat: no-repeat;"><br />
<br />
<h1>Unlocking Knowledge,<br />
Empowering Minds.</h1>
<p>Free lecture notes, exams, and videos from MIT. No registration required.</p>
<p>&nbsp;</p>
</div>
<p>&nbsp;</p>
<p>MIT OpenCourseWare (OCW) is a web-based publication of virtually all MIT course content. OCW is open and available to the world and is a permanent MIT activity.</p>
<h2 class="subhead">What is MIT OpenCourseWare?</h2>
@pdpinch
pdpinch / gist:3975472
Created October 29, 2012 18:25
source for /about/presidents-message/ pre-Reif
<div style="FLOAT: left; WIDTH: 325px" class="photo"><img width="300" border="0" height="192" style="PADDING-RIGHT: 25px; PADDING-BOTTOM: 7px; PADDING-TOP: 8px" alt="MIT President Susan Hockfield." src="/about/presidents-message/kennedyhockfield_sm.jpg" /><br />
<div style="PADDING-RIGHT: 25px; FONT-SIZE: 0.7em; PADDING-BOTTOM: 7px" class="caption instruction">MIT President Emeritus Susan Hockfield</div>
</div>
<p style="MARGIN-RIGHT: 20px">The goal of advancing education around the world is shared by the MIT Faculty. Indeed, we owe the existence of OpenCourseWare to the foresight, dedication, and generosity of our faculty. In the year 2000, a faculty committee first proposed this bold and innovative idea, and since then, the vast majority of our faculty&ndash;over 90%&ndash;have voluntarily contributed their teaching materials for free and open publishing on OCW. MIT faculty are passionate about their teaching, and they are keen to see their work benefit global society.</p>
<p>We do not yet know the full pot
@pdpinch
pdpinch / battleship.py
Created October 30, 2012 00:58
Codecademy Battleship game
import random
board = []
for x in range(0,5):
board.append(["O"] * 5)
def print_board(board):
for row in board:
print " ".join(row)
# ********** Exercise 2.8 **********
import math
def report_card():
##### YOUR CODE HERE #####
count_classes = int(input("How many classes did you take? "))
grade_book = {}
total = 0
@pdpinch
pdpinch / gist:4075142
Created November 14, 2012 22:03
Footer portlet
<div id="bottom">
<div id="grid"><!-- *begin footer* -->
<div id="footer" role="navigation sitemap">
<div id="foot-c1" class="grid_2 alpha">
<h4 class="footer">Courses</h4>
<ul class="foot-bullet">
<li><a href="/courses/find-by-topic/">Find by Topic</a></li>
<li><a href="/courses/find-by-number/">Find by Course Number</a></li>
<li><a href="/courses/find-by-department/">Find by Department</a></li>
<li><a href="/courses/audio-video-courses/">Audio/Video Courses</a></li>
@pdpinch
pdpinch / gist:4080312
Created November 15, 2012 18:31
OCW Stories snippet
<p><a id="top" name="top"></a>Do you have an OCW story? <a href="http://ocw.mit.edu/jsp/feedback.jsp?Referer=User_Stories">Share it with us</a>.</p>
<p><a href="#students">Students</a> | <a href="#educators">Educators</a> | <a href="#self-learners">Self Learners</a> | <a href="#supporters">OCW Supporters</a></p>
<p>&nbsp;</p>
<div class="clear">&nbsp;</div>
<h2 class="subhead"><a id="students" name="students"></a>Students</h2>
<p><img alt="Photo of user Kunle Adejumo." style="padding-bottom: 40px; padding-right: 15px; float: left" src="/about/ocw-stories/kunle_th.jpg" /><a href="/about/ocw-stories/kunle-adejumo">Kunle Adejumo</a><br />
Student<br />
Nigeria<br />
<br />
Kunle Adejumo is finishing his fourth year of engineering studies at Ahmadu Bello University in Zaria, Nigeria. By all rights, he should now be in his fifth and final year, but local strikes and instability in Nigeria have added almost a full year to his studies at Ahmadu Bello. <a href="/about/ocw-stories/kunle-adejumo">Read more</a>.</p>