Skip to content

Instantly share code, notes, and snippets.

View diafour's full-sized avatar

Ivan Mikheykin diafour

View GitHub Profile
echo 'export DEB_CFLAGS_MAINT_APPEND="-O3 -march=native -ftree-vectorize -flto -fprefetch-loop-arrays"' | sudo tee -a /etc/dpkg/buildflags.conf
echo 'export DEB_CXXFLAGS_MAINT_APPEND="-O3 -march=native -ftree-vectorize -flto -fprefetch-loop-arrays"' | sudo tee -a /etc/dpkg/buildflags.conf
@diafour
diafour / c_nostd.txt
Created March 17, 2025 17:44 — forked from tcoppex/c_nostd.txt
Writing C software without the standard library [Linux Edition] - Franc[e]sco's Gopherspace
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
stop there.
I will provide a more complete explanation that will allow you to
build yourself a little framework to write more complex programs.
@diafour
diafour / __usage
Last active September 24, 2024 14:01
d8-virtualization debug report for module
curl -sLo - https://gist.github.com/diafour/ede2238e6d7fbec9e5dff527f1b71788/raw/75e1aa6ef98f9ab8e83b866a6837047ff8293dfe/debug-report-module.sh | bash -s
@diafour
diafour / cluster-23.sh
Created June 9, 2023 12:38
Run kind cluster with access to local registry
#!/usr/bin/env bash
# A helper for kind to create and delete clusters with untrusted local registry.
# Based on https://kind.sigs.k8s.io/docs/user/local-registry/
#
# Note: kind 0.17.0
set -Eeo pipefail
# Settings for kind cluster
@diafour
diafour / gist:d601a5f5adfc02549a47e12815f40964
Created January 7, 2021 08:36
python psycopg2 fetchall
cur = self.conn.cursor()
cur.execute(
"""
SELECT
user_id
FROM
user_state
"""
)
user_ids = cur.fetchall()
@diafour
diafour / logrus_test.go
Created December 12, 2020 14:24
logrus with short caller and caller only for some levels
import (
"fmt"
"runtime"
"testing"
"github.com/sirupsen/logrus"
)
type MyFormatter struct {
@diafour
diafour / jq.test
Created March 31, 2020 18:14
jq fromjson or tostring problem
try (tonumber) catch ("Should catch error")
"a20"
"Should catch error"
# Tests are groups of three lines: program, input, expected output
# Blank lines and lines starting with # are ignored
#
# Simple value tests to check parser. Input is irrelevant
#
@diafour
diafour / cluster-19.sh
Last active February 19, 2025 12:11
Run kind cluster with access to local registry
#!/usr/bin/env bash
# A helper for kind to create and delete clusters with untrusted local registry.
# Based on https://kind.sigs.k8s.io/docs/user/local-registry/
#
# Note: kind 0.10.0
# Settings for kind cluster
CLUSTER_NAME="kube-19"
KIND_NODE_IMAGE="kindest/node:v1.19.7"
@diafour
diafour / gist:4ece0ee1157615bde5ed351e2e09a17d
Created April 16, 2019 10:22
tda2000.ru highlight M positions
(function() { var countM = 0; var countRows = $("table.catalog-item-list tr").each(function() { var t = $(this).find("td.catalog-item-nal div.catalog-item-nal-yes span b").text(); if (t == 'М') { $(this).css('background-color','pink'); countM++; } ; if (t!='М') {$(this).css('visibility', 'collapse')} } ).length; return {'M':countM, 'All':countRows}; })()
@diafour
diafour / gist:ab3cb34859de4e0c8d17c839548a9b31
Created December 19, 2017 18:51
Commiters stats from git repository
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}'