Skip to content

Instantly share code, notes, and snippets.

View henri's full-sized avatar
💭
hacking the mainframe

henri henri

💭
hacking the mainframe
View GitHub Profile
@henri
henri / vimrc cheatsheet
Last active June 17, 2022 00:25
.vimrc cheatsheet
# Set delete / backspace key to work like most text editors
set backspace=indent,eol,start
# Links to More + Quick Start Guide :
https://vim.rtorr.com
@henri
henri / screen_cheat_sheet.txt
Last active September 30, 2024 20:17
screen cheat sheet
# screen is useful command as it is included by default on some distributons / operating systemss (eg MacOS).
# even if you really like tmux, screen is useful in some situations. Both screen and tmux have a good use cases.
# list all screen sessions
screen -list
# start a command in screen
screen -S my_commands_awesome_name -md bash -lc /usr/bin/path_to_my_awesome_command
# start a command via ssh in screen
Summary How to control (or Understand) your GIST page's files list order.
Notice not official documentation.
@henri
henri / lsof_macOS_cheatsheet.txt
Last active July 4, 2022 22:50
netstat (more similar to GNU/LINUX) on macOS
# netstat (more similar to GNU/LINUX) on macOS
lsof -i -P | grep -i "listen" --line-buffered
@henri
henri / findmyfiles_bytime.bash
Created August 7, 2022 10:06
Find Files By Time Of Creation
#!/usr/bin/env bash
# find files within folder with creation time falling between 6PM and 9AM (change as required).
for f in /myfolder/* ; do
var=$(date -r "$f" '+%H')
if [ $var -gt 18 ] || [ $var -lt 9 ] ; then
ls -l "$f"
fi
done
@henri
henri / benchmark_function_v1.bash
Last active April 6, 2023 00:38
BASH benchmarking and latency monitoring
#!/bin/bash
# (C)2020 Henri Shustak
# Relased Under MIT LICENCE
# https://mit-license.org/
# benchmark bash function
# requires gdate to be installed (part of coreutils)
# This system is very basic and has some serious limitiations.
@henri
henri / grep_cheatsheet.txt
Last active September 30, 2024 03:42
grep_cheatsheet
# select lines which start with upper case or lower case letter at the start of the line
grep -E "^[a-z]|[A-Z]"
# enable line buffering (useful for dealing with pipes and real time loops)
grep --line-buffered "search term"
# enable highlighting for a match but do not filter output (all of these examples will have a similar effect)
ack --passthru 'hightlight-match-string'
grep "^\|highlight-match-string" --color="always"
grep "^\|highlight-match-string" --color
@henri
henri / macOS disable auto save.
Last active November 8, 2022 19:59
Important Tips for Old-School MacOS Users
Some programs will automatically save changes when closing files - Plan is to make a repository with a bunch of defaults which I use. For now it is a GitHub Gist.
Programs which seem to do this are listed below :
- Texttastic : https://www.textasticapp.com
More default settings now availble in a repository :
https://github.com/henri/handy-settings-macOS/
---- CLI Details ----
@henri
henri / switch_to_network_location.bash
Last active December 12, 2022 21:26
macOS switch to specific network location
#!/bin/bash
# simple script for macOS systems. It will switch to the location specified below if it is exists.
switch_to_location="Automatic"
current_location=`scselect | grep "*" | grep -v "Defined sets include: " | awk -F "(" '{print $2}' | awk -F ")" '{print $1}'`
if [ "{$current_location}" != "{$switch_to_location}" ] ; then
scselect "${switch_to_location}"
exit $?
fi
@henri
henri / macOS flush dns cache
Created October 20, 2022 22:38
Flush DNS cache on macOS system
# macOS 10.15 and later
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder