Skip to content

Instantly share code, notes, and snippets.

@aleksaa01
aleksaa01 / no_boundary_mail_parser.py
Created May 14, 2019 20:10
MailParser without mail boundary
from mailparser.mailparser import MailParser
class NoBoundaryMailParser(MailParser):
@property
def body(self):
return self.text_plain, self.text_html
@catb0t
catb0t / unittest_sorted.py
Last active December 2, 2023 17:56
Sorting Unittests to run in the order they're written, or any order I like.
#!/usr/bin/env python3
import unittest
import inspect
import re
class Test_MyTests(unittest.TestCase):
def test_run_me_first(self): pass
def test_2nd_run_me(self): pass
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active June 10, 2024 15:16
How to view-source of a Chrome extension

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@rudiedirkx
rudiedirkx / download.js
Created May 6, 2012 16:55
Download any File/Blob via JS
/**
* `url` can be a data URI like data: or a blob URI like blob: or an existing, public resource like http:
* `filename` is the (default) name the file will be downloaded as
*/
function download( url, filename ) {
var link = document.createElement('a');
link.setAttribute('href',url);
link.setAttribute('download',filename);
var event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
@hankchan
hankchan / upgrade_example.py
Created April 11, 2012 07:30 — forked from denik/upgrade_example.py
Upgradable WSGI server websocket example
import gevent.pywsgi
from websocket import WebSocketUpgrader
class UpgradableWSGIHandler(gevent.pywsgi.WSGIHandler):
def handle_one_response(self):
connection_header = self.environ.get('HTTP_CONNECTION', '').lower()
if connection_header == 'upgrade' and self.server.upgrade_handler:
upgrade_header = self.environ.get('HTTP_UPGRADE', '').lower()
handler = self.server.upgrade_handler(upgrade_header, self.environ)
@lrvick
lrvick / flask_geventwebsocket_example.py
Created September 1, 2011 07:17
Simple Websocket echo client/server with Flask and gevent / gevent-websocket
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@denik
denik / gevent-multiprocess.py
Created August 25, 2011 04:24 — forked from notedit/gevent-multiprocess.py
gevent-multiprocess
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))