Skip to content

Instantly share code, notes, and snippets.

View hodbby's full-sized avatar

Hod hodbby

  • 07:53 (UTC +03:00)
View GitHub Profile
@hodbby
hodbby / gist:2930375
Created June 14, 2012 13:42
cashRegister
<html>
<head><title>cashRegister</title></head>
<body>
<script type="text/javascript">
function StaffMember(name,discountPercent){
this.name = name;
this.discountPercent = discountPercent;
}
@hodbby
hodbby / gist:2922681
Created June 13, 2012 08:04
Blackjack-1
<html>
<head><title>Blackjack</title></head>
<body>
<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>");
@hodbby
hodbby / gist:2922600
Created June 13, 2012 07:44
Address book
<html>
<head><title>Address Book</title></head>
<body>
<script type="text/javascript">
var contacts = [];
function printPerson (person) {
document.write("First Name is: " + person.firstName)
document.write("</br>Last Name is: " + person.lastName)
@hodbby
hodbby / gist:2922429
Created June 13, 2012 06:56
Roll the dice
tml>
<head><title>Roll the Dice</title></head>
<body>
<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
@hodbby
hodbby / gist:2922328
Created June 13, 2012 06:39
Fizz Buzz
<html>
<head><title>FizzBuzz</title></head>
<body>
<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++) {
<html>
<head><title>simple page</title></head>
<body>
<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
</script>
<noscript>
@hodbby
hodbby / gist:1993457
Created March 7, 2012 14:28
goog regex
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 = []
def find_year (filename):
file1 = open (filename, 'rU')
match = re.findall (r'>Popularity in ([\d]+)<', file1.read())
file1.close()
return match
def find_name_and_rank (filename):
@hodbby
hodbby / gist:1814587
Created February 13, 2012 07:21
wordcount
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
else:
dict[word] = 1
@hodbby
hodbby / gist:1808362
Created February 12, 2012 13:00
text- wordcount task
# 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
...