Skip to content

Instantly share code, notes, and snippets.

@eginez
eginez / gh_logs.sh
Last active May 22, 2023 00:53
Github workflow logs in the command line
function gh_logs() {
#needs fzf, jq, github cli
branch_name=${1:-}
repo_name=
if [[ -n $2 ]]; then
repo_name="-R$2"
fi
job_name=$(gh $repo_name pr checks $branch_name|fzf|cut -d$'\t' -f1)
run_id=$(gh $repo_name pr checks $branch_name|grep "$job_name"|cut -d'/' -f8)
echo run id: $run_id
@eginez
eginez / compile_commands.json
Created March 13, 2023 04:14
Gcc compile commads for cpython
[
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-Wsign-compare",
"-Wunreachable-code",
"-DNDEBUG",
"-g",
"-fwrapv",
# load data index on date
# time series data like credit card transactions for example
df = pd.read_csv('~/Downloads/time_series_data.csv', index_col='Date', parse_dates=True)
# group by apply data and sum
df2 = df.groupby(pd.Grouper(freq='Y')).sum()
#df2 now contains sumarized data
# show perenctiles for example
df2.quantile([0.1, 0.5, 0.8, 0.9, 0.95])
@eginez
eginez / cors_server.py
Last active April 20, 2022 01:08
Python CORS simple http server
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
import sys
class CORSRequestHandler (SimpleHTTPRequestHandler):
def _send_cors_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
self.send_header("Access-Control-Allow-Methods", "GET,POST,OPTIONS")
def end_headers (self):
@eginez
eginez / one.sh
Last active January 3, 2022 18:55
Python build configurations
python -c "import sysconfig; print('-fprofile-use' in (sysconfig.get_config_var('PY_CFLAGS') + sysconfig.get_config_var('PY_CFLAGS_NODIST')))"
@eginez
eginez / init.vm
Created August 20, 2021 00:22
neovim setup
call plug#begin()
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/playground'
Plug 'hrsh7th/nvim-compe'
Plug 'tjdevries/colorbuddy.vim'
Plug 'tjdevries/gruvbuddy.nvim'
call plug#end()
@eginez
eginez / one.md
Last active August 12, 2021 02:17
Docker global limits via croups

Create slice file to limit resources: /etc/systemd/system/docker.slice

[Unit]
Description=Slice with MemoryLimit of 80% for docker
Before=slices.target

[Slice]
MemoryAccounting=true
MemoryMax=10%
@eginez
eginez / main.jl
Created July 3, 2021 18:55
Julia read stdout of proc
out = Pipe()
p = run(pipeline(`top`, stdout=out), wait=false)
## Now p is running in the background
## You can read out
output = String(read(out, 1024)) ## read() reads until eof, which is not what I need.
line = readline(out)
kill(p)
@eginez
eginez / main.py
Created June 6, 2021 15:52
ascii control codes
import sys
import time
from enum import Enum
class Decorations(Enum):
reset = u'\u001b[0m'
red = u'\u001b[31m'
bold = u'\u001b[1m'
green = u'\u001b[32m'
@eginez
eginez / gist:88244b27fe264df31d86ebf184c59107
Created March 22, 2021 17:29
Compensation software Seattle
# Statistics on eng positions in Seattle
Data coming from https://www.levels.fyi/js/salaryData.json
basesalary totalyearlycompensation yearsofexperience
count 1224.000000 1325.000000 1325.000000
mean 172.752042 324.453585 10.964151
std 32.179319 140.238469 2.373705
min 90.000000 100.000000 8.000000
25% 153.000000 226.000000 9.000000