This file contains hidden or 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
function task1() { | |
var taskImage = document.getElementsByTagName('img')[0]; | |
taskImage.src = "http://placekitten.com/g/200/200" | |
var taskHeader = document.getElementById('taskHeader') | |
taskHeader.style.color = 'red' | |
} | |
function task2() { |
This file contains hidden or 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> | |
<head> | |
<title>JAMstack</title> | |
</head> | |
<body> | |
<div id="task1wraper"> | |
<h1 id="taskHeader">Task 1</h1> |
This file contains hidden or 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 script is an example of how to simplify the creation, activation and deactivation of Python virtual environments. | |
alias we="which python" | |
alias ae='deactivate &> /dev/null; source ./venv/bin/activate' | |
alias de="deactivate" | |
# Function to create an environment and optionally set a custom prompt | |
ce() { | |
if [ -z "$1" ] # If the first parameter is an empty string (i.e no parameter supplied) | |
then |
This file contains hidden or 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
""" | |
Exercises for Programmers: 57 Challenges to Develop Your Coding Skills. | |
Exercise 37: Password Generator. | |
Requirements: | |
- Create a program to generate a secure password. | |
- Prompt for length, number of special characters, and the number of numeric chars. | |
Constraints: | |
- Store characters used to generate passwords in lists. |
This file contains hidden or 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
""" log parser | |
Accepts a filename on the command line. The file is a linux-like log file | |
from a system you are debugging. Mixed in among the various statements are | |
messages indicating the state of the device. They look like: | |
Jul 11 16:11:51:490 [139681125603136] dut: Device State: ON | |
The device state message has many possible values, but this program only | |
cares about three: ON, OFF, and ERR. | |
Your program will parse the given log file and print out a report giving | |
how long the device was ON, and the time stamp of any ERR conditions. | |
""" |
This file contains hidden or 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
""" | |
A series of examples of list operations for Dad! | |
EXAMPLE 1 | |
Start with a list of three lists: [[1,2,3], [4,5,6], [7,8,9]] | |
End with new lists for each position in the old list. | |
""" | |
# a list of lists, each three items long. | |
old_list = [ |
This file contains hidden or 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
""" | |
Specification: | |
A function initDeck which creates a list Deck of 52 entries containing the numbers 1-52. Needs to be recallable so delete or overwrite Dec. | |
Second function Deal which randomises the order of list Deck, then in a loop 1-13 creates or overwrites a two-dimensional array Hand[0-3][0-12] by copying the value in the next entry in Deck. | |
Master routine to call both and print out the values in Hand. | |
Deck and Hand to be global. | |
""" | |
import random | |
def init_deck(): | |
""" |
This file contains hidden or 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 random | |
import sys | |
class Deck: | |
def __init__(self, number_of_cards): | |
self.number_of_cards = number_of_cards | |
self.reset() | |
def reset(self): | |
self.cards = [] |
This file contains hidden or 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
""" | |
Specification: | |
A function initDeck which creates a list Deck of 52 entries containing the numbers 1-52. Needs to be recallable so delete | |
or overwrite Dec. | |
Second function Deal which randomises the order of list Deck, then in a loop 1-13 creates or overwrites a two-dimensional | |
array Hand[0-3][0-12] by copying the value in the next entry in Deck. | |
Master routine to call both and print out the values in Hand. | |
Deck and Hand to be global. | |
""" | |
import random |
This file contains hidden or 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
""" | |
Write a function that takes an ordered list of numbers (a list where the elements are in order from smallest to | |
largest) and another number. The function decides whether or not the given number is inside the list and returns | |
(then prints) an appropriate boolean. | |
Extras: Use binary search. | |
NOTE: I created an option to compare the time taken by three different search methods. | |
""" | |
import random, time, sys |