Skip to content

Instantly share code, notes, and snippets.

View Lvl4Sword's full-sized avatar
💚
Whatever you do, do it well.

Scott King Lvl4Sword

💚
Whatever you do, do it well.
View GitHub Profile
import random
foo = [1, 2, 3, 4, 5, 6]
random_selection = lambda: random.choice(foo)
random_selection()
import random
import sys
picked_num = random.randint(1, 10)
counter = 5
def guess_game(counter, picked_num):
while counter:
try:
number = int(input("Please choose a number between 1 and 10: "))
@Lvl4Sword
Lvl4Sword / google_finance.py
Created April 20, 2016 20:09
this needs worked on..
import datetime
import os
import sys
import time
import urllib
from colored import attr
from colored import bg as background
from colored import fg as foreground
from googlefinance import getQuotes
from time import sleep
@Lvl4Sword
Lvl4Sword / csv_email.py
Created April 2, 2016 08:06
E-mailing CSV + Rename + Archive
import datetime
import os
import shutil
import sys
from envelopes import Envelope
def mail_send(files_to_send):
right_now = datetime.datetime.now()
@Lvl4Sword
Lvl4Sword / gen_rand_numbers.py
Last active May 1, 2016 03:45
Simple Psuedo-Random Number Generation
# Using SystemRandom which is cryptographically secure[1],
# this prints out 64 psuedorandom characters for you to use in whatever.
# [1]https://docs.python.org/2/library/random.html
# "( Use os.urandom() or SystemRandom if you require a
# cryptographically secure pseudo-random number generator. )"
import random
import string
import sys
@Lvl4Sword
Lvl4Sword / google_trends.py
Created March 20, 2016 08:17
Google Trends Search
@Lvl4Sword
Lvl4Sword / bmi.py
Last active September 16, 2018 05:22
Body Mass Index ( Imperial AND Metric )
#!/usr/bin/env python3
import sys
complete = False
print('Ctrl+C / Ctrl+D to quit at anytime')
def bmi():
try:
measurement_type = input('(I)mperial or (M)etric?: ')
@Lvl4Sword
Lvl4Sword / ddg_ip.py
Created March 20, 2016 08:16
DuckDuckGo IP Lookup
import requests
import json
raw = requests.get('https://api.duckduckgo.com/?q=ip&format=json')
raw_json = json.loads(raw.text)
answer = raw_json["Answer"].split(' ')
print (' '.join(answer[:5]))
@Lvl4Sword
Lvl4Sword / rand_dict.py
Last active March 20, 2016 08:18
Print Random Values In A Dict Key
# like this :-)
# doesn't work for nested lists :-(
import random
my_dict = {'lol': [1, 2, 3, 4], 'wut': [5, 6, 7]}
print(random.choice(sum(my_dict.values(), [])))
@Lvl4Sword
Lvl4Sword / numbers.py
Last active March 20, 2016 08:43
Find Numbers In A String
# This finds positive, negative, and float numbers.
# They're added into a list by what was found first
# and then presented to the user.
# Let me know if you find any issues.
import re
# this prints ['0', '-10', '10.0', '10.999999999999999']
# which is what's expected :-)
the_string = "single 0 // negative -10 // float 10.0 // long float 10.999999999999999"