This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run it like `python3 udp-send.py <detination_addr> <destination_port> [<interface_to_bind>]` | |
import socket | |
import sys | |
with socket.socket(type=socket.SOCK_DGRAM) as s: | |
if len(sys.argv) >= 4: | |
s.bind((sys.argv[3], 0)) | |
s.connect((sys.argv[1], int(sys.argv[2]))) | |
s.send(b'Hello!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "common.h" // https://github.com/oliora/habr-switches-perf-test/blob/main/common.h | |
#include <cstdint> | |
#include <string_view> | |
#include <utility> | |
#include <immintrin.h> | |
template <size_t StepSize> | |
requires((StepSize <= PageSize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run it like `python3 udp-receiver.py 0.0.0.0 <listening_port>` | |
import socket | |
import sys | |
with socket.socket(type=socket.SOCK_DGRAM) as s: | |
s.bind((sys.argv[1], int(sys.argv[2]))) | |
while True: | |
(data, ancdata, msg_flags, address) = s.recvmsg(1024) | |
print(f'Received "{data.decode()}", ancdata="{ancdata}", sender={address}, flags={msg_flags}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# forward_variables usage example | |
include(forward_variables.cmake) | |
# After call to this function, all variables set by find_package will be forwarded to | |
# function caller scope (i.e. into parent scope). | |
function(find_boost_package) | |
start_track_variables() | |
set(bla_bla 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias to-timesptamp-ms="python3 -c 'import datetime, sys; s = sys.argv[1]; s = s[:-1] if s[-1] == \"Z\" else s; print(round(datetime.datetime.fromisoformat(s).replace(tzinfo=datetime.timezone.utc).timestamp() * 1000))'" | |
alias from-timesptamp-ms="python3 -c 'import datetime, sys; t = int(sys.argv[1]); print(datetime.datetime.utcfromtimestamp(t/1000).strftime(\"%Y-%m-%dT%H:%M:%S.%f\")[:-3]+\"Z\")'"from-timesptamp-ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%module(threads="1") something | |
%{ | |
// Register a callback (called from Python code) | |
// callbackFunc is a Python callable accepting one argument | |
void registerHandler(PyObject *callbackFunc) | |
{ | |
SWIG_PYTHON_THREAD_BEGIN_ALLOW; | |
const bool hasCallback = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A compilation of the following posts: | |
// http://stackoverflow.com/questions/18648069/g-doesnt-compile-constexpr-function-with-assert-in-it | |
// http://ericniebler.com/2014/09/27/assert-and-constexpr-in-cxx11/ | |
#include <cassert> | |
#include <utility> | |
template<class Assert> | |
inline void constexpr_assert_failed(Assert&& a) noexcept { std::forward<Assert>(a)(); } | |
// When evaluated at compile time emits a compilation error if condition is not true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to ~/.bashrc or ~/.zshrc or whatever shell you use | |
if [ -e $HOME/.ssh/ssh_auth_sock ]; then | |
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KSSGuvxn6Pi6x2pu1m3yvrgnDvLeg8S5JwbnHRPr_w-uIeI9z6LN9loec9FRdP7x2ah7U3aw743WBXwhrdyDkrlzNZe78s6LBdt0_yR3E7LNdTrfM19RUnyunlG22C3put5tyvrgnDvLuGI3S5mMv4_ROTDtfE0Dsfks1Q6B1Nsub15O0JqbVHt261my2e2ht1C3pubeH-uCeO8u4BzLlrmMXbnHRvmeWd7rbodLufWnwPbHaDSbi6W1GtWrXny2e2G2SLcbq7m3yvrgnDvLeg8S5JwrpnVvvuh2t4_TEfbMHbWrOnfuDdQaLTbi6W1RrrXnyundYbtxdq7m3yvrgnDvLegcwq3X3Q7b57HtcjZt6cQ6z0moOad96M29sDbX4O1dw743VxNHeXcwq3X3Q7naZ1qwlpjWb9aNjdP7x2FuTd38WVjfrqWBXVVVwhbW9_6uFrfizWdOad96M29sDbX4O1Nq28GVN_tqCaFcVNref9i7q_ks3QzWduVd0661Zs7ZH2uxtqm6WVt5tqqa8bV1K4Z1DtvVtf_yWdORdr6o11rwY3wOstqW4WVN1tqqq28WVN_dW9_6Pl6u1b2YjNpBJtMtJqbVb0arXnyundY7C3puV1m3Z1Lur6pNuysa_5O0BpLTnouVd0661Zs7ZH2uxdq7a6h2P9waH6g0lpTU3qOad96M29s7rf2it6s5n7QbQ6z0JqVbVpGtStetaG7s6nJ4kxthjEHbu6c_Z7QHkuMtaia1W1qRrVrXX4O1dwbN_tWBXwhr103g36C6O79BAuEsJhtNsRi1GwymjWH2uxd87K4qR0fa3_cu1g3PAYtEcS42xRiNts2YWtndYbLc38O_NqVQtdeEdfQ3uBgtEcS42xRitogmWUrXbG7e2htLcn62m3qyPNZe7cjobNdwq7JA2SxmE22xGJWDJrFl10zRrrXny2e2ht1C3puLlnM325R0rpnV3tH8DAWDJXUOtcrajWXvOjdP7x2ahbNQepcTm3OPiu109MBHSuoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " | |
ZSH_THEME_GIT_PROMPT_DIRTY="]%{$fg[red]%}✗" | |
ZSH_THEME_GIT_PROMPT_CLEAN="]" | |
export PROMPT='%{$BG[237]%}%{$fg[white]%}💰 %3c%{$reset_color%} $(git_prompt_info)' |
NewerOlder