Skip to content

Instantly share code, notes, and snippets.

View bbookman's full-sized avatar

Bruce Bookman bbookman

View GitHub Profile
@bbookman
bbookman / Info.plist
Last active September 5, 2018 17:52
Snapchat Snap Kit Properties List Requirements
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

Keybase proof

I hereby claim:

  • I am bbookman on github.
  • I am trentreznor (https://keybase.io/trentreznor) on keybase.
  • I have a public key ASAuct0Zg4DPo-WHmFXV3e47Xt9K7ZD2wnE-8ZKJauVCQAo

To claim this, I am signing this object:

@bbookman
bbookman / div7
Created December 26, 2018 21:39
Python List Comprehension: Find all of the numbers from 1-1000 that are divisible by 7
'''
Find all of the numbers from 1-1000 that are divisible by 7
'''
div7 = [n for n in range(1,1000) if n % 7 == 0]
print(div7)
@bbookman
bbookman / consonants.py
Created December 26, 2018 21:54
Python List Comprehension: Consonants in a string
'''
Create a list of all the consonants in the string "Yellow Yaks like yelling and yawning and yesturday they yodled while eating yuky yams"
'''
sentence = "Yellow Yaks like yelling and yawning and yesturday they yodled while eating yuky yams"
result = [letter for letter in sentence if letter not in 'a,e,i,o,u, " "']
@bbookman
bbookman / common_nums.py
Created December 26, 2018 22:06
Python List Comprehension: Find common numbers in two lists of numbers
'''
Find the common numbers in two lists (without using a tuple or set) list_a = [1, 2, 3, 4], list_b = [2, 3, 4, 5]
'''
list_a = [1, 2, 3, 4]
list_b = [2, 3, 4, 5]
common = [a for a in list_a if a in list_b]
print(common)
@bbookman
bbookman / even_odd.py
Created December 26, 2018 22:41
Python List Comprehension: Determine even or odd in list of numbers
'''
Given numbers = range(20), produce a list containing the word 'even' if a number in the numbers is even, and the word 'odd' if the number is odd. Result would look like ['odd','odd', 'even']
'''
result = ['even' if n%2 == 0 else 'odd' for n in range(20)]
print(result)
'''
Let's see the for loop and break out the syntax of the list comprehension
@bbookman
bbookman / common_tuples.py
Created December 26, 2018 22:54
Python List Comprehension: Common number tuples
'''
Produce a list of tuples consisting of only the matching numbers in these lists list_a = [1, 2, 3,4,5,6,7,8,9], list_b = [2, 7, 1, 12]. Result would look like (4,4), (12,12)
'''
list_a = [1, 2, 3,4,5,6,7,8,9]
list_b = [2, 7, 1, 12]
result = [(a, b) for a in list_a for b in list_b if a == b]
print(result)
@bbookman
bbookman / words_more_than_4.py
Created December 26, 2018 23:06
Python List Comprehension: Find words with more than 4 letters
'''Find all of the words in a string that are less than 4 letters'''
sentence = 'On a summer day somner smith went simming in the sun and his red skin stung'
examine = sentence.split()
result = [word for word in examine if len(word) >=4]
print(result)
@bbookman
bbookman / findThree.py
Created December 26, 2018 21:41
Python List Comprehension: Find all of the numbers from 1-1000 that have a 3 in them
'''
Find all of the numbers from 1-1000 that have a 3 in them
'''
three = [n for n in range(0,1000) if '3' in str(n)]
print(three)
@bbookman
bbookman / index_value.py
Created December 26, 2018 21:57
Python List Comprehension: Get index and value from list
'''
Get the index and the value as a tuple for items in the list ["hi", 4, 8.99, 'apple', ('t,b','n')]. Result would look like [(index, value), (index, value)]
'''
items = ["hi", 4, 8.99, 'apple', ('t,b','n')]
result = [(index, item) for index, item in enumerate(items)]
print(result)