Skip to content

Instantly share code, notes, and snippets.

View sc1f's full-sized avatar

Jun Tan sc1f

View GitHub Profile
import smtplib, sys, settings
def send_email_alert(msg):
if not settings.TO_EMAIL:
print "No emails to alert!"
sys.exit()
else:
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(settings.FROM_EMAIL, settings.FROM_EMAIL_PASS)
#!/usr/bin/env python3
import argparse, ipaddress, socket, geoip2.database
input = argparse.ArgumentParser()
input.add_argument("host", type=str, help="enter the host to locate")
input_args = input.parse_args()
ip_reader = geoip2.database.Reader('/volumes/files/personal/utilities/network/dependencies/GeoLite2-City.mmdb')
def input_validate(host):
#!/usr/bin/env python3
import argparse
arg = argparse.ArgumentParser()
arg.add_argument("file", type=str, help="input text file")
arg.add_argument("dir", type=str, help="dir to save new file in")
input = arg.parse_args()
def parse_vocab(file, dir):
vocab_file = open(file).read().split("\n")
import argparse, urllib.request, requests, re
from bs4 import BeautifulSoup
from queue import Queue
from threading import Thread
#input validation
def validate_url(input_url):
if "http://" not in input_url:
raise ValueError("not a valid URL!")
elif "https://" not in input_url:
raise ValueError("not a valid URL!")
@sc1f
sc1f / imgcompress.py
Created February 21, 2017 23:04
compresses images through the tinify API
#!/usr/bin/python3
import tinify, argparse, os, settings
# change this to your tinypng api key
tinify.key = settings.TINIFY_API_KEY
# input arguments
input = argparse.ArgumentParser()
input.add_argument("-d", "--directory", type=str, help="\
Specify the directory you want to save the images in, if not the current one.", required=False)
# Gist example of IB wrapper ...
#
# Download API from http://interactivebrokers.github.io/#
#
# Install python API code /IBJts/source/pythonclient $ python3 setup.py install
#
# Note: The test cases, and the documentation refer to a python package called IBApi,
# but the actual package is called ibapi. Go figure.
#
# Get the latest version of the gateway:
@sc1f
sc1f / log.txt
Created November 5, 2019 23:22
widget bug
2926 function calls (2876 primitive calls) in 341.547 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 341.539 341.539 341.541 341.541 {built-in method perspective.table.libbinding.make_table}
2 0.002 0.001 0.002 0.001 {method 'copy' of 'numpy.ndarray' objects}
2 0.000 0.000 0.000 0.000 missing.py:219(_isna_ndarraylike)
3 0.000 0.000 0.000 0.000 {method 'astype' of 'numpy.ndarray' objects}
26/25 0.000 0.000 0.000 0.000 {built-in method numpy.array}
@sc1f
sc1f / log2.txt
Created November 6, 2019 11:19
Pivot log
Sampling process 13221 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling Python (pid 13221) every 1 millisecond
Process: Python [13221]
Path: /usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Load Address: 0x100a6f000
Identifier: Python
Version: ???
Code Type: X86-64
Parent Process: zsh [70842]
@sc1f
sc1f / profile.svg
Created November 6, 2019 12:53
Update profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sc1f
sc1f / col_log.svg
Created November 6, 2019 14:22
Column-only update
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.