Skip to content

Instantly share code, notes, and snippets.

View actuallymentor's full-sized avatar

Mentor Palokaj actuallymentor

View GitHub Profile
@actuallymentor
actuallymentor / namecheap_update_dyndns.sh
Last active December 14, 2023 08:30
Namecheap dyndns update script
#/bin/bash
# Declare the variables needed
host= # @ or subdomain
domain= # TLD
ddns_password= # Password as found in advanced dns settings
# get the current ip address, try with another service if this one is down
array_of_ip_services=( "https://icanhazip.com" "http://ipinfo.io/ip" "http://ifconfig.me/ip" "http://ipecho.net/plain" "http://checkip.amazonaws.com" "http://myexternalip.com/raw" "http://ipecho.net/plain" )
@actuallymentor
actuallymentor / search_commadn_history.sh
Created August 24, 2023 13:24
A history searching function for linux and mac
# History search helper
# usage: his query1 query2 queryn...
# example: his ssh 192 (search all ssh commands done to ips inclusing 192)
# example: his sed jsx react (search all sed commands that include "jsx" and "react")
function his() {
# Store the full history in a variable
# Command order: history, remove line numbers, remove leading and trailing whitespace, sort, remove duplicates
# Note that we are using a naive way of removing the line numbers
commandlog=$(history | grep -oE "[a-zA-Z]{1}.*" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | sort | uniq)
@actuallymentor
actuallymentor / update-sendy-command-lne.sh
Last active February 23, 2021 14:05
Update sendy on the command line
# CHANGE THESE
yourlicensekey=abc123
yourremotepath=root@mexample.com:/var/www/domainfolder
# Download sendy zip
curl --output sendy.zip https://sendy.co/download/?license=$yourlicensekey && \
# Remove old sendy folder if it exists
rm -rf sendy && \
# unzip update payload
unzip sendy.zip && \
@actuallymentor
actuallymentor / commands.sh
Last active November 18, 2021 12:42
Android Shell Commands (for use with Tasker or adb)
##
# These commands can all be run as Tasker shell commands, or through adb
# NOTE ON ROOT: I noticed many commands work through the adb shell, but fail in tasker unless using ROOT. If you tasks fail, try enabling root for it
##
## SETTING THINGS
# Enable deep doze
dumpsys deviceidle force-idle
@actuallymentor
actuallymentor / check-website-up-down-status.sh
Last active May 22, 2019 10:31
curl based website up function
#!/usr/bin/zsh
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[1;33m"
NC="\033[0m" # No Color
# Called as islive url title
function isLive() {
if curl -Is $1 2>&1 | grep -q 'HTTP.* 200'; then
@actuallymentor
actuallymentor / reverse-compound-interest.js
Created November 28, 2016 13:57
Calculating the amount of money you need to set aside to reach a certain amount of wealth. Basically reversing compound interest by brute force.
// This script is terribly inefficient, but on a decent computer it takes 1 second to complete anyway. I made it on an airplane while half asleep.
const target = 600000 // The target net worth
const roi = 4 // The assumed return on investment yearly
const term = 20 // Time until retirement
const start = 0 // Starting capital
const desire = 600000 // Desired capital
// Configuration
const verbose = false
@actuallymentor
actuallymentor / angellist-uncheck-contacts-not-on-angellist.js
Last active October 3, 2016 13:36
Prevent Angellist from inviting Linkedin/Gmail/Facebook contacts not on Angellist
/*
NOTE: Made on Sept 20 2016, it might be that the site was edited since them
The below jQuery snippet will deselect any contacts you import from Linkedin
Usage: when prompted with the list of users to invite, run this in the console, it will deselect users not in Angellist
Much love from Amsterdam
@actuallymentor
@actuallymentor
actuallymentor / compound-interest.js
Last active October 1, 2018 13:03
A simple script to calculate compound interest
// Input it initial amount
// Interest as a number, e.g. 5% is 1.05 on a yearly basis
// Length as number of years
// Name of this calculation
// Addition determines whether the input variable is one time or a yearly contribution
function compound( input, interest, length, name, addition ) {
var accumulated = input
for ( i=0; i < length; i++ ) {
accumulated *= interest
if ( addition ){
@actuallymentor
actuallymentor / git_add_commit_push.sh
Created December 15, 2015 06:01
Creating a bash function that takes parameters, and using it .bashrc_profile style
#This function when added to ~/.bashrc_profile will allow you to use
#the command 'push "Commit message"' to lazily push your repo to your git server
push() {
#Add commit and push
git add *
git commit -a -m "$1"
git push
}
@actuallymentor
actuallymentor / optimize.sh
Created October 18, 2015 12:07
Optimize images in a WordPress installation using Bash
# You need a recent version of jpegoptim and pngquant for this
yes | apt-get install jpegoptim
yes | apt-get install pngquant;
# Navigate to your wp-content/uploads
#optimize JPEG
optimizelossy() { jpegoptim -v *.jpg --max=80; for i in *; do if test -d $i; then cd $i; echo $i; optimizelossy; cd .. ; fi; done; echo; }
optimizelossy