Skip to content

Instantly share code, notes, and snippets.

View bgromov's full-sized avatar

Boris Gromov bgromov

View GitHub Profile
@bgromov
bgromov / ANSI.md
Created September 26, 2022 12:24 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@bgromov
bgromov / pandas-query.md
Last active November 3, 2022 10:10
Pandas: DataFrame.query() for complex data types

Pandas: DataFrame.query() for complex data types

Consider the following pandas DataFrame:

df = pd.DataFrame([[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[0, 1, 2]]], columns=['a'])
 a
@bgromov
bgromov / .docker-private-registry-with-read-write-control.md
Created August 18, 2021 14:17
Run docker private registry with read/write access control
@bgromov
bgromov / readme.md
Last active August 5, 2021 13:59
NumPy in Pipenv: Could not build wheels for numpy which use PEP 517 and cannot be installed directly

NumPy in Pipenv: Could not build wheels for numpy which use PEP 517 and cannot be installed directly

Problem appears on macOS BigSur when trying to install numpy or packages that depend on it with pipenv, e.g. pandas.

$ SYSTEM_VERSION_COMPAT=1 pipenv install numpy

or

@bgromov
bgromov / forward-tello-port.sh
Last active July 28, 2020 10:02
Forward DJI Tello port with socat
#!/bin/sh
if [ $# -eq 0 ]; then
echo "Usage: $0 <new_ip_address>"
exit 1
fi
socat udp4-listen:8889,fork,reuseaddr,bind=$1 udp:192.168.10.1:8889
@bgromov
bgromov / RingBuffer.swift
Last active March 30, 2021 06:50
RingBuffer publisher for Apple's Combine framework
/*
Source: https://github.com/raywenderlich/swift-algorithm-club/tree/dd1ed39fca150d4fa2905b902736f12a49f3efb1/Ring%20Buffer
Fixed-length ring buffer
In this implementation, the read and write pointers always increment and
never wrap around. On a 64-bit platform that should not get you into trouble
any time soon.
Not thread-safe, so don't read and write from different threads at the same
time! To make this thread-safe for one reader and one writer, it should be
enough to change read/writeIndex += 1 to OSAtomicIncrement64(), but I haven't
@bgromov
bgromov / main.tex
Created January 8, 2020 10:06
LaTeX: How to add a prefix to `natbib` references and bibliography with `numbers` citation style and without `biblatex`?
\documentclass{your_thesis_class}
\usepackage[utf8x]{inputenc} % <--- required by Inkscape generated pdf_tex figures. biblatex won't work with these
\usepackage[numbers]{natbib}
% \setcitestyle{numbers} % <--- if natbib is already included by another package
\usepackage{bibunits} % <--- lets you have a separate bibliography, e.g. your own publications list
\begin{document}
\begin{bibunit}[unsrtnat] % <--- unsrtnat arranges bibliography list in appearance order
@bgromov
bgromov / readme.md
Last active September 30, 2023 15:35
Compiling Swift framework with mixed-in Objective-C code

Problem

You can't use bridging headers within a framework.

Solution 1 (umbrella header):

Xcode will automatically create umbrella header for you Cocoa Framework project. That will be the file named <FrameworkName>.h in the <FrameworkName> group/folder (where the rest of your sources are).

  1. To include the required Obj-C header you need to set it as Public: select it in the project explorer (left pane) and change the property Target Membership (left—Inspectors—pane) from Project to Public.
  2. Open umbrella header (<FrameworkName>.h) and import the required header as:
@bgromov
bgromov / hue_colors.md
Created May 29, 2019 19:48 — forked from popcorn245/hue_colors.md
XY Color Conversion

FROM HUE DESIGN DOCS

https://github.com/PhilipsHue/PhilipsHueSDK-iOS-OSX/blob/00187a3db88dedd640f5ddfa8a474458dff4e1db/ApplicationDesignNotes/RGB%20to%20xy%20Color%20conversion.md

#Conversion between RGB and xy in the CIE 1931 colorspace for hue The conversion between RGB and xy in the CIE 1931 colorspace is not something Philips invented, but we have an optimized conversion for our different light types, like hue bulbs and LivingColors. It is important to differentiate between the various light types, because they do not all support the same color gamut. For example, the hue bulbs are very good at showing nice whites, while the LivingColors are generally a bit better at colors, like green and cyan.

@bgromov
bgromov / Adaptive_macOS_dark.sublime-theme
Last active January 30, 2019 12:51
Dark Theme on macOS Mojave for Sublime Text 3
[
{
"class": "title_bar",
"fg": ["background", 255, 255, 255, 0.7],
// "bg": ["background", 63, 65, 72, 1.0]
},
{
"class": "title_bar",
"attributes": ["file_dark"],
"bg": ["background", 255, 255, 255, 0.15]