Skip to content

Instantly share code, notes, and snippets.

View leonid-ed's full-sized avatar

Leonid Edrenkin leonid-ed

View GitHub Profile
@leonid-ed
leonid-ed / make_record.sh
Last active August 12, 2024 18:07
A short Bash script to make quick records with time spent
# This is a script to make short records about activities with time spent in minutes.
# Dependencies:
# - tac - (install: $ brew install coreutils)
# - align - (install: https://github.com/Guitarbum722/align/tree/master/cmd/align, $ go build -o align && go install)
#
# You can add alias with shortcuts to your bash/zsh config:
# alias mr='/Users/leonid/bash-scripts/make_record.sh add'
# alias mrs='/Users/leonid/bash-scripts/make_record.sh show'
# alias mrsf='/Users/leonid/bash-scripts/make_record.sh show-filter'
# alias mre='/Users/leonid/bash-scripts/make_record.sh edit'

Keybase proof

I hereby claim:

  • I am leonid-ed on github.
  • I am leonided (https://keybase.io/leonided) on keybase.
  • I have a public key ASABKy69asMsnQRSChUTFtYgLtzc0YNEwDeOnCiwJIWBkAo

To claim this, I am signing this object:

@leonid-ed
leonid-ed / .vimrc
Created June 11, 2020 08:57
SelectIndentOn() function for VIM to select all the lines with the same indent level in Python
" Inspired by https://vim.fandom.com/wiki/Visual_selection_of_indent_block
" This version additionaly goes through empty lines to select also separated blocks
" on the same indent level.
function SelectIndentOn()
let temp_var=indent(line("."))
if temp_var is 0 | return | endif
while (line(".") > 1) &&
\ ((indent(line(".")-1) >= temp_var) || (getline(line(".")-1) is ""))
exe "normal k"
@leonid-ed
leonid-ed / static_inline_example.md
Created March 21, 2020 10:36 — forked from htfy96/static_inline_example.md
static inline vs inline vs static in C++

In this article we compared different behavior of static, inline and static inline free functions in compiled binary. All the following test was done under g++ 7.1.1 on Linux amd64, ELF64.

Test sources

header.hpp

#pragma once

inline int only_inline() { return 42; }
static int only_static() { return 42; }
@leonid-ed
leonid-ed / weighted_quick_union_with_path_compression.py
Created July 15, 2019 20:40
Python implementation of weighted quick-union with path compression algorithm
class WeightedQuickUnionWithPathCompressionUF():
"""Weighted quick-union with path compression algorithm
The original Java implementation is introduced at:
https://algs4.cs.princeton.edu/15uf/index.php#1.5
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf
Time complexity:
constructor: O(n)
union: amortized ~O(1)
@leonid-ed
leonid-ed / clipboard-lines-copier.py
Last active March 16, 2017 08:14
Sublime Text 3 plugin that copies selected lines to the clipboard.
# The MIT License (MIT)
# Copyright (c) 2016 Leonid Edrenkin
#
# This is a Sublime Text 3 plugin that copies selected lines to the clipboard.
# You should select text lines and apply command:
# view.run_command('copy_lines_to_clipboard')
# view.run_command('copy_lines_to_clipboard', {"with_filename": True})
# view.run_command('copy_lines_to_clipboard', {"with_filename": True, "tabsize" : 4})
@leonid-ed
leonid-ed / Text-item-list.py
Last active October 10, 2016 09:55
This is a Sublime Text 3 plugin that makes a numberred list.
# The MIT License (MIT)
# Copyright (c) 2016 Leonid Edrenkin
#
# This is a Sublime Text 3 plugin that makes and unmakes a numberred list.
# You should select text lines and apply one of commands:
# view.run_command('make_numberred_list')
# view.run_command('unmake_numberred_list')
import sublime, sublime_plugin
@leonid-ed
leonid-ed / C-make-multiline-macro.py
Created April 28, 2016 08:15
This is a Sublime Text 3 plugin that makes an adjusted multiline C-macro
# The MIT License (MIT)
# Copyright (c) 2016 Leonid Edrenkin
#
# This is a Sublime Text 3 plugin that makes an adjusted multiline C-macro.
# You should select some code and apply one of commands:
# view.run_command('make_multi_line_macro')
# view.run_command('unmake_multi_line_macro')
import sublime, sublime_plugin
@leonid-ed
leonid-ed / prepare-commit-msg
Last active April 28, 2016 08:00
.git/hooks/prepare-commit-msg showing latest 15 commit messages
# The MIT License (MIT)
# Copyright (c) 2016 Leonid Edrenkin
#
#!/bin/bash
case "$2,$3" in
message,HEAD)
;;
*)
@leonid-ed
leonid-ed / udp_to_local.c
Last active August 23, 2024 09:49
Examples of using raw sockets (c, linux, raw socket)
/*
An example of using raw sockets.
You can capture packets by tcpdump:
tcpdump -X -s0 -i lo -p udp
*/
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>