Regex Find URLs

import re result = re.sub(p, subst, test_str)p = re.compile(ur‘(?i)b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)/)(?:[^s()<>{}[]]+|([^s()]*?([^s()]+)[^s()]*?)|([^s]+?))+(?:([^s()]*?([^s()]+)[^s()]*?)|([^s]+?)|[^s`!()[]{};:’”.,<>?«»“”‘’])|(?:(?<!@)[a-z0-9]+(?:[.-][a-z0-9]+)*[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)b/?(?!@)))’)test_str = u“”subst = u“” Even longer Regex for finding URL

Create and Import CSV file into Database

Linkedin’s Industry Codes import sqlite3, os, csv conn = sqlite3.connect(‘industry_classifications’)curs = conn.cursor() tblcmd = ‘create table linkedin_industries (code int(3), groups char(60), description char(60))’curs = conn.execute(‘select * from linkedin_industries’)names = [description[0] for description in curs.description]namescurs.execute(tblcmd)curs.rowcount file = r’C:projectsLinkedinIndustry Codes.csv’ with open(file, ‘r’, encoding=’utf-8′) as f:    readCSV = csv.reader(f, delimiter=’,’)    for row in readCSV:        curs.execute(‘INSERT INTO linkedin_industries (code, groups, description) VALUES (?, ?, ?)’, row) curs.execute(‘select * from linkedin_industries’)for rec in curs.fetchall(): print(rec) conn.commit()

Add Chrome app to Secondary taskbar w/ icon

Now that my beloved chrome app launcher is gone, I’ve had to find another way to launch my apps.  I used Feedly, but process should be same for others. 1)       Goto chrome://apps/, right click icon, click Create shortcuts… (shortcut will be created on Desktop) a.        2)       Goto desktop, right click icon, properties, select everything in target…

Setting up Windows Shebang using Anaconda

Download and install Py Launcher (it will install py.exe to c:windows)https://bitbucket.org/vinay.sajip/pylauncher/downloads/ https://bitbucket.org/vinay.sajip/pylauncher/downloads/launchwin-1.0.1.6.amd64.msi ^direct url Download and install Anaconda (I install in c:PYTHON instead of default c:anaconda3) https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86_64.exe Create two environments (using command prompt) $ conda create —name py27 python=2.7.11      # creates python 2 environment $ conda create —name py35 python=3.5.2       # creates python 3 environment $ conda info —envs      # lists currently installed environments $ activate py27      # test python 2 environment $ activate py35      # test python 3 environment $ deactivate Setting up Shebang for Python 3 and Python 2 environment:…