Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
#
# Copyright (c) 2021 Jasper Lievisse Adriaanse <[email protected]>
#
# 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
deluge.tests.test_log
LogTestCase
test_twisted_error_log ... 22:01:12.170 [ERROR ][deluge.log:284 ] ('Unhandled error in Deferred:',)
22:01:12.171 [ERROR ][deluge.log:284 ] [Failure instance: Traceback (failure with no frames): <class 'deluge.component.ComponentException'>: Trying to start a component ('EventManager') not in stopped state. Current state: 'Paused'
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
result = g.send(result)
File "/home/ubuntu/deluge.git/deluge/tests/test_log.py", line 48, in call
yield component.start(["EventManager"])
File "/home/ubuntu/deluge.git/deluge/component.py", line 298, in start
deferreds.append(self.components[name]._component_start())