App-Cheats
view release on metacpan or search on metacpan
#############################################################
## Git - Log Commands
#############################################################
# Show/Check commit log (basic usage)
git log
# Show/Check commit log with plus's for revisions per file
git log --stat
# Show/Check a summary of the commit log (does not seem too useful)
git log --summary
# Show/Check a really fancy progression of the branch revisions (commit log)
git log --oneline --decorate --graph --all --tags
# See which what fetched changes need to be merged
git log --no-merges
# Find all log commits whose files match a pattern
git log -Garinc_xmt
# Find all commits where a file was changed (affected)
git log --follow <file>
git log <file>
# Show all commits/changes for a file (diff,generate patch report)
git log -p <file>
git log --patch <file>
# Show all commits/changes for a file in chronological order (diff,patch report)
git log -p --reverse <file>
# Display log without a pager
git -no-pager log
# Display a list of all commits made to a branch (prepare for cherry-pick)
# Shows commits which are not in the branch before ".."
# (In other words, unique to the branch).
git log --no-merges BRANCH..
git --no-pager log --no-merges rel-8_0.. --oneline --reverse --no-abbrev-commit
#
# Same but includes the committer (author).
local format="%C(yellow)%H%Creset %Cred%cn%Creset %s"
git --no-pager log --no-merges $branch.. --reverse --pretty="format:$format"
echo ""
# Display a list of all files changed between commits
git --no-pager log --no-merges rel-8_0.. --name-only --pretty= | sort -u
# Search for text in commit message.
git log --grep COMMIT_TEXT
#############################################################
## Git - RefLog Commands
#############################################################
# git reflog can be useful if you messed something up with a branch:
# Such as:
# - Accidentally did a hard reset.
# - Undo merge/rebase.
# - Remove deleted branches.
# - Fix detached HEAD state.
#############################################################
## Git - Push/Pull Commands
#############################################################
# Push upstream to origin from the branch (only after using -u switch)
git push
# Fetch (sync) from the assigned repository (but do NOT checkout any files)
git fetch
# Fetch from repository (origin)
git fetch origin
# Sync with a specific repository (but do NOT checkout any files)
git fetch <url>
# Pull down changes to branch from origin
git pull origin master
git pull github master
# Warning when pulling from github/gitlab:
X11 forwarding request failed on channel 0
#
vi ~/.ssh/config
#
Host git.otrs.com
ForwardX11 no
# When there is a conflict when pulling a branch,
# this will pull in the changes and put your commits
# as last
git pull --rebase
# Push upstream to origin from the branch
git push -u origin master
git push github addsvn
# Remove a remote branch
git push --delete origin <branch name>
# Checkout latest commit version of a single file
git init
git fetch <url>
git checkout FETCH_HEAD <file>
# Checkout select commit version of a single file
git init
git fetch <url>
git checkout -m <commit_id> <file>
# Checkout a specific version of a single file
git checkout -m <commit_id> file
# Checkout a file from another branch
git checkout master file1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
16 10000
17 10001
18 10010
19 10011
20 10100
21 10101
22 10110
23 10111
24 11000
25 11001
26 11010
27 11011
28 11100
29 11101
30 11110
31 11111
32 100000
33 100001
34 100010
35 100011
36 100100
37 100101
38 100110
39 100111
40 101000
#############################################################
## Perl Bugs
#############################################################
# Global our must be used within regex embedded code (bug)
# Appears to only be a problem in older versions of Perl
perl -le 'sub func{my($t)=@_; my $s; my $m = $t =~ m{ (?{ $s //= $-[0] }) \d}x; print "t=[$t]\ns=[$s]\nm=[$m]\n"} func 1; func 1'
perl -le 'sub func{my($t)=@_; our $s; my $m = $t =~ m{ (?{ $s //= $-[0] }) \d}x; print "t=[$t]\ns=[$s]\nm=[$m]\n"} func 1; func 1'
# Segmentation fault in perl on some systems (Gentoo,SEGV)
# https://github.com/Perl/perl5/issues/19147
perl -we '$a{$b}'
# Run script multiple times in order and stop on the first error.
for n in {1..1000}; do perl -I. -IKernel/cpan-lib -MSchedule::Cron::Events -E 'eval{ Schedule::Cron::Events->new("* * 0 * *", Date => [ 16, 25, 16, 10, 7, 123])}; say "OK"'; if [ $? -ne 0 ]; then echo "STOPPED on run: $n"; break; fi; done
# Perl SEGV due to confess
https://github.com/Perl/perl5/issues/15928
# Variable suicide bug (fixed pre v5.6)
https://perldoc.perl.org/perlfaq7#What-is-variable-suicide-and-how-can-I-prevent-it?
perl -E 'my $f = 'foo'; sub func { while ($i++ < 3) { my $f = $f; $f .= "bar"; say $f }} func; say "Finally $f\n"' foobar foobar
foobar
Finally foo
# Perl lexical variable eval bug (fixed after 5.40).
https://www.perlmonks.org/?node_id=11158351
https://github.com/Perl/perl5/pull/22097
# Refresh a Module (bug):
https://www.perlmonks.org/?node_id=11161935
#############################################################
## Perl Compile
#############################################################
# Compile a perl script into c code (only on lnxbr42) (really slow)
pp -o hello hello.pl
# Run c/cpp code inside perl (Compile)
perldoc Inline
#############################################################
## Perl Configuration
#############################################################
# Print all the perl configuration variables
perl -V:.*
# Check if little or big endian
perl -V:byteorder
byteorder='12345678' # Little
# Show all perl configuration options.
perl -MConfig -Me -e 'p \%Config'
#############################################################
## Perl Debugger
#############################################################
# Library to enable using up arrow key in perl debugger window (-de0)
sudo apt install libreadline-dev
# Check for paste bracketing
bind -V | grep paste
enable-bracketed-paste is set to `on'
#
# Enable paste bracketing
if [ -n "$PS1" ]; then
bind 'set enable-bracketed-paste on'
fi
# Create a perl debug file. Watch parameters. view code around (v) (debugger)
cat > .perldb
@DB::typeahead = (
'{{v',
# 'c',
# 'Nonstop',
#
# Need to run after updating cryptab:
sudo update-initramfs -u -k all
#
# Add device to be auto mounted
sudo vi /etc/fstab
srto_backup /media/SRTO_BACKUP auto nosuid,nodev,nofail,x-gvfs-show 0 2
# Close encrypted drive
sudo umount /dev/mapper/luks-ea444ab0-445e-4c5c-931b-27922bfa5510
sudo cryptsetup close luks-ea444ab0-445e-4c5c-931b-27922bfa5510
# file found here:
ll /dev/mapper/
#############################################################
## Ubuntu - Hard Drive Create and Delete
#############################################################
# Wipe an external hard drive (with Marco,ubuntu,hd)
#
# Find device here.
lsblk
#
# Remove signature.
sudo wipefs -a /dev/sdb
#
sudo cfdisk /dev/sdb
# Setup a new external hard drive (with Marco,ubuntu,hd)
lsblk # To find out DEVICE name
sudo cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/DEVICE
sudo cryptsetup luksOpen /dev/DEVICE srto_backup
sudo mkfs.ext4 -L MY_BACKUP /dev/mapper/srto_backup
sudo mount /dev/mapper/srto_backup /media/<USER>/SRTO_BACKUP
#############################################################
## Ubuntu - Evolution
#############################################################
# Completely remove ubunutu evolution services.
https://askubuntu.com/questions/315640/how-do-i-completely-remove-evolution
#
cd /usr/share/dbus-1/services
sudo cp org.gnome.evolution.dataserver.* /home/<USER>/my/git/srto/evolution/_usr_share_dbus-1_services/
sudo ln -snf /dev/null org.gnome.evolution.dataserver.Calendar8.service
sudo ln -snf /dev/null org.gnome.evolution.dataserver.
sudo ln -snf /dev/null org.gnome.evolution.dataserver.Sources5.service
sudo ln -snf /dev/null org.gnome.evolution.dataserver.UserPrompter0.service
#############################################################
## Ubuntu - Filesystem
#############################################################
# Show Hide/Hidden Files (Ubuntu)
Control + H
# Mount wired network connection (Ubuntu,linux)
# Useful is policykit-i is accidentally removed
sudo dhclient -v usb0
# Remove trash icon in Ubuntu left panel.
gsettings get org.gnome.shell.extensions.dash-to-dock show-trash # true
gsettings set org.gnome.shell.extensions.dash-to-dock show-trash false
# Trash folder locaiton on Ubuntu
~/.locat/share/Trash
#############################################################
## Ubuntu - Shortcuts
#############################################################
# Screenshot (Ubuntu)
Druck + Click and drag + Enter # Snippet.
Shift + Druck # Full screenshot.
Control + Alt + Fn + (F1,F2..F12) # Switch display.
#############################################################
## Ubuntu - Filesystem - ZFS
#############################################################
# Create a new zpool
sudo fdisk -l # Find device path here
# Destroy (completely remove) a zpool
# WILL DELETE ALL DATA INSIDE
sudo zpool destroy brpool
# Unmount a busy device
umount -l /PATH/OF/BUSY-DEVICE
umount -f /PATH/OF/BUSY-NFS (NETWORK-FILE-SYSTEM)
# ZFS list snapshots
zfs list -r -t snapshot -o name,creation
# Send snapshot backup
sudo zfs send rpool/USERDATA/tim_e5bkz1@autozsys_zh25vd | sudo zfs receive brpool/USERDATA
# Send incremental backup
sudo zfs send rpool@june15b | sudo zfs receive -Fd brpool
# Mount external hard drive with ZFS
sudo zpool list # Show available pools
sudo zpool import # Shows the brpool name
sudo zpool import brpool # Import brpool
sudo zpool list # Pool now added
# Create a Snapshot with a specific text
sudo zfs snapshot rpool/USERDATA/tim_e5bkz1@june15
# View mounting options for ZFS (zpool)
sudo zfs get 'mountpoint,mounted,canmount' brpool/USERDATA
# zpool status is SUSPENDED
sudo zpool clear brpool
sudo zpool clear -nFX brpool # Or this
#############################################################
## Vim Other
#############################################################
# Join lines (Vim)
J
# Repeat last text-changing command (Vim)
.
# Undo last change (Vim)
u
# Undo all changes to line (Vim)
U
# Redo last command (Vim)
<Control> + r
# Diplay file name, number of lines (and percent) (Vim)
<Control> + g
# Type a control character in Vim
Control-V <RET>
# Convert binary to hex (Vim)
:%!xxd
# Comment a block of lines (Vim)
<Control> + v
# Scroll down with arrow keys
<Shift> + i
# Change first line to have a comment
ESC
# all other lines will have same change (comments added)
# Scroll down half a page (Vim)
<Control> + D
# Scroll up half a page (Vim)
<Control> + U
# Find documentaion for a lookahead (Vim)
:h \@
# View Vim variables (Vim)
:set
# History is not working (Vim)
# Check permissions of ~/.viminfo
# View man page (Vim,help)
:h
# Search for spaces (Vim)
/\s\+
# \+ since all are taken literally unless escaped
# If accidentally pressed <Control> + s (Vim)
# that will freeze the terminal. This is due to "flow control"
# Do this to undo the effect:
<Control> + q
#
# To permanently disable this from occurring put this in .bashrc
stty -ixon
# Stop all output to terminal/xterm (Vim)
<Control> + s
# Restart output to terminal/xterm (Vim)
<Control> + q
# ERROR: the command is not available in this version (Vim)
sudo apt-get install vim
# Compare files (Vim)
vimdiff file1 file2 # vertical split
vimdiff -o file1 file2 # horizontal split
# Open multiple files in split screens (Vim(
vim -O file1 file2 # vertical split
vim -o file1 file2 # horizontal split
# View history of searches (Vim)
q/
# View history of commands (Vim)
q:
# Open stream from STDIN (Vim)
echo "abc" | vi -
#############################################################
## Visual Basic Script (.vbs)
#############################################################
# Remove RSIGaurd process (.vbs)
Dim strComputer
DIm objWMIService
Dim colProcessList
Dim objProcess
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'RSIGuard.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
#
# Same with perl
perl -e "kill -9,`tasklist`=~/RSIGuard\D+(\d+)/g"
# Convert .msg files to .txt files (extract text from outlook, .vbs)
Set ol = CreateObject("Outlook.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
inputString = "S:\controls\cert\<USER>\msg"
REM inputString = InputBox("Enter the full path to the .msg folder: ")
For Each f In fso.GetFolder(inputString).Files
If LCase(fso.GetExtensionName(f)) = "msg" Then
( run in 2.126 seconds using v1.01-cache-2.11-cpan-98e64b0badf )