Skip to content

Instantly share code, notes, and snippets.


Ilya Konstantinov ikonst

View GitHub Profile
ikonst /
Created Nov 11, 2021
pytest_mock with patch.method
import gc
import sys
import types
import unittest.mock
from typing import Any
from typing import Callable
from typing import Generator
from typing import Optional
from typing import TYPE_CHECKING
ikonst / eabi-wchar.c
Last active Sep 28, 2020
Patches ELF (EABI) ARM attribute Tag_ABI_PCS_wchar_t.
View eabi-wchar.c
* Patches ELF (EABI) ARM attribute Tag_ABI_PCS_wchar_t.
* This utility's chief purpose is to remove the flag indicating sizeof(wchar_t)
* from ARM EABI binaries -- or more precisely, setting it to 0 (= undefined).
* It is useful to mark libraries which don't use wchar_t at all as wchar_t-width-agnostic.
* This way, they can be linked to both sizeof(wchar_t)=2 and sizeof(wchar_t)=4 programs
* without any warnings.
ikonst / ActiveDirectoryToVcf.vbs
Created Aug 22, 2012
Gets Active Directory user information into a VCF file of VCards you can import into your phone or contacts app
View ActiveDirectoryToVcf.vbs
set iAdRootDSE = GetObject("LDAP://RootDSE")
namingContext = iAdRootDSE.Get("defaultNamingContext")
If WScript.Arguments.Count = 1 Then
namingContext = WScript.Arguments.Item(0)
Wscript.Echo "Usage: ActiveDirectoryToVcf.vbs [Naming Context]"
Wscript.Echo "Default path is " & namingContext
End If
ikonst /
Last active Mar 19, 2020
LLDB extension for saving CFData to local file; useful for remote iOS debugging
curl --create-dirs -o ~/.lldb/ \
&& echo 'command script import ~/.lldb/' >> ~/.lldbinit
(lldb) cfdata_save some_cfdata /Users/john/foo
(lldb) cfdata_save some_nsdata /Users/john/bar
ikonst / addsym.cpp
Last active Feb 19, 2020
Adds IDA symbols as WinDbg synthetic symbols
View addsym.cpp
// Adds IDA symbols as WinDbg synthetic symbols
// Original code by 'blabb'.
// See:
#include <engextcpp.hpp>
#!/bin/sh -e
# Converts a Quicktime movie to a GIF aniamtion.
# Useful for screen recordings.
# Preliminary step with palette required to make it look good
# without dithering artifacts.
ikonst /
Last active May 14, 2019
Example of a gevent-based Flask server that aborts when downstream disconnects
Implements a behavior similar to:
- Go srv's cancelation of context on downstream disconnect
- PHP (unless `ignore_user_abort` is true)
import gevent.monkey
from contextlib import contextmanager
from flask import Flask
from contextlib import contextmanager
from functools import wraps
from socket import socket as socket_type, MSG_PEEK
from typing import Set
import flask
import gevent
def _abort_on_eof_watchdog(socket: socket_type, greenlets: Set[gevent.Greenlet]) -> bool:
ikonst / private.xml
Created Mar 18, 2016
Microsoft L5V-00001 Sculpt Ergonomic Desktop Keyboard and Mouse — private.xml for Karabiner
View private.xml
<?xml version="1.0"?>
Based on:
Button 4 is the side button (located by the blue Windows button).
This allows you to map the Windows button as Button 5.
1. brew cask install karabiner
View NSData+GStreamer.h
@import Foundation;
#include <gst/gst.h>
@interface NSData (GStreamer)
- (GstBuffer *)gstBuffer;
@interface NSMutableData (GStreamer)