Skip to content

Instantly share code, notes, and snippets.

View astyagun's full-sized avatar

Anton Styagun astyagun

  • Russia
View GitHub Profile
@astyagun
astyagun / planNextAction.omnijs
Last active June 4, 2020 10:48
Добавить действие "Запланировать следующее действие" с контекстом "Мак"
/*{
"author": "Anton Styagun",
"targets": ["omnifocus"],
"type": "action",
"identifier": "com.antonstyagun.planNextAction",
"version": "0.1",
"description": "Добавить действие \"Запланировать следующее действие\" с контекстом \"Мак\"",
"label": "Запланировать следующее действие",
"mediumLabel": "Запланировать следующее действие",
"paletteLabel": "Запланировать следующее действие",
@astyagun
astyagun / vimed
Last active September 17, 2018 13:37
Use Vim in shell piped command chains
#!/bin/sh
# Use Vim in shell piped command chains
# https://gist.github.com/astyagun/952cb3b61b2d7d5e5d95b722d95bf428
(vim - -esbnN -c "$@" -c 'w!/dev/fd/3|q!' >/dev/null) 3>&1
@astyagun
astyagun / dump_config.rb
Created August 2, 2018 17:56
Dump Rails configuration using Pry
def dump_config
output = ''
Pry::ColorPrinter.pp(Rails.configuration, output, Pry::Terminal.width! - 1)
File.write 'current', output
end
@astyagun
astyagun / git-rerebase
Last active March 19, 2018 13:45
Rebase a number of branches on top of one another
#!/bin/sh
# Rebase a number of branches on top of one another
# https://gist.github.com/astyagun/0c9b0ea51ad9dd350c0d7326c364188f
#
# Given
#
# A---B---C
# /
# ----origin/A
#
@astyagun
astyagun / count_files
Last active October 18, 2017 05:19
Count files in first level subdirectories of a given directory, sort results by fins count in descending order
#!/bin/sh
if [ ! -d "$1" ]; then
echo \"$1\" is not a directory
exit 1
fi
find "$1" -type d -maxdepth 1 | xargs -I{} sh -c 'echo `find {} -type f | wc -l` {}' | sort -nr
@astyagun
astyagun / DefaultKeyBinding.dict
Last active January 29, 2025 10:08
macOS Emacs-alike text editing shortcuts, including Russian keyboard layout
{
/* macOS Emacs-alike text editing shortcuts, including Russian keyboard layout
* Reference:
* - https://gist.github.com/zsimic/1367779
* - http://xahlee.info/kbd/osx_keybinding.html
* - http://xahlee.info/kbd/osx_keybinding_action_code.html
* - http://osxnotes.net/keybindings.html
* - https://gist.github.com/cheapRoc/9670905
* https://gist.github.com/astyagun/fe665b93d9b79da584b0b9b41106d862 */
@astyagun
astyagun / git-difftool-mvim
Created September 20, 2017 16:07
Use MacVim as a Git difftool
#!/bin/sh
echo diffing file: ./$1
mvim -d -f -c 'set columns=200' -c 'normal =' "$2" "$3"
@astyagun
astyagun / gem-list-leaves
Last active December 11, 2024 03:39
List Ruby gems, that are not a dependency of any other gem (analog of `brew leaves`)
#!/bin/sh
# List Ruby gems, that are not a dependency of any other gem (analog of `brew leaves`)
# https://gist.github.com/astyagun/290b783045afffb8190a0c75ab76d0fa
GEMS_FILE=`mktemp`
DEPENDENCIES_FILE=`mktemp`
gem list -l | sed 's/ (.*//' | sort > $GEMS_FILE
cat $GEMS_FILE | xargs -n1 gem dependency -l --pipe | sed 's/ --version.*//' | sort -u > $DEPENDENCIES_FILE
comm -23 $GEMS_FILE $DEPENDENCIES_FILE
@astyagun
astyagun / tmux-shell
Last active June 9, 2019 19:52
tmux shell for macOS Terminal application
#!/bin/bash -l
# tmux shell for macOS Terminal application
#
# Starts tmux taking current directory and open tmux sessions into account
#
# When Terminal starts, it's $PWD always equals $HOME. Except cases when Terminal application was told to open
# some particular directory (`open ~/Code -a Terminal` for instance).
#
# In the first case we want to attach to existing tmux session if one exists. If there is more than one
# session open, the script will ask user which session to attach to.
@astyagun
astyagun / export_code_example
Created April 6, 2017 11:24
Extract and export code example into an archive
#!/usr/bin/env ruby
require 'fileutils'
SOURCE_DIRECTORY = File.expand_path raise 'Path to source directory is not set'
Dir.chdir SOURCE_DIRECTORY
TARGET_NAME = raise 'Target name is not set'
ARCHIVE_NAME = "#{TARGET_NAME}.zip"
TARGET_DIRECTORY = File.expand_path "../#{TARGET_NAME}"
ARCHIVE_TAGET_DIRECTORY = raise 'Archive target directory is not set'