Skip to content

Instantly share code, notes, and snippets.

View macloo's full-sized avatar
💭
Teaching some Python

Mindy McAdams macloo

💭
Teaching some Python
View GitHub Profile
@macloo
macloo / index.html
Created April 11, 2013 13:40
A CodePen by Mindy McAdams. Number - This is a simple exercise for people who are beginning to learn JavaScript. You need to write a new function (in JavaScript) that will play a number guessing game with the user.
<h1>Number</h1>
<p>Here is something to get you started:</p>
<button onclick="alertThem();">Alert</button>
<button onclick="confirmIt();">Confirm</button>
<button onclick="promptThem();">Prompt</button>
<p>Your challenge is this: Create a little game with an HTML page, a confirm dialog box and JavaScript.
@macloo
macloo / index.html
Last active December 16, 2015 02:38
A CodePen by Mindy McAdams. Simple Horizontal Nav - Buttons in a row, suitable for top navigation on a website
<!-- Simple navigation button set
Not responsive
Aligns to right -->
<div id="nav">
<ul>
<li><a href="#">Home</a></li>
<li id="inactive-link">About</li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Websites</a></li>
@macloo
macloo / index.html
Created April 11, 2013 14:52
A CodePen by Mindy McAdams. Canvas and setInterval - Create a grid of squares that all change color endlessly, on a 500ms timer.
<canvas id="myCanvas" width="600" height="320">
<p>Some default content can appear here.</p>
</canvas>
@macloo
macloo / index.html
Last active December 16, 2015 02:39
A CodePen by Mindy McAdams. Canvas techniques - Mark points on a grid - write text on the canvas - get familiar with the coordinates.
<p>Using the canvas to understand the canvas:</p>
<canvas id="myCanvas" width="601" height="401">
<p>Some default content can appear here.</p>
</canvas>
# Put this in the root directory of your repository in a file called
# "Makefile". When you're ready to re/publish, just open terminal, cd
# to the directory containing your repo and type "make publish". As
# you can see, it's just a bunch of commands so you can easily add
# more steps to this workflow. Idea by Jeff Larson
publish:
git checkout gh-pages
git merge master
git push origin gh-pages
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
#Twitter API credentials
consumer_key = ""
consumer_secret = ""
access_key = ""
@macloo
macloo / ftponefile.py
Last active December 16, 2015 14:08
Python FTP script for uploading a single file
import ftplib
session = ftplib.FTP('HOSTNAME','USERNAME','PASSWORD')
session.cwd('//DIR//DIR//DIR//')
f = open('Downloads/picture.jpg', 'r')
session.storbinary('STOR pic2.jpg', f)
f.close()
session.quit()
# http://www.pythonforbeginners.com/code-snippets-source-code/how-to-use-ftp-in-python/
# 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):
@macloo
macloo / modulo.py
Created December 17, 2013 16:15
Simple example of using modulo (modulus) to test for a prime number.
# 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)
@macloo
macloo / lists.py
Last active December 31, 2015 15:39
Introductory script for adding items to a list in Python.
# 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) > ")