Skip to content

Instantly share code, notes, and snippets.

View jorenham's full-sized avatar

Joren Hammudoglu jorenham

  • Delft, the Netherlands
View GitHub Profile
@wolph
wolph / pretty-pyright
Last active June 25, 2023 21:35
Little python script to wrap around pyright to add indenting, reformatting and making it easier to read. It also adds pretty colours
#!/usr/bin/env python -u
import os
import re
import sys
import itertools
import contextlib
import subprocess
sys.stdout.reconfigure(line_buffering=True)
@jorenham
jorenham / asyncio_eventloop_benchmark.py
Last active August 29, 2022 23:38
Directly measures the asyncio event loop iteration speed, and compares it with a sync for-loop
import asyncio
import time
from time import perf_counter_ns
# noinspection PyPep8Naming
class ns_per_it:
__slots__ = 'n', 'res'
def __init__(self, n: int):
@jorenham
jorenham / async_init.py
Created November 4, 2021 16:43
async version of __init__
import asyncio
class AsyncInit:
def __await__(self):
async def _():
await self.__ainit__()
return self
return _().__await__()
@almoore
almoore / README.md
Last active April 10, 2024 12:34
Getting realtime output using Python Subprocess
@wolph
wolph / main.py
Last active January 18, 2018 20:16 — forked from jorenham/main.py
Best exception handling in Python
import sys
import webbrowser
def main():
return 42/0
def excepthook(type_, value, traceback):
webbrowser.open_new_tab('https://stackoverflow.com/search?q=[python] {} {}'.format(type_, value))
@alexellis
alexellis / HackingOnLiveStreaming.md
Created June 1, 2017 12:48
HackingOnLiveStreaming

Additional notes

Original blog post - http://blog.alexellis.io/live-stream-with-docker/

How do I rebuild the image from scratch?

This will take several hours on a Raspberry Pi Zero - but less time on a Pi 2 or Pi 3. You can edit the Dockerfile for a Pi 2/3 and change RUN make to RUN make -j 4 to take advantage of the quad-core processor.

$ git clone https://github.com/alexellis/raspberrypi-youtube-streaming/
@paulirish
paulirish / how-to-view-source-of-chrome-extension.md
Last active April 17, 2024 21:44
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.

@sergeyhush
sergeyhush / post-receive
Last active August 30, 2021 11:47
Post-receive git hook to check if file changed
#!/bin/bash
WATCH_FILE="abc.123"
while read oldrev newrev refname; do
if [ "$refname" = "refs/heads/master" ]; then
if git diff-tree --name-only -r -z $oldrev $newrev | grep --quiet $WATCH_FILE ; then
# WATCH_FILE changed...
fi
fi
done