Skip to content

Instantly share code, notes, and snippets.

@kolomenkin
kolomenkin / version.sh
Last active May 19, 2022 18:02
Version script to calculate software version from git tags and current date in format: <major>.<minor>.<patch>-<current-year-2-digits><current-day-of-year>.<commit-hash>[.dirty]
#!/usr/bin/env bash
script_version="1.33"
set -e
set -u
set -o pipefail
# set -x
# ==================================================
# This script calculates and prints a software version
@kolomenkin
kolomenkin / clean_msvc_recursive.bat
Created June 12, 2017 12:52
Delete all MSVC generated files from specified directory recursively
@echo off
if "%~1" == "" goto sub_help
REM ===================================================
setlocal
echo Removing all MSVC generated files from %1 recursively...
%~d1
cd "%~1" || goto sub_cd_error
echo Current directory: %CD%
@kolomenkin
kolomenkin / PrecompiledHeader.cmake
Created December 27, 2016 11:09 — forked from larsch/PrecompiledHeader.cmake
cmake module for setting up precompiled headers (MSVC & GCC)
# Function for setting up precompiled headers. Usage:
#
# add_library/executable(target
# pchheader.c pchheader.cpp pchheader.h)
#
# add_precompiled_header(target pchheader.h
# [FORCEINCLUDE]
# [SOURCE_C pchheader.c]
# [SOURCE_CXX pchheader.cpp])
#
git init
git commit --allow-empty -m "initial empty commit"
# Recursively set executable flags for all shell files in git:
find . -name '*.sh' -exec git update-index --chmod=+x "{}" \;
@kolomenkin
kolomenkin / submodule_update_alturl.sh
Last active April 25, 2016 12:56 — forked from vi/submodule_update_alturl.sh
"git submodule update --init --recursive" with second change for submodules referencing unpushed code (alternative URIs for submodules)
#!/bin/bash
script_version="1.04"
unset CDPATH
if [[ $1 = "--help" ]]; then
echo >&2 "Script version: $script_version"
echo >&2 "Expected environment example: ALTURL_repo1name=https://github.com/user1/repo1name.git ALTURL_repo2name=https://github.com/user1/repo2name.git ..."
echo >&2 "Expected environment example: mangle_submodule_name() - it should mangle its argument: 'repo/1/name' -> 'repo_1_name'"
echo >&2 "Expected environment example: submodule_recurse_script=update-checkout.sh submodule_recurse_arguments='arg1 arg2 arg3'"
@kolomenkin
kolomenkin / gittemplater.sh
Last active April 25, 2016 12:57 — forked from vi/envtemplater
Simplify setting multiple environment variables using templates
#!/bin/bash
script_version="1.08"
SUBST="@repo@"
SAVE_IFS="$IFS"
if [[ -z $1 || $1 = "--help" ]]; then
echo >&2 "Git-specialized version of tool: $script_version"
echo >&2 "Usage: T_template1=substitution1 ... T_templateN=substitutionN ./envtemplater.sh repo1@template ... repoN@template -- command [arguments]"
echo >&2 "Example: T_github=ALTURL_${SUBST}=https://github.com/vi/${SUBST}.git ./envtemplater.sh dive@github fdlinecombine@github -- ./submodule_update_alturl.sh --force"