pull/176/head
Igor Chubin 2 years ago
commit 45fb761f78

@ -34,6 +34,7 @@ Ctrl + p - previous command (↑)
Ctrl + n - next command (↓)
Ctrl + o - execute displayed command from history, don't clear command line
Alt + . - recall last argument (word) of last executed command
Alt + - + . - recall second last argument (word) of last executed command
# -= Terminal control =-
Ctrl + l - clear screen, don't clear command line

@ -4,6 +4,9 @@
// Null is an Object
typeof null // => 'object'
// Weird decimal calculation
0.1 + 0.2 // -> 0.30000000000000004
// Despite this, null is not an instance of an Object
null instanceof Object // => false

@ -0,0 +1,41 @@
# A decorator is a design pattern in Python that allows a user
# to add new functionality to an existing object without modifying
# its structure. Decorators are usually called before the definition
# of a function you want to decorate.
# In simple words: they are functions which modify the functionality
# of other functions.
from datetime import datetime
def my_decorator(func):
def wrapper():
print('start', datetime.now())
func()
print('end', datetime.now())
return wrapper
@my_decorator
def my_method():
for i in range(1, 100000):
pass
my_method()
# start 2021-06-07 15:29:51.330086
# end 2021-06-07 15:29:51.333832
# Decorator with function parameters.
def my_decorator(func):
def wrapper(start, end):
print('start', datetime.now())
func(start, end)
print('end', datetime.now())
return wrapper
@my_decorator
def my_method(start, end):
for i in range(start, end):
pass
my_method()
# start 2021-06-07 15:29:51.330086
# end 2021-06-07 15:29:51.333832

@ -0,0 +1,20 @@
# Declare a function that behaves like an iterator.
# Any function with yield returns generator.
# Generators follow lazy evaluation.
# lazy evaluation means that the object is evaluated when it is needed,
# not when it is created.
def my_generator(start, end, step=1):
while start < end:
yield start
start += step
gen = my_generator(start=1, end=10)
next(gen), next(gen), next(gen)
# (1, 2, 3)
gen = (i for i in range(1, 100) if i%2==0)
next(gen), next(gen), next(gen), next(gen)
# (2, 4, 6, 8)
# https://wiki.python.org/moin/Generators

@ -20,7 +20,7 @@ l map { //note: the curly brackets allow us to make the map multi-line and us
l filter (_ % 2 == 0) //returns List(2,4)
// filterNot
l filter (_ % 2 == 0) //returns List(1,3,5)
l filterNot (_ % 2 == 0) //returns List(1,3,5)
// collect
// this is like a combination of filter and map

@ -35,7 +35,7 @@ abstract class D { ... }
class C extends D { ... }
class D(var x: R)
// inheritance and constructor params. (wishlist: automatically pass-up params
// inheritance and constructor params. (wish list: automatically pass-up params
// by default)
class C(x: R) extends D(x)

@ -2,7 +2,7 @@
# Method for when the solution to a problem depends on solutions to smaller
# instance of the same problem; a self-calling function.
# Recursive programs - Pseduocode
# Recursive programs - Pseudocode
function factorial:
input: integer n such that n >= 0
output: n * (n-1) * (n-2) * ... * 1 = n!

@ -0,0 +1,10 @@
# apt-config
# APT Configuration Query program
# List all APT (and related) configuration options and their values.
apt-config dump
# List regular expressions used to match packages to be ignored by apt-get(8)'s
# `autoremove` functionality. Assumes `;` or some other undesired character
# will be at the end of the string.
apt-config dump | awk '/^APT::NeverAutoRemove::/ {print(substr($2, 0, length($2) - 1))}'

@ -48,7 +48,7 @@ awk '{NR != 1 && A[$1]=$2} END {print(A["Mem:"])}' <(free -h)
# the same, and in other cases, the above is definitely preferable.
awk '/^Mem:/ {print($2)}' <(free -h)
# Output list of unique uppercase-only, sigil-omitted variables used in [FILE].
# Output list of unique uppercase-only, sigil-omitted variables used in FILE.
awk '
{
for(F=0; F<NF; F++){
@ -63,10 +63,10 @@ awk '
printf("%s\n", X)
}
}
' [FILE]
' FILE
# Output only lines from FILE between PATTERN_1 and PATTERN_2. Good for logs.
awk '/PATTERN_1/,/PATTERN_2/ {print}' [FILE]
awk '/PATTERN_1/,/PATTERN_2/ {print}' FILE
# Pretty-print a table of an overview of the non-system users on the system.
awk -F ':' '
@ -82,3 +82,21 @@ awk -F ':' '
# a painful but useful workaround to get the units comma-separated, as would be
# doable with Bash's own `printf` built-in.
awk '/^MemTotal:/ {printf("%'"'"'dMiB\n", $2 / 1024)}'
# It's possible to sort strings in AWK, as well as uniq-ing, meaning you can
# replace uniq(1) and sort(1) calls with just the one call of AWK. Granted, you
# can use `sort -u` to do both, but AWK offers much more functionality.
#
# Unlike when using AWK to uniq-ify, uniq(1) only works by adjacency, meaning
# the duplicate lines must be adjacent to one another for them to be handled.
awk '
{
!Lines[$0]++
}
END {
asorti(Lines, Sorted)
for (Line in Sorted) {
print(Sorted[Line])
}
}
' FILE

@ -45,7 +45,7 @@ az vm open-port --resource-group MyRG --name MyLinuxVM --port 443 --priority 899
# Show storage accounts
az storage account list --output table
# Show contaniers for an account
# Show containers for an account
az storage container list --account-name mystorageaccount --output table
# Show blobs in a container

@ -8,13 +8,13 @@ mkfs.btrfs -m single /dev/sdb
# data to be redundant and metadata to be non-redundant:
mkfs.btrfs -m raid0 -d raid1 /dev/sdb /dev/sdc /dev/sdd
# both data and metadata to be redundan
# both data and metadata to be redundant
mkfs.btrfs -d raid1 /dev/sdb /dev/sdc /dev/sdd
# To get a list of all btrfs file systems
btrfs filesystem show
# detailed df for a fileesystem (mounted in /mnt)
# detailed df for a filesystem (mounted in /mnt)
btrfs filesystem df /mnt
# resize btrfs online (-2g decreases, +2g increases)

@ -1,4 +1,4 @@
# POSIX-ly correct way in which to cat(1); see cat(1posix).
# POSIX way in which to cat(1); see cat(1posix).
cat -u [FILE_1 [FILE_2] ...]
# Output a file, expanding any escape sequences (default). Using this short

@ -1,5 +1,5 @@
# Currency (Bash-Snippets)
# A realtime currency converter
# A real time currency converter
# To convert between currencies (guided)
currency

@ -1,5 +1,5 @@
# enhanced version of GNU dd with features useful for forensics and security.
# includes ability to have mulitple output targets
# includes ability to have multiple output targets
# write file image to an SD card showing a progress bar based on filesize
sudo dcfldd if=./raspbian.img of=/dev/mmcblk0 sizeprobe=if

@ -1,11 +1,19 @@
# dict
# Dictionary client
# dictd - Client/server software, human language dictionary databases, and tools supporting the DICT protocol
# A list of all the available dictionaries can be queried by executing.
# List available dictionary databases
dict -D
# Get information about a dictionary database (e.g. moby-thesaurus)
dict -i moby-thesaurus
# Look up "use" in Moby-Thesaurus database
dict -d moby-thesaurus use
# Look up "perceive" in all available dictionary databases
dict perceive
# List all the available dictionaries server and their info
dict -I
# Translate 'understand' to Dutch.
dict -d fd-eng-nld understand
# Show available dict databases.
dict -D

@ -7,8 +7,8 @@
C-x b create/switch buffers
C-x C-b show buffer list
C-x k kill buffer
C-z suspend emacs
C-X C-c close down emacs
C-z suspend Emacs
C-X C-c close down Emacs
# Basic movement
C-f forward char
@ -65,11 +65,11 @@
C-h f what does this function do
C-h v what\'s this variable and what is it\'s value
C-h b show all keycommands for this buffer
C-h t start the emacs tutorial
C-h t start the Emacs tutorial
C-h i start the info reader
C-h C-k start up info reader and go to a certain key-combo point
C-h F show the emacs FAQ
C-h p show infos about the Elisp package on this machine
C-h F show the Emacs FAQ
C-h p show info about the Elisp package on this machine
# Search/Replace
C-s Search forward
@ -122,7 +122,7 @@
C-x 5 0 close this frame
# Bookmark commands
C-x r m set a bookmark at current cursor pos
C-x r m set a bookmark at current cursor position
C-x r b jump to bookmark
M-x bookmark-rename
M-x bookmark-delete
@ -147,10 +147,10 @@
# Shell
M-x shell starts shell modus
C-c C-c same as C-c under unix (stop running job)
C-c C-c same as C-c under Unix (stop running job)
C-d delete char forward
C-c C-d Send EOF
C-c C-z suspend job (C-z under unix)
C-c C-z suspend job (C-z under Unix)
M-p show previous commands
# Text
@ -163,7 +163,7 @@
M C-\ indent region between cursor and mark
M-m move to first (non-space) char in this line
M-^ attach this line to previous
M-; formatize and indent comment
M-; formats and indent comment
# C, C++ and Java Modes
M-a beginning of statement
M-e end of statement
@ -171,22 +171,22 @@
M C-e end of function
C-c RETURN Set cursor to beginning of function and mark at the end
C-c C-q indent the whole function according to indention style
C-c C-a toggle modus in which after electric signs (like {}:\';./*) emacs does the indention
C-c C-d toggle auto hungry mode in which emacs deletes groups of spaces with one del-press
C-c C-a toggle modus in which after electric signs (like {}:\';./*) Emacs does the indention
C-c C-d toggle auto hungry mode in which Emacs deletes groups of spaces with one del-press
C-c C-u go to beginning of this preprocessor statement
C-c C-c comment out marked area
# More general
M-x outline-minor-mode
collapses function definitions in a file to a mere {...}
M-x show-subtree
If you are in one of the collapsed functions, this un-collapses it
If you are in one of the collapsed functions, this expands it
# In order to achieve some of the feats coming up,
# now you have to run etags *.c *.h *.cpp
# (or what ever ending you source files have) in the source directory
M-. (Meta dot) If you are in a function call, this will take you to it\'s definition
M-x tags-search ENTER
Searches through all you etaged
M-, (Meta comma) jumps to the next occurence for tags-search
M-, (Meta comma) jumps to the next occurrence for tags-search
M-x tags-query-replace yum.
This lets you replace some text in all the tagged files

@ -45,7 +45,7 @@ exim -Mt <message-id> [ <message-id> ... ]
# whether the retry time has been reached or not
exim -M <message-id> [ <message-id> ... ]
# Force message to fail and bounce as "cancelled by administrator"
# Force message to fail and bounce as "canceled by administrator"
exim -Mg <message-id> [ <message-id> ... ]
# View message's headers

@ -23,6 +23,6 @@ ffmpeg -i ImageFile.jpg ImageFile.png
# to the ffmpeg(1) man page for more information on these levels of logging.
ffmpeg -v 0 -i IN_FILE OUT_FILE
# If you want to see ongoing but not over-the-top statitics for the file on
# If you want to see ongoing but not over-the-top statistics for the file on
# which ffmpeg(1) is currently working, you can make use of the `-stats` flag.
ffmpeg -stats -i IN_FILE OUT_FILE

@ -37,7 +37,7 @@ find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
# times faster, and allows for more specificity.
find -perm -4000 -type f -print0 | xargs -I '{}' -0 \ls -l '{}'
# Find and remove files with case-senstive extension of `.txt`.
# Find and remove files with case-sensitive extension of `.txt`.
find [PATH] -name '*.txt' -exec rm '{}' \;
# The above is much more efficiently written as shown below, as find(1) has its
# own built-in delete function, not to mention a single rm(1) process was

@ -4,6 +4,6 @@
# “.pgpkey” and “.forward” from the user's home directory.
finger -s username
# weather report in console (for nuremberg in this case)
# weather report in console (for Nuremberg in this case)
finger nuremberg@graph.no

@ -86,7 +86,7 @@ git checkout master # <-- Checkout local master branch.
git checkout -b new_branch # <-- Create and checkout a new branch.
git merge upstream/master # <-- Merge remote into local repo.
git show 83fb499 # <-- Show what a commit did.
git show 83fb499:path/fo/file.ext # <-- Show the file as it was in 83fb499.
git show 83fb499:path/to/file.ext # <-- Show the file as it was in 83fb499.
git diff branch_1 branch_2 # <-- Check difference between branches.
git log # <-- Show all of the commits.
git status # <-- Show the changes from the last commit.

@ -3,6 +3,6 @@
# It is a wrapper for nvidia-smi.
# To install: `pip install gpustat`
# show GPU statistsics with the processes PIDs and names
# show GPU statistics with the processes PIDs and names
gpustat -cp

@ -1,4 +1,4 @@
# side-by-side hexadecimal and ascii view of the first 128 bytes of a file
# side-by-side hexadecimal and ASCII view of the first 128 bytes of a file
hexdump -C -n128 /etc/passwd
# Convert a binary file to C Array

@ -57,7 +57,7 @@
#
# When creating new window, currently focused window
# will be split in half and one half will be used by new window.
# You can control whether it will split horiontally or
# You can control whether it will split horizontally or
# vertically with ◆+v or ◆+h.
# You can focus multiple windows at once.
# For example with this layout with two windows:
@ -96,7 +96,7 @@
# Default configuration path:
/etc/i3/config
# Keys can be binded with bindsym like this:
# Keys can be bound with bindsym like this:
bindsym $mod+4 workspace $ws4
bindsym $mod+Shift+R exec custom-script-in-path.sh --flag1 --flag2
bindcode 172 exec playerctl play-pause

@ -0,0 +1,21 @@
# iscsiadm
# open-iscsi administration utility
# Discover targets at iscsi portal ADDR:PORT
# Prints a list of available iscsi targets, example:
#
# <target-ip>:<port> <IQN>
# 10.10.10.42:3260,1 iqn.2007-10:iscsi.target0
iscsiadm -m discovery -t sendtargets -p ADDR:PORT
# login to target IQN at portal ADDR:PORT:
iscsiadm -m node -T IQN -p ADDR:PORT --login
# logout from specified target IQN:
iscsiadm -m node -T IQN --logout
# list active sessions:
iscsiadm -m session
# logout from all active sessions:
iscsiadm -m node --logout

@ -97,7 +97,7 @@ jq --slurp '. | sort | .[]'
# Group by a key - opposite to flatten
jq 'group_by(.foo)'
# Minimun value of an array
# Minimum value of an array
jq 'min'
# See also min, max, min_by(path_exp), max_by(path_exp)

@ -1,6 +1,6 @@
# jslint
#
# The JavaScript Code Quality Tool written by Dougls Crockford
# The JavaScript Code Quality Tool written by Douglas Crockford
# to install jslint
sudo npm install jslint -g

@ -1,6 +1,6 @@
# kafka-topics
#
# Comamnd-line tool to manage Kafka topics
# Command-line tool to manage Kafka topics
# list topics
kafka-topics --zookeeper localhost:2181 --list

@ -18,7 +18,7 @@ links2 -dump -width 80 duckduckgo.co.uk
links2 -http.fake-user-agent 'Mozilla/5.0' duckduckgo.co.uk
# Have links2(1) request not to be tracked (as if anyone respects this!?). The
# `1` is a boolean integer, indicating to enable the aforetyped option. This
# `1` is a boolean integer, indicating to enable the option. This
# option is by default disabled, according the August 2006 man page.
links2 -http.do-not-track 1 duckduckgo.co.uk

@ -1,8 +1,8 @@
# lse
# Linux enumeration tools for pentesting and CTFs.
# Linux enumeration tools for pen-testing and CTFs.
# This project was inspired by https://github.com/rebootuser/LinEnum and uses
# many of its tests. Unlike LinEnum, lse tries to gradualy expose the
# information depending on its importance from a privesc point of view.
# many of its tests. Unlike LinEnum, lse tries to gradually expose the
# information depending on its importance from a privacy point of view.
# GitHub repo: https://github.com/diego-treitos/linux-smart-enumeration.git
# Basic usage
@ -27,7 +27,7 @@
# fst: File system related tests.
# sys: System related tests.
# sec: Security measures related tests.
# ret: Recurren tasks (cron, timers) related tests.
# ret: Recurrent tasks (cron, timers) related tests.
# net: Network related tests.
# srv: Services related tests.
# pro: Processes related tests.

@ -2,17 +2,17 @@
# Extends a logical volume in an existing volume group.
# A volume group is a collection of logical and physical volumes.
# Extend volume in volume mylv in groug vg0
# Extend volume in volume mylv in group vg0
# (defined by volume path /dev/vg0/mylv)
# to 12 gigabyte:
lvextend -L 12G /dev/vg0/mylv
# Extend volume in volume mylv in groug vg0
# Extend volume in volume mylv in group vg0
# (defined by volume path /dev/vg0/mylv)
# by 1 gigabyte:
lvextend -L +1G /dev/vg0/mylv
# Extend volume in volume mylv in groug vg0
# Extend volume in volume mylv in group vg0
# (defined by volume path /dev/vg0/mylv)
# to use all of the unallocated space in the volume group vg0:
lvextend -l +100%FREE /dev/vg0/mylv

@ -21,7 +21,7 @@ mongo --shell my-script.js
# and execute my-script.js after that
mongo localhost:27017/myDatabase my-script.js
# Evaluate a javascript expression on the database:
# Evaluate a JavaScript expression on the database:
mongo --eval 'JSON.stringify(db.foo.findOne())' database
# See also:

@ -64,8 +64,8 @@ mutt -s "hello" -b user2@example.com user@example.com
#
# shift+d (D) : Delete messages using pattern
# shift+t (T) : Select messages using pattern
# shift+u (U) : Un-delete messages using pattern
# ctrl+t : de-selected messages using pattern
# shift+u (U) : Undelete messages using pattern
# ctrl+t : deselect messages using pattern
# d : Delete message
# N : Mark as new
# C : Copy message to another folder(mailbox)

@ -24,7 +24,7 @@ nm -S 1 | grep abc
nm -D executable
# Change the format of the nm output
# (display the output of nm command in posix style)
# (display the output of nm command in POSIX style)
nm -u -f posix executable
# Display only the external symbols of executable

@ -73,8 +73,8 @@ nmap --script "(default or safe or intrusive) and not http-*"
# -pT:443 => Scan only port 443 with TCP (T:)
nmap -T5 --min-parallelism=50 -n --script "ssl-heartbleed" -pT:443 127.0.0.1
# Show all informations (debug mode)
# Show all information (debug mode)
nmap -d ...
# Discovert DHCP information on an interface
# Discover DHCP information on an interface
nmap --script broadcast-dhcp-discover -e eth0

@ -0,0 +1,10 @@
# pactl
# Control a running PulseAudio sound server
# Display a sorted and uniq-ified list of PulseAudio modules, using AWK.
pactl list modules short | awk '{!Lines[$2]++} END {asorti(Lines, Sorted); for (Line in Sorted) print(Sorted[Line])}'
# Load a module.
pactl load-module MODULE
# Unload a module.
pactl unload-module MODULE

@ -1,4 +1,4 @@
# create a new MBR/msdos partition table for BIOS systems
# create a new MBR/MSDOS partition table for BIOS systems
(parted) mklabel msdos
# create a new GPT partition table for UEFI systems instead, use:

@ -1,5 +1,5 @@
# pg_top
# Display and update information about the top cpu PostgreSQL processes
# Display and update information about the top CPU PostgreSQL processes
# connect to port 5432 using user postgres, and database, ask for password
pg_top -p 5432 -U postgres -d database -W
@ -10,10 +10,10 @@ pg_top -p 5432 -U postgres -d database -W
# Display the actual query plan (EXPLAIN ANALYZE)
# E
# Display re-determined execution plan (EXPLAIN) of the SQL statement
# by a backend process
# by a back end process
# L
# Display the currently held locks by a backend process
# Display the currently held locks by a back end process
# Q
# Display the currently running query of a backend process
# Display the currently running query of a back end process
# X
# Display user index statistics.

@ -6,7 +6,7 @@
# Examine process limits and permissions:
prctl ${PID}
# Examine process limits and permissions in machine parseable format:
# Examine process limits and permissions in machine parse-able format:
prctl -P ${PID}
# Get specific limit for a running process:

@ -1,6 +1,6 @@
# /proc is a pseudo-filesystem containing running process information and more.
# See the commandline arguments that started the process
# See the command line arguments that started the process
cat /proc/<pid>/cmdline
# See the process's environment variables

@ -23,7 +23,7 @@ read -n 1 -e -p 'Prompt: '
# In this example, the [I]nput [F]ield [S]eperator is set to `=` for only the
# `read` built-in, and the `-a` flag is used to split the input, per the
# provided IFS, into an array. This then means the first index is the key and
# the second index the value, which is ideal when parsing configurtion files.
# the second index the value, which is ideal when parsing configuration files.
while IFS='=' read -a Line; do
COMMANDS
done < INPUT_FILE

@ -1,6 +1,6 @@
# resize2fs
# ext2/ext3/ext4 file system resizer
# ext2/ext3/ext4 file system resize tool
# resize filesystem up to the block device size
# make e2fsck /dev/xvdb1 before

@ -1,19 +1,19 @@
# rustup
# The Rust toolchain installer
# The Rust tool chain installer
# update rustup toolchain
# update rustup tool chain
rustup update
# install nightly build
rustup install nightly
# use rustc from nightly toolchain
# use rustc from nightly tool chain
rustup run nightly rustc --version
# switch to nightly installation
rustup default nightly
# List all available targets for the active toolchain
# List all available targets for the active tool chain
rustup target list
# Install the Android target
@ -22,5 +22,5 @@ rustup target add arm-linux-androideabi
# Run a shell configured for the nightly compiler
rustup run nightly bash
# Show which toolchain will be used in the current directory
# Show which tool chain will be used in the current directory
rustup show

@ -1,7 +1,7 @@
# scp
# Secure copy (remote file copy program)
# Secury copies files from remote ADDR's APTH to the current-working-directory.
# Securely copies files from remote ADDR's PATH to the current-working-directory.
# By default here, port 22 is used, or whichever port is otherwise configured.
scp ADDR:PATH ./

@ -1,6 +1,6 @@
# short (Bash-Snippets)
# Unmasks shortended urls.
# Unmasks shortened URLs.
# Unmask the true url behind a shortened link
# Unmask the true URL behind a shortened link
short tinyurl.com/jhkj
# Output: http://possiblemaliciouswebsiteornot.com

@ -1,5 +1,5 @@
# slsc
# SpreadSheet for console, written using libslang (legacy)
# Spreadsheet for console, written using libslang (legacy)
# to install
# * install libslang-dev first

@ -4,11 +4,14 @@
# Return the contents of the British English dictionary, in reverse order.
sort -r /usr/share/dict/british-english
# Since sort(1) can filter out duplicate adjacent lines or fields, this example
# therefore makes uniq(1) redundant. You should only ever use uniq(1) if you
# need its functionality, or need uniqueness without sorting.
# The GNU sort(1) command can also filter out adjacent duplicate lines and can
# therefore overlap with the uniq(1) command. However, uniq(1) has some options
# that sort(1) cannot do so refer to the man page for you situation if you
# require something beyond a basic uniqueness check. In addition, there is the
# potential for parallizing the processing by piping sort(1) into uniq(1) for
# non trivial tasks.
#
# By default, sort(1) sorts lines or fields using the ASCI table. Here, we're
# By default, sort(1) sorts lines or fields using the ASCII table. Here, we're
# essentially getting alphanumeric sorting, where case is handled separately; -
# this results in these words being adjacent to one another, thus duplicates
# are removed.
@ -17,7 +20,7 @@ sort -r /usr/share/dict/british-english
printf '%s\n' this is a list of of random words with duplicate words | sort -u
# Sort numerically. If you don't provide the `-n` flag, sort(1) will instead
# sort by the ASCI table, as mentioned above, meaning it'll display as 1, 10, -
# sort by the ASCII table, as mentioned above, meaning it'll display as 1, 10, -
# 11, 2, 3, 4, etc.
printf '%d\n' {1..9} 10 11 | sort -n

@ -0,0 +1,21 @@
# sqlcmd
# utility for MS SQL Server
# connect to a database server with user
sqlcmd -S localhost,1433 -U username
# connect to a database server on specific db instance
sqlcmd -S localhost,1433 -U username -P password -d target_db
# change a password
sqlcmd -U username -P oldpassword -Z newpassword
# run a sql script against a database with variable (stdout)
sqlcmd -S localhost,1433 -U username -v SOME_VARIABLE="foo" -i "/path/to/script.sql"
# run a cmd line query and exit
sqlcmd -S localhost,1433 -U username -Q "INSERT QUERY HERE"
# check if a database exists using cmd line query (return 1 if True)
sqlcmd -S localhost,1433 -U username -h -1 -W -Q "SET NOCOUNT ON;SELECT 1 FROM sys.databases WHERE [Name] = N'YOURDBNAME'"

@ -27,13 +27,13 @@ ssh -X -t user@example.com 'chromium-browser'
# Create a SOCKS proxy on localhost and port 9999.
ssh -D 9999 user@example.com
# Connect to server, but allow for X11 forwarding, while also using GZip
# Connect to server, but allow for X11 forwarding, while also using Gzip
# compression (can be much faster; YMMV), and using the `blowfish` encryption.
# For more information, see: http://unix.stackexchange.com/q/12755/44856
ssh -XCc blowfish user@example.com
# Copy files and directories, via SSH, from remote host to the current working
# directory, with GZip compression. An option for when `rsync` isn't available.
# directory, with Gzip compression. An option for when `rsync` isn't available.
#
# This works by creating (not temporary!) a remote Tar archive, then piping its
# output to a local Tar process, which then extracts it to STDOUT.
@ -46,7 +46,7 @@ ssh -i some_id_rsa -o IdentitiesOnly=yes them@there:/path/
# Temporarily disable `pubkey` authentication for this instance.
ssh -o PubkeyAuthentication=no username@hostname.com
# Mount a remote directory or filesystem, through SSH, to a local mountpoint.
# Mount a remote directory or filesystem, through SSH, to a local mount point.
# Install SSHFS from: https://github.com/libfuse/sshfs
sshfs name@server:/path/to/folder /path/to/mount/point

@ -1,7 +1,7 @@
# swipl
# SWI-Prolog is a versatile implementation of the Prolog language.
# run plolog interpreter in interactive mode
# run Prolog interpreter in interactive mode
swipl
# consult file.pl, run goal mygoal(3,foo)

@ -1,4 +1,4 @@
# SysVinit to Systemd Cheatsheet
# SysVinit to Systemd Cheat sheet
# Ways in which to control an available service.
#
@ -30,7 +30,7 @@ chkconfig SERVICE
# SystemD:
systemctl is-enabled SERVICE
# Print a table of services, listing for which runlevel each is configured.
# Print a table of services, listing for which run level each is configured.
#
# SysVinit:
chkconfig --list
@ -59,9 +59,9 @@ chkconfig SERVICE --add
# SystemD:
systemctl daemon-reload
# Runlevel/Target -- Half the system.
# Run level/Target -- Half the system.
#
# SysVinit Runlevel: 0
# SysVinit Run level: 0
# SystemD Target: runlevel0.target
# poweroff.target
#
@ -71,7 +71,7 @@ systemctl daemon-reload
# SystemD Target: runlevel1.target
# rescue.target
#
# User-defined/Site-specific runlevels. By default, identical to 3.
# User-defined/Site-specific run levels. By default, identical to 3.
#
# SysVinit Runlevel: 2, 4
# SystemD Target: runlevel2.target

@ -1,7 +1,7 @@
# tar
# GNU version of the tar archiving utility
# An approach to backing up the current user's HOME, using tar(1) and GZip
# An approach to backing up the current user's HOME, using tar(1) and Gzip
# compression. Permissions (modes) will be preserved. The filename format will
# be: UID:GID_DATE.tgz
#

@ -70,7 +70,7 @@ tmux attach-session -t name
#
# setw -g mode-keys vi # to switch into vi mode
#
# Function vi emacs
# Function Vi Emacs
# -----------------------------------------------
# Back to indentation ^ M-m
# Start selection Space C-space

@ -1,5 +1,5 @@
# Todo (Bash-Snippets)
# A simplistic commandline todo list
# A simplistic command line to-do list
# Add a task to your todo list
todo -a This is an example task

@ -1,5 +1,5 @@
# tsp
# task-spooler - A simple unix batch system to run commands in a queue
# task-spooler - A simple Unix batch system to run commands in a queue
# Run a job in the background
tsp pg_dump mydb

@ -5,8 +5,8 @@
# mode creation mask") for only the current user, and only his or her current
# session. The (one) leading zero is optional, unless you otherwise need it.
#
# This umask setting is actually recommended for security by RHEL, and is also
# mentioned and I believe recommended in the Arch Linux Wiki.
# This umask setting is actually recommended for security by major Linux distributions
# like RHEL, Debian and Arch Linux.
#
# The result of '0077' being -- and I'll use standard octal with which we're
# all probably familiar -- that all new files are created using the '600'

@ -1,7 +1,7 @@
# xfs_repair
# repair an XFS filesystem
# rapair a XFS filesystem
# repair a XFS filesystem
xfs_repair /dev/dm-0
# last resort option:

@ -25,7 +25,7 @@ xinput --set-prop 8 157 1.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.
xinput disable [touchscreen XID]
# Disable middle mouse button click
# Numbers are what you do with the first, second, and third (ie, left, middle, right) mouse buttons.
# Numbers are what you do with the first, second, and third (i.e., left, middle, right) mouse buttons.
# 1 0 3 means that the left button should do a left click (action 1),
# the middle button should do nothing,
# and the right button should do a right click (action 3).

@ -12,6 +12,6 @@ export GTK_IM_MODULE=$input_module
export XMODIFIERS=@im=$input_module
export QT_IM_MODULE=$input_module
EOF
# And you probly need to start:
# And you probably need to start:
# ibus-daemon --xim --verbose --daemonize --replace

@ -57,7 +57,7 @@ xm resume
# Similar to suspend except with user definable state file
xm save
# Similar to resume except restoreable with exports that used the save verb
# Similar to resume except can be restored with exports that used the save verb
xm restore
# Dumps core per domain

@ -7,7 +7,7 @@ xset s off
# Change time before which the screen is blanked, to 3,600 seconds (1 hour).
xset s 3600 3600
# Turn off Display Power Management Signaling. To instead enable DPMS, the `-`
# Turn off Display Power Management Signalling. To instead enable DPMS, the `-`
# character is simply changed to `+`.
xset -dpms

@ -21,7 +21,7 @@ yay -Y --gendb
# and use PKGBUILD modification time and not version to determine update
yay -Syu --devel --timeupdate
# instalation
# installation
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

@ -24,7 +24,7 @@ yq r sample.yml spec.metadata[name==myapp]
# Collect results into an array
yq r sample.yaml --collect a.*.animal
# Read from the 2nd docuemnt
# Read from the 2nd document
yq r -d1 sample.yaml b.c
# Validate a document

@ -15,7 +15,7 @@ yq eval \
yq eval '.a |= .b' sample.yml
# Update multiple nodes. a and c are siblings.
yq eval '(.a, .c) |= "potatoe"' sample.yml
yq eval '(.a, .c) |= "potato"' sample.yml
# Update selected results.
# Only update a's children with value=='apple' to 'frog'.

@ -1,10 +1,10 @@
# ytview (Bash-Snippets)
# search and play youtube videos right from the terminal
# search and play YouTube videos right from the terminal
# Search for youtube videos by title
# Search for YouTube videos by title
ytview This is my search query
# Search for youtbe videos by specifying a channel
# Search for YouTube videos by specifying a channel
ytview -c numberphile
# After using one of the two above commands you will be able

Loading…
Cancel
Save