Skip to content

Instantly share code, notes, and snippets.

View Cr4ck3r's full-sized avatar

Cr4ck3r Cr4ck3r

  • uuuuuuuuhhh
  • Barrow Alaska
View GitHub Profile
@Cr4ck3r
Cr4ck3r / bicycle_model.py
Last active April 3, 2017 15:41
Bicycle Industry Model
class Wheel:
#Have a model name
#Have a weight
#Have a cost to produce
#There should be a total of three different wheel types
def __init__(self,name,weight,cost):
self.name = name
self.weight = weight
self.cost = cost
def rgb_hex():
invalid_msg = "Something went wrong. Check your response."
red = int(raw_input("What is the RED value? "))
if ((red < 0) or (red > 255)):
print invalid_msg
return
green = int(raw_input("What is the GREEN value? "))
if ((green < 0) or (green > 255)):
@Cr4ck3r
Cr4ck3r / class_band.py
Created March 22, 2017 08:55
Band class.
class Bassist(object):
def __init__(self):
self.sounds = ["Twang", "Thrumb", "Bling"]
def solo(self, length):
for i in range(length):
print(self.sounds[i % len(self.sounds)], end=" ")
print()
class Guitarist(object):
@Cr4ck3r
Cr4ck3r / pirate.py
Created March 15, 2017 07:12
pirate bartender
import random
questions = {
"strong": "Do ye like yer drinks strong? ",
"salty": "Do ye like it with a salty tang? ",
"bitter": "Are ye a lubber who likes it bitter? ",
"sweet": "Would ye like a bit of sweetness with yer poison? ",
"fruity": "Are ye one for a fruity finish? "
}
@Cr4ck3r
Cr4ck3r / fizzbuzz_function.py
Created March 7, 2017 04:12
Fizzbuzz as an Importable Function
def fizzbuzz(a):
"""performs fizzbuzz process using a for loop"""
for n in range (1,a+1):
if n % 3 == 0 and n % 5 == 0:
print("FizzBuzz")
elif n % 3 == 0:
print ("Fizz")
elif n % 5 == 0:
print ("Buzz")
else:
@Cr4ck3r
Cr4ck3r / fizzbuzzARGV.py
Created March 5, 2017 03:36
argv version
import sys
if len(sys.argv)< 2:
maxn = int(input("Enter the max: "))
else:
upper = int(sys.argv[1])
n = 0
while n <= maxn:
if n % 5 == 0 and n % 3 == 0:
@Cr4ck3r
Cr4ck3r / fizzbuzz1.py
Last active March 7, 2017 03:55
Fizzbuzz while loop
n = 0
while (n < 101):
if (n % 5 == 0) and (n % 3 == 0):
print ('fizzbuzz')
elif n % 5 == 0:
print ('fizz')
elif n % 3 == 0:
print ('buzz')
else:
@Cr4ck3r
Cr4ck3r / fizzbuzz2.py
Last active March 7, 2017 03:55
fizzbuzz for loop
for n in range(1,101):
if n % 3 == 0 and n % 5 == 0:
print ("fizzbuzz")
elif n % 3 == 0:
print ("fizz")
elif n % 5 == 0:
print ("buzz")
else:
print (n)
@Cr4ck3r
Cr4ck3r / fizzbuzz3.py
Last active March 1, 2017 05:43
Fizzbuzz with only one print python 3
fblist = []
for n in range (1,101):
if n % 3 == 0 and n % 5 == 0:
fblist.append("fizzbuzz")
elif n % 3 == 0:
fblist.append("fizz")
elif n % 5 == 0:
fblist.append("buzz")
else:
@Cr4ck3r
Cr4ck3r / kscow.sh
Last active May 28, 2016 00:06 — forked from lrvick/kscow.sh
Cow contemplating the current total pledged value of a given Kickstarter.
#!/bin/bash
api_url='https://www.kickstarter.com/projects/597507018/pebble-2-time-2-and-core-an-entirely-new-3g-ultra/stats.json'
while sleep 1; do
ks_json=$(curl $api_url -s)
[ $? -ne 0 ] && continue
old_total=$total
total=$(echo $ks_json | jq -r '.project.pledged')
[[ "$total" == "$old_total" ]] && continue