Skip to content

Instantly share code, notes, and snippets.

View msukmanowsky's full-sized avatar
🥳
Building the future of how companies work with elvex!

Mike Sukmanowsky msukmanowsky

🥳
Building the future of how companies work with elvex!
View GitHub Profile
import time
import asyncio
import aiohttp
from bs4 import BeautifulSoup
async def main():
async with aiohttp.ClientSession() as session:
import asyncio
import aiohttp
import logging
logging.basicConfig(level=logging.DEBUG)
async def main():
async with aiohttp.ClientSession() as session:
@msukmanowsky
msukmanowsky / 1_sys_exit.py
Created July 4, 2017 20:24
Demonstrating issues between sys.exit and os._exit when active threads are running.
import logging
import os
import sys
import threading
import time
import six
logging.basicConfig(level=logging.INFO, format='%(name)s %(threadName)s %(thread)d [%(levelname)s]: %(message)s')
Network OS ua_browser Sample User Agent
Facebook iOS Facebook Mozilla/5.0 (iPhone; CPU iPhone OS 8_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12D508 [FBAN/FBIOS;FBAV/27.0.0.10.12;FBBV/8291884;FBDV/iPhone7,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/8.2;FBSS/3; FBCR/vodafoneIE;FBID/phone;FBLC/e,...: n_US;FBOP/5]
Facebook Android Facebook `Mozilla/5.0 (
#!/usr/bin/env python
'''Build up a set of URLs using the common crawl index. See
http://commoncrawl.org/2015/04/announcing-the-common-crawl-index/ for more info.
'''
from __future__ import print_function
import gzip
import logging
import os
import random
<script src="http://content.jwplatform.com/libraries/2SJ3KAcS.js"></script>
<div id="embed_container">Loading the player...</div>
<script type="text/javascript">
var player = jwplayer("embed_container");
player.setup({
file: "http://content.jwplatform.com/videos/xxxxxxxx.mp4",
image: "http://content.jwplatform.com/thumbs/xxxxxxxx.jpg",
mediaid: "myvideoid12345",
width: 640,
height: 360,
{
"action": "pageview",
"apikey": "mashable.com",
"display": true,
"display_avail_height": 735,
"display_avail_width": 1280,
"display_pixel_depth": 24,
"display_total_height": 800,
"display_total_width": 1280,
"engaged_time_inc": null,
{
"session_initial_url": "http://www.example.com/",
"surl_fragment": "",
"display_pixel_depth": 24,
"sref_scheme": "https",
"surl_clean": "http://www.example.com/",
"visitor": true,
"url_scheme": "http",
"surl_domain": "example.com",
"sref_netloc": "www.google.ca",
@msukmanowsky
msukmanowsky / 1-driver.py
Last active August 5, 2016 02:21
Testing out some handy dandy pyspark debugging. Note that the output script displays file, line number and code being executed as well as a sample of the result.
import pyspark
from sparkbuddy.monkey import patch_pyspark
patch_pyspark()
def is_even(val):
if val % 2 == 0:
return [val]
return []
@msukmanowsky
msukmanowsky / numpy_unique.py
Last active June 14, 2016 16:39
To run `pip install numpy psutil` and then `time python <script> <set size>`.
import uuid
import sys
import numpy as np
import psutil
num_users = int(sys.argv[1])
users = np.unique(list(str(uuid.uuid4()) for _ in xrange(num_users)))
print len(users)