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
@Lvl4Sword
Lvl4Sword / hosts_create.py
Created March 20, 2016 08:05
HOSTS file creation
# 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',''))
@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 / google_trends.py
Created March 20, 2016 08:17
Google Trends Search
@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"
@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 / 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
import random
foo = [1, 2, 3, 4, 5, 6]
random_selection = lambda: random.choice(foo)
random_selection()
@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
# this should probably be using colorama..
class my_color(object):
def __init__(self, first_color, second_color):
self.first_color = first_color
self.second_color = second_color
self.primary_colors = ['blue', 'red', 'yellow']
self.secondary_colors = ['green', 'purple', 'orange']
self.tertiary_colors = ['amber', 'vermillion', 'magenta',
'violet', 'teal', 'chartreuse']