Skip to content

Instantly share code, notes, and snippets.

@cas--
cas-- / adventures-in-python-core-dumping.md
Created September 3, 2021 13:41 — forked from toolness/adventures-in-python-core-dumping.md
Adventures in Python Core Dumping

Adventures in Python Core Dumping

After watching Bryan Cantrill's presentation on [Running Aground: Debugging Docker in Production][aground] I got all excited (and strangely nostalgic) about the possibility of core-dumping server-side Python apps whenever they go awry. This would theoretically allow me to fully inspect the state of the program at the point it exploded, rather than relying solely on the information of a stack trace.

#!/usr/bin/env python3
#
# Copyright (c) 2021 Jasper Lievisse Adriaanse <j@jasper.la>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@cas--
cas-- / win32_verstamp.py
Created September 21, 2018 15:40
Stamp windows exe files with version information
""" Stamp a Win32 binary with version information.
Original code from pywin32 module.
Modified to only use ctypes, making it standalone.
"""
import ctypes
import os
import struct
import glob
@cas--
cas-- / ptt_mic.md
Last active August 23, 2017 10:43
Details on push-to-talk keyboard shortcut using xbindkeys

A quick guide to setting up keyboard shortcuts for a push-to-talk microphone.

  1. Install xbindkeys:

    sudo apt install xbindkeys
    
  2. Find the required keycode for xbindkeys:

    touch $HOME/.xbindkeysrc
    

xbindkeys --key

#if BOOST_VERSION >= 106000
+if (boost::python::converter::registry::query(
+ boost::python::type_id <boost::shared_ptr<alert> >()) == NULL) {
register_ptr_to_python<boost::shared_ptr<alert> >();
+}
@cas--
cas-- / patch_double_to_single_quote.py
Created November 3, 2016 19:12
Python script to convert quotes in a `git format-patch -1 <sha1>` to apply to converted quotes branch `git am < <patch>`
import os
new_lines = []
os.chdir('/home/ubuntu/deluge.git/')
patchfile = '0001-Fix-pylint-warnings.patch'
with open(patchfile) as file_:
for line in file_.readlines():
line_strip = line.lstrip('-').lstrip('+').strip()
if '"' in line and not "'" in line and not '"""' in line and not '\\"' in line:
{
"file": 2,
"format": 1
}{
"show_progress": true,
"seeding_time_width": 10,
"show_remaining": false,
"ratio_width": 10,
"remaining_width": 13,
"downloading_time_width": 10,
@cas--
cas-- / .pre-commit-config.yaml
Created October 26, 2016 11:25
yelp pre-commit config
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 8e0d7bab601ce6a8775ea98082938e60fc80eb7f
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: flake8
- id: check-ast
# - id: double-quote-string-fixer
# - id: end-of-file-fixer
# - id: fix-encoding-pragma
@cas--
cas-- / gist:f0a33566739be9075f3c851dbc94534e
Created July 21, 2016 20:49
List of ubuntu supported series from launchpad
import json
import urllib
series = json.load(urllib.urlopen('https://api.launchpad.net/1.0/ubuntu/series'))
print [entry['name'] for entry in series['entries'] if entry['supported']]
# List mounts
systemctl -t mount
# Unit starts after mount and unit is stopped when any of the mounts suddenly disappears.
After=xyz.mount
BindsTo=xyz.mount
# Also look at RequiresMountsFor