Skip to content

Instantly share code, notes, and snippets.

View zlocate's full-sized avatar

Denis zlocate

View GitHub Profile
@zlocate
zlocate / gogh.sh
Created August 9, 2020 20:15
Extract and open in browser repository url (e.g for Github it's repo webpage)
#!/bin/bash
cd "$(pwd)";
SITE_URL=$(git config --get remote.origin.url)
if [ "$URL" ]; then
echo Repository URL: "$URL"
xdg-open "$URL"
else
echo "Git repository not found (or origin is empty)"
fi
#!/bin/bash
# Shell-script that kills top of cpu-usage process (with minimal load limit)
# Dependencies: ps awk bc (available by-default at mostly linux distro)
# Minimal process CPU load after that process will be killed
MIN_CPU_LOAD="50"
echo "Min cpu load to kill $MIN_CPU_LOAD %"
pid=$(ps -eo %cpu,pid,comm --sort -%cpu --no-headers | head -n 1)
# Minimal process CPU load after that process will be killed
MIN_CPU_LOAD="50"
echo "Min cpu load to kill $MIN_CPU_LOAD %"
pid=$(ps -eo %cpu,pid,comm --sort -%cpu --no-headers | head -n 1)
# For debugging purposes
# echo $pid
if [[ -n $pid ]]; then
# Maybe use single command to fill array or object-like storage
@zlocate
zlocate / NpmSpeedupOptions.md
Last active August 15, 2020 15:25
How to make npm much faster.

If you want to speed up dependencies installing of your node project try to use this npm options: Sometimes this dramatically increase installing times

Use this flags (or npm options):

--prefer-offline - prefer use a local version of packages instead check ones at registry.

--no-audit - disable security checking of used dependencies (may be insecure)

#!/bin/bash
# Enable usb tethering by adb shell (works on Android 10, Honor 10 Lite)
# Additional links: https://android.stackexchange.com/questions/29954/is-it-possible-to-activate-the-usb-tethering-android-setting-from-the-command
# https://stackoverflow.com/questions/20226924/is-it-possible-to-usb-tether-an-android-device-using-adb-through-the-terminal/24346101
adb shell svc usb setFunctions rndis
#!/bin/bash
# Drops all MongoDB databases
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase();})'
@zlocate
zlocate / deleteunused.js
Created July 13, 2021 16:38
Delete all unsed node deps
#!/bin/bash
file='unused-deps.txt'
echo "list all unused deps"
npx depcheck > $file
n=1
while read line; do
dep=$( echo "$line" | cut -c 3- )
echo "uninstall : $dep"
npm uninstall "$dep"
n=$((n+1))
@zlocate
zlocate / google-no-redirect.js
Created December 28, 2021 20:53
Prohibit click-tracking, and prevent url redirection when clicks on the result links in Google search page
// Run this at browser console at google.com tab and reload page
Object.defineProperty(window, 'rwt', {
value:()=>true,
writable: false, // set the property to read-only
configurable: false
});
@zlocate
zlocate / create-fx-portable.sh
Last active September 14, 2023 04:08
Download and configure firefox as portable app
#!/bin/bash
#
# VERSION : 0.2
# AUTHOR : Davide Airaghi
#
# Script to create a portable version of Mozilla Firefox ESR
# to be used on a generic GNU/Linux System.
#
# if you run "bash build-firefox-portable.sh" you get a portable version for the latest version of Firefox "standard"
@zlocate
zlocate / download-snap.sh
Created May 8, 2022 20:32
Download .snap package file
#!/bin/bash
ARCH=amd64
RELEASE=stable
#export PATH="$PATH:/snap/bin/"
eval assert_fetcher_path="~/assert-fetcher/bin/assert-fetcher"
PACKAGE=$1
echo "Checking for jq..."
which jq