Skip to content

Instantly share code, notes, and snippets.

View ikonst's full-sized avatar

Ilya Priven ikonst

  • New York, NY
  • 00:17 (UTC -04:00)
View GitHub Profile
@ikonst
ikonst / abort_on_dc.py
Last active May 14, 2019 19:29
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
gevent.monkey.patch_all()
from contextlib import contextmanager
from flask import Flask
#!/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.
FPS=10
PALETTE=$(mktemp).png
MOV=$1
@ikonst
ikonst / addsym.cpp
Last active February 19, 2020 17:06
Adds IDA symbols as WinDbg synthetic symbols
// Adds IDA symbols as WinDbg synthetic symbols
//
// Original code by 'blabb'.
//
// See:
// http://www.woodmann.com/forum/entry.php?262-addsym-windbg-extension-%28extension-to-load-names-from-ida-to-windbg%29
// http://reverseengineering.stackexchange.com/questions/3850/importing-list-of-functions-and-addresses-into-windbg
#include <engextcpp.hpp>
@ikonst
ikonst / eabi-wchar.c
Last active September 28, 2020 12:40
Patches ELF (EABI) ARM attribute Tag_ABI_PCS_wchar_t.
/*
* 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
ikonst / mocker.py
Created November 11, 2021 02:45
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
ikonst / ActiveDirectoryToVcf.vbs
Created August 22, 2012 00:04
Gets Active Directory user information into a VCF file of VCards you can import into your phone or contacts app
set iAdRootDSE = GetObject("LDAP://RootDSE")
namingContext = iAdRootDSE.Get("defaultNamingContext")
If WScript.Arguments.Count = 1 Then
namingContext = WScript.Arguments.Item(0)
Else
Wscript.Echo "Usage: ActiveDirectoryToVcf.vbs [Naming Context]"
Wscript.Echo "Default path is " & namingContext
End If
from typing import Any
from typing import Dict
from typing import Type
from typing import TYPE_CHECKING
from typing import TypeVar
from pynamodb.attributes import MapAttribute
MapT = TypeVar('MapT', bound=MapAttribute)
@ikonst
ikonst / LogStream.test.ts
Last active September 16, 2023 01:47
Bunyan log size limiting stream
import bunyan from "bunyan";
import fs from "fs";
import { LogStream, trimStringToJsonLength } from "LogStream";
describe("LogStream", () => {
const outputStream = fs.createWriteStream("/dev/null");
const logger = bunyan.createLogger({
name: "test",
stream: new LogStream({ stream: outputStream, maxLength: 1000 }),
});
@ikonst
ikonst / pgPoolTracing.ts
Created September 13, 2023 14:55
Patches pg-pool to trace with dd-trace
import tracer, { Span } from "dd-trace";
import pg from "pg";
/**
* Patches pg.Pool to add tracing.
*/
export function patchPgPool(serviceName: string) {
const name = "pg-pool.connect";
const service = `${serviceName}-postgres`;
@ikonst
ikonst / cfdata.py
Last active January 27, 2024 22:18
LLDB extension for saving CFData to local file; useful for remote iOS debugging
'''
INSTALLING
curl --create-dirs -o ~/.lldb/cfdata.py https://gist.githubusercontent.com/ikonst/364af37c44e5f549b722/raw/cfdata.py \
&& echo 'command script import ~/.lldb/cfdata.py' >> ~/.lldbinit
USING
(lldb) cfdata_save some_cfdata /Users/john/foo
(lldb) cfdata_save some_nsdata /Users/john/bar