Skip to content

Instantly share code, notes, and snippets.

View mikeckennedy's full-sized avatar

Michael Kennedy mikeckennedy

View GitHub Profile
@stenuto
stenuto / hls.sh
Created November 7, 2024 16:58
HLS ffmpeg script
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]"
exit 1
}
# Check if at least one argument (input file) is provided
if [ $# -lt 1 ]; then
@Midnighter
Midnighter / watch_this.py
Last active August 7, 2020 19:20 — forked from mikeckennedy/watch_this.py
Add C# += / -= event subscriptions to Python using the Events package
import functools
from events import Events # Note you must pip install events
class set_event:
"""Define a class-based setter method decorator."""
def __init__(self, func, event):
super().__init__()
@josemarimanio
josemarimanio / install_pyenv_mac_zsh.rst
Created May 13, 2020 12:13
Installing pyenv on macOS for Zsh using Homebrew
@IanColdwater
IanColdwater / twittermute.txt
Last active November 17, 2024 02:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@mikeckennedy
mikeckennedy / switch_in_python_example.py
Last active August 21, 2019 04:55
Could we easily add switch to the Python language? I think the answer is maybe yes!
# Here is an example of some syntax I'm proposing:
# See the github repo at https://github.com/mikeckennedy/python-switch
def test_switch():
num = 7
val = input("Enter a key. a, b, c or any other: ")
with Switch(val) as s:
s.case('a', process_a)
s.case('b', process_b)
@SuneKjaergaard
SuneKjaergaard / check_uwsgi.sh
Last active January 12, 2024 04:01
Small shell script to restart the uWSGI application when https://github.com/unbit/uwsgi/issues/1369 happens. Based on uWSGI server run by upstart
#!/bin/bash
line=$(tail -1 /var/log/myapp/myapp.uwsgi.log)
substr='uWSGI listen queue of socket'
if test "${line#*$substr}" != "$line"
then
#We're using upstart, could be easily adapted to fx systemd
# Adding a log statement to keep track of when this happens. Remember to create the monitor dir
/sbin/initctl restart myapp > /var/log/myapp/monitor/uwsgi-monitor.log 2>&1
echo "$(date) restarted myapp due to listen queue error" >> /var/log/myapp/monitor/uwsgi-monitor.log
@simonw
simonw / recover_source_code.md
Last active September 28, 2024 08:10
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@ewenchou
ewenchou / README.md
Last active July 8, 2023 04:36
Run Python script as systemd service
  1. Create a service file like dash_sniffer.service
  2. Put it in /lib/systemd/system/
  3. Reload systemd using command: systemctl daemon-reload
  4. Enable auto start using command: systemctl enable dash_sniffer.service
@Dexdev08
Dexdev08 / talk_python_similarities.py
Created June 7, 2016 13:46
Copy from local Ipython Notebook to derive similarity scores of Talk Python Transcripts
import graphlab as gl
import pandas
import numpy as np
import string
import re
import unicodedata
import math
# attempt to load text files
import os
files = os.listdir(os.getcwd())
@Dexdev08
Dexdev08 / talk_python_similarities.csv
Created June 5, 2016 14:36
Talk Python Cosine Similarity Scores
index file2 similarity file1
0 027.txt 0.870699976021 001.txt
1 038.txt 0.86203984054 001.txt
2 045.txt 0.83739929573 001.txt
3 048.txt 0.871940130115 001.txt
4 007.txt 0.839339858402 001.txt
5 009.txt 0.849677851534 001.txt
6 004.txt 0.830406980293 001.txt
7 006.txt 0.878178563493 001.txt
8 031.txt 0.850476330623 001.txt