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 pytz | |
import datetime | |
nowz = datetime.datetime.utcnow() | |
dt = nowz.astimezone(pytz.timezone('US/Eastern')) | |
print(dt.strftime('%Y-%m-%d %H:%M:%S %Z%z')) |
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 sys import exc_info as error | |
trapped = lambda x: print("Trapped: %s" % x) | |
err = lambda : print(error()[0].__name__) | |
try : | |
#1/0 | |
#1 + 'foo' | |
#int('foo') | |
foo |
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
echo "# repome" >> README.md | |
git init | |
git add README.md | |
git commit -m "first commit" | |
git remote add origin git@github.com:miklevin/repome.git | |
git push -u origin master |
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
#!/bin/bash | |
# Are you getting this message when you apt-get update? | |
# ** (appstreamcli:1244): CRITICAL **: Error while moving old database out of the way. | |
# AppStream cache update failed. | |
# Then run this: | |
sudo chmod -R a+rX,u+w /var/cache/app-info/xapian/default |
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 smtplib | |
from pathlib import Path | |
tos = Path("emails_test.txt").read_text().strip() | |
tos_list = tos.split('\n') | |
tos = ", ".join(tos_list) | |
SUBJECT = 'TEST MAIL' | |
TEXT = 'Here is a message from python.' |
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
sites = ''' | |
www.google.com | |
http://www.amazon.com | |
apple.com | |
'''.split('\n')[1:-1] | |
for i, site in enumerate(sites): | |
if site[:4].lower() != 'http': | |
sites[i] = 'http://%s' % site |
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 pyfiglet import Figlet | |
fig = lambda x : print(Figlet(font='standard', width=200).renderText(x)) |
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 asyncio | |
async def in_the_future(fut): | |
result = await fut | |
print("Side-effect: %s" % result) | |
return result | |
async def side_effects(url, name): |
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
proxies = [] | |
with open('goodproxies.txt', 'r') as f: | |
for line in f: | |
proxies.append(line.strip()) | |
block_dict = dict() | |
blocks = set() | |
staggered = [] | |
for proxy in proxies: | |
block = '.'.join(proxy.split('.')[:3]) |
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 | |
r = None | |
try: | |
r = requests.get("http://www.yahoofdsdsf.com/", proxies={'http': '127.0.0.1:8800'}) | |
except requests.exceptions.ProxyError: | |
print("Proxy Error") | |
except requests.exceptions.ConnectTimeout: | |
print("Taking too long to connect") | |
except requests.exceptions.ReadTimeout: | |
print("Taking too long to read back") |