Skip to content

Instantly share code, notes, and snippets.

@vpetruchok
vpetruchok / vim-trailing-spaces.md
Created July 30, 2023 18:42
Vim trailing spaces
set listchars=trail:·,tab:>→,nbsp:% ",eol:¶
set list
highlight ExtraWhitespace ctermbg=green ctermfg=blue guibg=green guifg=blue
match ExtraWhitespace /\s\+$/

fun! TrimRight()
  %s/\v\S\zs\s+$//
endfunction
@vpetruchok
vpetruchok / editors.md
Last active December 5, 2020 22:11
Editors
Task Emacs Vim
Quit Editor with an error code (kill-emacs <exitcode>) :cq
Toggle whitespace visualization M-x whitespace-mode :set list!
@vpetruchok
vpetruchok / git-refs.md
Last active November 28, 2018 13:28
Show git refs ordered by committer date DESC
#!/bin/sh

git for-each-ref --sort=-committerdate --format '%(objectname:short) %(objecttype) %(refname) | %(committerdate:relative)  %(if)%(authorname)%(then)(by %(authorname) %(authoremail))%(end)' "$@" | column  -t -s\|

Documentation: https://git-scm.com/docs/git-for-each-ref

Fields for the --format option

@vpetruchok
vpetruchok / ping-wrappers.ps1
Last active July 13, 2017 07:50
Ping wrappers
function playNotificationSound() {
# From http://scriptolog.blogspot.com/2007/09/playing-sounds-in-powershell.html
$sound = New-Object System.Media.SoundPlayer;
$sound.SoundLocation="c:\WINDOWS\Media\notify.wav";
$sound.Play();
}
function p() {
Param(
$ComputerName="google.com"
@vpetruchok
vpetruchok / lastCommandTime.ps1
Created July 10, 2017 07:53
PowerShell : Linux time command equivalent
# from http://stackoverflow.com/questions/3513650/timing-a-commands-execution-in-powershell
function lastCommandTime() {
$command = Get-History -Count 1
return $command.EndExecutionTime - $command.StartExecutionTime
}
set-alias lct lastCommandTime
@vpetruchok
vpetruchok / powershell-repl-history.ps1
Created July 10, 2017 07:49
PowerShell Repl History
# from https://superuser.com/questions/880213/automatically-export-history-at-end-of-powershell-session
$HistoryFilePath = Join-Path ([Environment]::GetFolderPath('UserProfile')) .ps_history
Register-EngineEvent PowerShell.Exiting -Action { Get-History | Export-Clixml $HistoryFilePath } | out-null
if (Test-path $HistoryFilePath) { Import-Clixml $HistoryFilePath | Add-History }

psql connection parameters

Parameter name Command line argurment Environment variable
Database name -d database $PGDATABASE
Hostname -h host $PGHOST
Port -p port $PGPORT
User name -U username $PGUSER

Usefull settings

Structural search

Find classes with the main method:

public static void main(String[] $param$);

@vpetruchok
vpetruchok / intellij-idea-live-templates.md
Last active October 20, 2016 22:48
Intellij Idea Live Templates

IntelliJ Idea Live Templates

  • main

    public static void main(String[] args){
        $END$
    }
  • printf

@vpetruchok
vpetruchok / git-diff-plain.md
Last active March 17, 2016 11:25
git diff --word-diff=plain