Skip to content

Instantly share code, notes, and snippets.

View antoniopresto's full-sized avatar

Antonio Silva antoniopresto

View GitHub Profile
@antoniopresto
antoniopresto / myip.sh
Created March 1, 2018 11:12
local machine ip
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
@antoniopresto
antoniopresto / kp
Last active May 25, 2021 12:14
Kill process
# kp 3000 node # kill if node is running on port 3000
# kp 3000 # kill process running on port 3000
PORT=$1;
MATCH=$2;
if [ -n "$MATCH" ]; then
kill -9 `lsof -i :$PORT | awk -v MATCH=$2 '$0 ~ MATCH{ print $2; }'`
exit;
fi;
@antoniopresto
antoniopresto / bestMatch.js
Created December 19, 2017 21:48
bestMatch.js
// find in objects https://www.npmjs.com/package/q_
function _(o, qs) {
const qa = qs.replace(/\[([0-9]*)]/gim, '.$1').split('.');
return qa.reduce(function(prev, next) {
if (!prev) return undefined;
return prev[next];
}, o);
}
function bestMatch(o, qs) {
# /bin/fixtime
/usr/sbin/ntpdate -u time.apple.com
#
chmod u+x /bin/fixtime
# cron
$ EDITOR=nano crontab -e
> 2 * * * * sudo -S fixtime >> ~/Desktop/cron.log 2>&1
$ sudo visudo
antonio ALL = (ALL) NOPASSWD: /bin/fixtime
# set the Forward Delete key to delete a file in Finder
defaults write com.apple.finder NSUserKeyEquivalents '{"Move to Trash"="\U007F";}'