Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block hodbby

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2930375
<script type="text/javascript">
function StaffMember(name,discountPercent){ = name;
this.discountPercent = discountPercent;
View gist:2922681
<script type="text/javascript">
document.write ("This is Balckjack game.</br>");
document.write ("The points are as follow:</br>");
document.write ("Ace(1) = 11.</br>");
document.write ("King(12), Queen(11) and Prince(10) = 10.</br>");
document.write ("The rest by their own number values.</br></br>");
View gist:2922600
<head><title>Address Book</title></head>
<script type="text/javascript">
var contacts = [];
function printPerson (person) {
document.write("First Name is: " + person.firstName)
document.write("</br>Last Name is: " + person.lastName)
View gist:2922429
<head><title>Roll the Dice</title></head>
<script type="text/javascript">
var die1 = Math.floor(Math.random()*6 + 1);
var die2 = Math.floor(Math.random()*6 + 1);
var score;
// This time if either die roll is 1 then score should be 0
View gist:2922328
<script type="text/javascript">
document.write ("Counting 1 to 100, when ever number devide in 3 it is fuzz, when number devide in 5 it is buzz and both are fizzbuzz... ");
document.write (" ");
for (i=1; i<=100; i++) {
View gist:2823244
<head><title>simple page</title></head>
<h1 id="header">This is JavaScript</h1>
<script type="text/javascript">
document.write('Hello World!');
var h1 = document.getElementById("header"); // holds a reference to the <h1> tag
h1 = document.getElementsByTagName("h1")[0]; // accessing the same <h1> element
View gist:1993457
def extract_names(filename):
Given a file name for baby.html, returns a list starting with the year string
followed by the name-rank strings in alphabetical order.
['2006', 'Aaliyah 91', Aaron 57', 'Abagail 895', ' ...]
# +++your code here+++
# LAB(begin solution)
# The list [year, name_and_rank, name_and_rank, ...] we'll eventually return.
names = []
View gist:1993415
def find_year (filename):
file1 = open (filename, 'rU')
match = re.findall (r'>Popularity in ([\d]+)<',
return match
def find_name_and_rank (filename):
View gist:1814587
import sys
def calculate_data (line_data):
# Got a sring and creates dictionary of (word : count)
dict = {}
for word in line_data:
if word in dict:
dict[word] += 1
dict[word] = 1
hodbby / gist:1808362
Created Feb 12, 2012
text- wordcount task
View gist:1808362
# Define print_words(filename) and print_top(filename) functions.
# You could write a helper utility function that reads a file
# and builds and returns a word/count dict for it.
# Then print_words() and print_top() can just call the utility function.
1. For the --count flag, implement a print_words(filename) function that counts
how often each word appears in the text and prints:
word1 count1
word2 count2
You can’t perform that action at this time.