Skip to content

Instantly share code, notes, and snippets.

@xtream1101
xtream1101 / url_regex.py
Last active May 6, 2016 14:08
URL Regex
import re
from pprint import pprint
"""
TODO:
Support PORT numbers in the url
Support IP's as domains. If IP, it cannot have a subdomain or a tld
"""
"""
@xtream1101
xtream1101 / csv_to_dict_with_unicode.py
Created May 6, 2016 14:25
csv to dict with unicode chars
import sys
import csv
from pprint import pprint
row_list = []
with open(sys.argv[1], 'r', encoding='ISO-8859-1') as f:
reader = csv.DictReader(f)
for row in reader:
# Make all keys lower case since we do not know the case used
row = dict((k.lower(), v) for k, v in row.items())
@xtream1101
xtream1101 / aliases.sh
Last active June 30, 2016 18:53
Python virtual envs bash commands
# Add this to your .bashrc or .bash_profile file to use
#
# This gives you access to create and switch between different python envs
# To create a venv called 'foo' just type:
# `pyve foo`
# This will create a python 3 venv and activate it as well
# If you are in a different venv and want to switch to foo, enter the same thing
pyve(){
env_name=$1
activate_file=~/Virtualenvs/py3/$env_name/bin/activate
@xtream1101
xtream1101 / keybase.md
Created September 1, 2016 21:59
keybase.md

Keybase proof

I hereby claim:

  • I am xtream1101 on github.
  • I am xtream1101 (https://keybase.io/xtream1101) on keybase.
  • I have a public key whose fingerprint is 061A BAAC 9D1B E6EB 89F5 26AF 1498 1397 2F25 7A6D

To claim this, I am signing this object:

@xtream1101
xtream1101 / multi_try_except_flat.py
Last active June 20, 2017 20:56
Python multiple Try/except flat design
# I know dict's have `.get()`, this example was made to break if the key is not
# there to show the use of multiple try/except's
# Yes I know that having the except and else on 1 line each does not fit with PEP8 standards.
# But when you have many of them it helps reduce the size of the file and is no harder to read
data = {'some_key': 'key value'}
key_data = None
for _ in range(1):
try:
key_data = data['someKey']
// ==UserScript==
// @name Periscope Auto refresh all
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Refresh all table on an interval
// @author xtream1101
// @match https://www.periscopedata.com/app/*
// @grant none
// @downloadURL https://gist.githubusercontent.com/xtream1101/211332c4cb2062a77010f623796a6431/raw/periscope_auto_refresh.js
// @updateURL https://gist.githubusercontent.com/xtream1101/211332c4cb2062a77010f623796a6431/raw/periscope_auto_refresh.js
@xtream1101
xtream1101 / X's Scrapers.md
Last active August 27, 2017 20:10
Current Scrapers
@xtream1101
xtream1101 / python_venv_shortcuts.sh
Last active December 6, 2016 21:46
Easy python environments
# Put this code in your .bashrc or .bash_profile
# Get Virtual Env
Color_Off="\033[0m" # Text Reset
Purple="\033[0;35m" # Purple
virtualenv_prompt() {
if [[ $VIRTUAL_ENV != "" ]]; then
venv=${VIRTUAL_ENV##*/}
# Strip out the path and just leave the env name
@xtream1101
xtream1101 / Try #1.sql
Created April 21, 2017 14:31
Dynamic QA query
#1
DROP FUNCTION qa_fields(character varying,character varying);
CREATE OR REPLACE FUNCTION qa_fields(schema_name VARCHAR, tbl_name VARCHAR)
-- The table def needs to be known before the function runs, but the number of fields returned is dynamic :(
-- Also need to correct names for the fields, the types will alwyas be FLOAT
RETURNS TABLE(a FLOAT, b FLOAT, c FLOAT, d FLOAT, e FLOAT, f FLOAT, g FLOAT, h FLOAT, i FLOAT, j FLOAT, k FLOAT, l FLOAT, m FLOAT, n FLOAT, o FLOAT, p FLOAT, q FLOAT, r FLOAT, s FLOAT, t FLOAT, u FLOAT, v FLOAT, w FLOAT, x FLOAT, ts DATE) AS
$func$
DECLARE field_name VARCHAR;
@xtream1101
xtream1101 / open_dirty_git_files.sh
Created November 2, 2017 17:26
Open all git files that have been modified or are untracked in sublime (or your editor of choice)
git status -s | cut -c4- | xargs -L1 sublime