Skip to content

Instantly share code, notes, and snippets.

View NonLogicalDev's full-sized avatar

Oleg Utkin NonLogicalDev

View GitHub Profile
@NonLogicalDev
NonLogicalDev / gist:2fad55f52c26dcd633966c69dd483955
Created September 27, 2022 17:33
Enable IntelliJ Experimental UI
--- /Users/USER/Library/Application Support/JetBrains/IntelliJIdea2022.2/before.txt 2022-09-27 10:30:08.000000000 -0700
+++ /Users/USER/Library/Application Support/JetBrains/IntelliJIdea2022.2/jba_config/ide.general.xml 2022-09-27 10:31:36.000000000 -0700
@@ -1,34 +1,36 @@
<application>
<component name="GeneralSettings">
<option name="autoSaveIfInactive" value="true" />
<option name="confirmExit" value="false" />
<option name="confirmOpenNewProject2" value="0" />
<option name="inactiveTimeout" value="5" />
<option name="processCloseConfirmation" value="TERMINATE" />
@NonLogicalDev
NonLogicalDev / stg-fixup.sh
Last active June 15, 2023 19:06
Utilities for fixing up stacked git stack in case of accidental modifications.
#!/bin/bash
# DEPENDENCIES:
# - git
# - stg
# - jq
# Stacked git records metadata in two commits:
#
# 1. Octopus commit that is a "merge" commit that has parent links to:
@NonLogicalDev
NonLogicalDev / osc52.sh
Last active March 22, 2022 19:30
osc52 is a utility for copying to system clipboard via osc52 escape sequences.
#!/bin/bash
#
# osc52 is a utility for copying to system clipboard via osc52 escape sequences.
#
# If your terminal supports these sequences this enables you
# to copy things from remote SSH sessions to system clipboard.
#
# Convenient when you're using lots of in-browser terminals or working on a remote server.
#
# Usage:
stg-checked-refresh-index() {
#: stg-checked-refresh-index
#: `stg refresh --index` but with diff preview and confirmation
#:
TARGET_PATCH=$(stg top)
git diff --cached -u --stat
git --no-pager diff --cached --stat
@NonLogicalDev
NonLogicalDev / stg-repair-top.sh
Last active March 23, 2022 20:07
Stacked git helper script to repair topmost amended commit.
# A collection of improvised utilites to fixup stacked git metadata
@NonLogicalDev
NonLogicalDev / git-ls-index.py
Created November 16, 2021 01:51
A toy git index file parser in python
#!/usr/bin/env python3
from io import TextIOWrapper
from typing import List
import os
import sys
import math
import json
import datetime
@NonLogicalDev
NonLogicalDev / main.go
Created January 26, 2021 00:11
Go Cobra Environment Mapping Example
package main
import (
"context"
"fmt"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
@NonLogicalDev
NonLogicalDev / vault-list-tokens.sh
Last active January 6, 2021 08:42
List all token accessors with creation dates and met information.
#!/bin/sh
vault list -format json /auth/token/accessors \
| jq -r '.[]' | xargs -I % vault token lookup -format=json -accessor % \
| jq -cr '.data|[(.creation_time | todate),.accessor,.display_name,(.meta|tojson)]|join("%%")' \
| column -t -xs %% | sort -h
package main
import (
"encoding/json"
"fmt"
"sort"
"strings"
"sync"
"time"