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
<div class="row"> | |
<div class="col-xs-12 text-center"> | |
<h2>Select version:</h2> | |
<div class="btn-group" data-toggle="buttons"> | |
<label id="esv" class="btn btn-primary active"> | |
<input type="radio" autocomplete="off">ESV | |
</label> | |
<label id="kjv" class="btn btn-primary"> | |
<input type="radio" autocomplete="off">KJV | |
</label> |
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
// produce a data string in this format: 2015-12-17 01:31:39 | |
function getDate() { | |
var date = new Date(); | |
timestamp = date.getUTCFullYear() + '-' + | |
('00' + (date.getUTCMonth() + 1)).slice(-2) + '-' + | |
('00' + date.getUTCDate()).slice(-2) + ' ' + | |
('00' + date.getUTCHours()).slice(-2) + ':' + | |
('00' + date.getUTCMinutes()).slice(-2) + ':' + | |
('00' + date.getUTCSeconds()).slice(-2); |
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
# testing for a prime number - use of modulo (modulus) | |
# also, a good example (for beginners) of use of a while loop | |
# journalism students often ask how one would use modulo - this shows them one case | |
n = 0 | |
print "\nWe will test a number to find out whether it is prime." | |
print "Try it with 25. Then try it with 7 or 13." | |
n = raw_input("Enter a whole number: ") | |
def testfor100(a): |
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
# testing for a prime number - use of modulo (modulus) | |
# also, good example of a for loop | |
n = 0 | |
print "\nWe will test a number to find out whether it is prime." | |
print "Try it with 25. Then try it with 7 or 13." | |
print "Then try it with any number you like (but not too large a number!)." | |
n = raw_input("Enter a number: ") | |
n = int(n) |
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
# some things we do with lists | |
userlist = [] # makes an empty list | |
q = "n" | |
x = "a" | |
while q == "n": | |
e = raw_input("Add an element: ") | |
userlist.append(e) | |
q = raw_input ("Do you want to quit? (y/n) > ") |
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
import sys | |
scores = {"A": 1, "C": 3, "B": 3, "E": 1, "D": 2, "G": 2, | |
"F": 4, "I": 1, "H": 4, "K": 5, "J": 8, "M": 3, | |
"L": 1, "O": 1, "N": 1, "Q": 10, "P": 3, "S": 1, | |
"R": 1, "U": 1, "T": 1, "W": 4, "V": 4, "Y": 4, | |
"X": 8, "Z": 10} | |
# Get the Scrabble rack from the command line. | |
if len(sys.argv) < 2: |
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
# see http://bit.ly/mmpython2 for the quiz | |
# compare the way this runs to the way argv_test2.py runs | |
# to run: | |
# python argv_test1.py first.txt | |
from sys import argv | |
script, filename = argv | |
txt = open(filename) |
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
# this is the answer to questions 16 and 17 in Practice with Python, Part 2 - Self-Quiz | |
# see http://bit.ly/mmpython2 for the quiz | |
def myname(): | |
print 'Mindy' | |
print 'McAdams' | |
def anyname(a, b): | |
print a | |
print b |
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
<?php | |
// $conn comes from a separate database connection file | |
// this is a partial, nonworking file | |
try { | |
// Let's begin a transaction | |
mysqli_begin_transaction($conn, MYSQLI_TRANS_START_READ_ONLY); | |
// There can be a set of queries | |
// If any one fails, an exception should be thrown |
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
<?php | |
// this is a partial, nonworking file | |
$salt1 = "qm&h*"; | |
$salt2 = "pg!@"; | |
$first_name = "Bill"; | |
$last_name = "Smith"; | |
$username = "bsmith"; | |
$password = "secret"; | |
$token = hash('ripemd128', "$salt1$password$salt2"); |