Skip to content

Instantly share code, notes, and snippets.

Steven B. Combs' Git stevencombs

Block or report user

Report or block stevencombs

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
@stevencombs
stevencombs / BBedit-Preview-in-Marked.applescript
Last active Dec 15, 2015 — forked from collindonnell/BBedit-Preview-in-Marked.scpt
Open the current BBedit Markdown or HTML file in Marked.
View BBedit-Preview-in-Marked.applescript
-- Preview the currently active BBEdit document using Marked. For easy access, add as a service.
tell application "BBEdit"
activate
-- Ask BBEdit for it's active document.
set the_document to active document of text window 1
-- If the file doesn't alreay exist, ask the user to save it.
if not the_document's on disk then
@stevencombs
stevencombs / CodecademyPygLatin.py
Last active Feb 17, 2018
Solution to Codecademy (http://www.codecademy.com) Python Pig Latin Assignment.
View CodecademyPygLatin.py
# Convert a normal word to pig latin
# A Codecademy Python assignment (that drove many nuts!)
# Dr. Steven B. Combs, coding novice
pyg = 'ay' # create a variable that contains 'ay'
original = raw_input('Enter a word: ') # request input from the user
if len(original) > 0 and original.isalpha(): # does the variable contain any, and if so, only alpha characters
word = original.lower() # convert variable original to all lower case characters
@stevencombs
stevencombs / ZenPython.md
Created Aug 9, 2013
The Zen of Python is an Easter egg found within the Python 2.7 interpreter. To view the text found below, execute the following code within Python: import this
View ZenPython.md

The Zen of Python, by Tim Peters

  • Beautiful is better than ugly.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.
  • Sparse is better than dense.
  • Readability counts.
  • Special cases aren't special enough to break the rules.
@stevencombs
stevencombs / 50x50HTML5Blocks.html
Last active Dec 20, 2015
Sample CSS file that creates multiple 50px by 50px squares of varying color. The yellow square is a link.
View 50x50HTML5Blocks.html
<!--
Sample CSS file that creates multiple 50px by 50px squares of varying color. The yellow square is a link.
A Codecademy HTML5 assignment
Dr. Steven B. Combs, HTML5 novice
-->
<!DOCTYPE html>
<html>
<head>
<title>Result</title>
@stevencombs
stevencombs / SplatArguments.py
Last active Dec 20, 2015
Splat (*) arguments example from Codecademy. A splat argument allows for an unknown quantity of arbitrary arguments to be processed in a function.
View SplatArguments.py
# Sample function that utilizes the splat (*) argument to accept multiple input strings
# A Codecademy Python assignment
# Dr. Steven B. Combs, coding novice
def favorite_actors(*actors):
"""Prints out your favorite actorS (plural!)"""
print "Your favorite actors are:" , actors
favorite_actors("Michael Palin", "John Cleese", "Graham Chapman")
@stevencombs
stevencombs / SquareNumberFunction.py
Last active Dec 20, 2015
A sample Python function that squares a number.
View SquareNumberFunction.py
# Sample function code to square a number
# Identical to the sqrt function in the math module
# Dr. Steven B. Combs, coding novice
def square(n):
"""Returns the square of a number."""
squared = n**2
print "%d squared is %d." % (n, squared)
return squared
@stevencombs
stevencombs / CubeNumberDivisibleBy3.py
Last active Jun 9, 2018
This code is the solution to the Codecademy Python Function Syntax Assignment: Practice Makes Perfect.
View CubeNumberDivisibleBy3.py
# Cube a number if divisible by three with no remainder
# A Codecademy Python assignment
# Dr. Steven B. Combs, coding novice
def cube(n):
"""Cube a number"""
n = n ** 3 # Cube the number
print n # Print the number
return n # Return
@stevencombs
stevencombs / ImportModules.py
Last active Dec 20, 2015
Python module basics
View ImportModules.py
# Collection of notes that describe module and function useage
# Dr. Steven B. Combs, coding novice
# Import basics
import module # Imports a module
from module import function # Imports a single function from a module
from module import * # Imports all functions from a module
# Import samples
import math # Imports the math module
View ShutdownFunctionsReview.py
# Shutdown Function
# A Codecademy Python (Review: Functions) assignment
# Dr. Steven B. Combs, coding novice
def shut_down(s):
if s.lower() == "yes":
return "Shutting down..."
elif s.lower() == "no":
return "Shutdown aborted!"
else:
View BuiltInFunctionsReview.py
# Number is Integer or Float - return Absolute Function
# A Codecademy Python (Review: Built-In Functions) assignment
# Dr. Steven B. Combs, coding novice
def distance_from_zero(a):
"""Integer or Float to Absolute"""
if type(a) == int or type(a) == float:
return abs(a)
else:
return "Not an integer or float!"
You can’t perform that action at this time.