This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a fairly basic script that i use to create a sorted HOSTS file | |
# copy whatever is printed out, and you have a HOSTS file :-) | |
a = [] | |
b = [] | |
with open('/home/user/hosts.txt', 'r') as infile: | |
for each in infile: | |
a.append(each.replace('\n','')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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(), []))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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?: ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests import get | |
from yaml import load | |
import sys | |
# in a virtualenv: pip install libyaml | |
# input is always split by a comma | |
# if you were searching for 2 things it would be q=a,b& | |
base = 'https://www.google.com/trends/fetchComponent?hl=en-US&q=[INPUT_HERE]&cid=TIMESERIES_GRAPH_0&export=5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import os | |
import shutil | |
import sys | |
from envelopes import Envelope | |
def mail_send(files_to_send): | |
right_now = datetime.datetime.now() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ")) |
OlderNewer