Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
CGO_ENABLED=1 go build -v -o libhello.so -buildmode=c-shared libhello.go
python3 -c 'import ctypes;lib = ctypes.CDLL("./libhello.so");print(lib.HelloWorld())'
@alexdyukov
alexdyukov / text_manipulation_bash_shortcuts
Created October 9, 2021 22:58
text manipulation bash shortcuts
#replace 'string1' with 'string2'
sed 's/string1/string2/g'
#modify 'anystring1' to 'anystring2'
sed 's/\(.*\)1/\12/g'
#remove comments and blank lines
sed '/^ *#/d; /^ *$/d'
#remove trailing spaces from lines
@alexdyukov
alexdyukov / .bash_aliases
Last active December 7, 2023 18:25
bash aliases
shopt -s histappend
export PROMPT_COMMAND='history -a'
export CGO_ENABLED="0"
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:/usr/local/go/bin
COMMON_CREDITIAL='salt'
export GIT_SSH_COMMAND='ssh -i ~/.ssh/fake -o IdentitiesOnly=yes'
export GOPRIVATE=gitlab.mycompany.com
function gofix() {
@alexdyukov
alexdyukov / SEMVER
Last active March 4, 2023 17:29
Easy semver for github-flow
# semver: increment MAJOR version when you make incompatible API changes
# magic number 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is git commit hash of null (before init commit)
MAJOR_VERSION=0
MAJOR_LAST_COMMIT_HASH="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
# semver: increment MINOR version when you add functionality in a backwards-compatible manner
MINOR_LAST_COMMIT_HASH=$(git rev-list --invert-grep -i --grep='fix' ${MAJOR_LAST_COMMIT_HASH}..HEAD --no-merges -n 1)
MINOR_VERSION=$(git rev-list --invert-grep -i --grep='fix' ${MAJOR_LAST_COMMIT_HASH}..HEAD --no-merges --count)
[ "${MINOR_LAST_COMMIT_HASH}" = "" ] && MINOR_LAST_COMMIT_HASH=${MAJOR_LAST_COMMIT_HASH}
#!/usr/bin/env bash
# FILE: cleanup_cms_caches.sh
# Brief: Detect CMS and clear its cache
# Author: @AlexDyukov
# Requirement: wp-cli, drush
if (( $# == 0 )); then
echo -e "site path not present\nusage: $0 /home/[a-z]/*/*/public_html/"
exit 1