Skip to content

Instantly share code, notes, and snippets.

View editors.md
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 Nov 28, 2018
Show git refs ordered by committer date DESC
View git-refs.md
#!/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

View ping-wrappers.ps1
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 Jul 10, 2017
PowerShell : Linux time command equivalent
View lastCommandTime.ps1
# 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
View powershell-repl-history.ps1
# 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 }
View psql-notes.md

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

View Intellij-idea-notes.md

Structural search

Find classes with the main method:

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

@vpetruchok
vpetruchok / intellij-idea-live-templates.md
Last active Oct 20, 2016
Intellij Idea Live Templates
View intellij-idea-live-templates.md

IntelliJ Idea Live Templates

  • main

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

@vpetruchok
vpetruchok / git-diff-plain.md
Last active Mar 17, 2016
git diff --word-diff=plain
View git-diff-plain.md
@vpetruchok
vpetruchok / git-merge-diff3.txt
Last active Mar 17, 2016
git merge.conflictStyle (diff3)
View git-merge-diff3.txt
# 3-way merge style
git config merge.conflictstyle diff3
# 2-way merge style (by default)
git config merge.conflictstyle merge