Skip to content

Instantly share code, notes, and snippets.

View stevencombs's full-sized avatar

Steven B. Combs' Git stevencombs

View GitHub Profile
@stevencombs
stevencombs / BBedit-Preview-in-Marked.applescript
Last active December 15, 2015 08:49 — forked from collindonnell/BBedit-Preview-in-Marked.scpt
Open the current BBedit Markdown or HTML file in Marked.
-- 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 / ZenPython.md
Created August 9, 2013 00:10
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

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 December 20, 2015 20:28
Sample CSS file that creates multiple 50px by 50px squares of varying color. The yellow square is a link.
<!--
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 December 20, 2015 21:18
Splat (*) arguments example from Codecademy. A splat argument allows for an unknown quantity of arbitrary arguments to be processed in a function.
# 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 December 20, 2015 21:19
A sample Python function that squares a number.
# 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 / ImportModules.py
Last active December 20, 2015 21:28
Python module basics
# 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
# Function to determine if number is odd or even
# A Codecademy Python (Function and Control) assignment
# Dr. Steven B. Combs, coding novice
def is_even(x):
if x % 2 == 0: # If varialble is divisible by 2 without remainder
return "yep" # The variable is even
else:
return "nope"
# 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:
# 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!"
# Function to determine the minimum payment
# A Codecademy Python (Something of Interest) assignment
# Dr. Steven B. Combs, coding novice
def hotel_cost(nights):
return nights * 140
bill = hotel_cost(5)
def get_min(balance,rate):