Skip to content

Instantly share code, notes, and snippets.

View gko's full-sized avatar
🐑
📃💨

Konstantin gko

🐑
📃💨
View GitHub Profile
@gko
gko / setTimeout.scss
Last active June 27, 2023 00:24
setTimeout mixin
/**
* @include setTimeout(timeout) {
* properties to change to
* }
*/
@use "sass:string";
@mixin setTimeout($timeout) {
$animation-name: animation-#{string.unique_id()};
const getPercentageRounds = function(percentage = 1) {
const blueSpotSymbol = "🔵";
const emptySpotSymbol = "⚪";
// 1 to 10
const convertedPercent = Math.ceil(percentage * 10);
const blueSpots = Array(convertedPercent).fill(blueSpotSymbol);
const emptySpots = Array(10 - convertedPercent).fill(emptySpotSymbol);
return [...blueSpots, ...emptySpots].join('');
// https://twitter.com/fermatslibrary/status/875340896379817984/photo/1
const memoizedWords: {
[Key: string]: number;
} = {};
const ALPHABET_MAPPED_TO_PRIME_NUMBERS: {
[Key: string]: number;
} = {
a: 2,
b: 3,
@gko
gko / hi.vim
Created May 22, 2020 08:43
show highlight under cursor
echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"
@gko
gko / rename_branch.sh
Created May 1, 2020 12:00
rename git branch (local and remote)
#!/usr/bin/env bash
rename_branch() {
[[ $# = 2 ]] && local from=$1 || local from=`git symbolic-ref -q --short HEAD`
local to=${2:-$1}
git branch -m $from $to
git push origin :$from $to
git push origin -u $to
}
@gko
gko / .gitconfig
Created April 22, 2020 11:09
webstorm as merge and difftool for git
[difftool "webstorm"]
cmd = /Applications/WebStorm.app/Contents/MacOS/webstorm diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
trustExitCode = true
[mergetool "webstorm"]
cmd = /Applications/WebStorm.app/Contents/MacOS/webstorm merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
trustExitCode = true
[merge]
keepBackup = false
@gko
gko / fromhex.bash
Created March 20, 2020 10:45 — forked from mhulse/fromhex.bash
Bash function to convert hex to 256 terminal color.
# fromhex A52A2A
# fromhex "#A52A2A"
# BLUE_VIOLET=$(fromhex "#8A2BE2")
# http://unix.stackexchange.com/a/269085/67282
function fromhex() {
hex=$1
if [[ $hex == "#"* ]]; then
hex=$(echo $1 | awk '{print substr($0,2)}')
fi
r=$(printf '0x%0.2s' "$hex")
@gko
gko / alter_theme.sh
Created February 22, 2020 07:02
switch colorscheme between 7h and 18h keep the light theme
function alter_theme() {
local current_hour=$(date +%H)
if [[ $current_hour -ge 7 && $current_hour -lt 18 ]]; then
base16_classic-light
else
base16_material-palenight
fi
}
@gko
gko / generateAliasesFromGit.sh
Created February 7, 2020 20:38
generate aliases from git
# generate aliases from gitconfig aliases
function generateAliasesFromGit() {
git config --get-regexp ^alias\\. | while read gitAlias; do
local aliasName=$(echo $gitAlias | sed -E 's/^alias\.([a-z_\-]*).*/\1/')
# alias only if there is no collision
if ! type "g$aliasName" >/dev/null 2>&1; then
alias g$aliasName="git $aliasName"
fi
done
#!/bin/bash
# This script takes a remote repository and merges it into
# the current one as a subdirectory
set -e
if [ -z "$1" ]
then
echo "Usage:"