Skip to content

Instantly share code, notes, and snippets.

View millsoft's full-sized avatar
🔵
while 1

Michael millsoft

🔵
while 1
  • Millsoft
  • Germany
View GitHub Profile
@millsoft
millsoft / template.sh
Created October 27, 2022 18:49
A template for best pracices bash file
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
@millsoft
millsoft / idea.properties
Last active September 4, 2022 19:51
Optimized phpstorm options for best performance
# custom IntelliJ IDEA properties
editor.zero.latency.typing=true
idea.max.intellisense.filesize=3500
idea.cycle.buffer.size=2048
@millsoft
millsoft / git.md
Created November 27, 2020 09:37
Tricks and Howtos for git

GIT tricks

Problem: You deleted a local branch and also on remote but you still see it when you do git branch -r. Use following to synchronize your branches:

git fetch -p

The -p flag means "prune". After fetching, branches which no longer exist on the remote will be deleted.

@millsoft
millsoft / encode.py
Last active November 16, 2020 09:04 — forked from gasman/encode.py
Encoding a file as a Youtube video - https://www.youtube.com/watch?v=hyqLv2_zBdA
# Encode inputfile.tar.gz as a series of video frames
# Frames are written to frames/frameNNNN.png
from PIL import Image
with open('inputfile.tar.gz', 'rb') as f:
data = f.read()
WIDTH = 120
HEIGHT = 90
CHUNK_SIZE = int((WIDTH * HEIGHT) / 8)
@millsoft
millsoft / lazy_update.sh
Created March 11, 2020 12:25
A script for automatic update of lazygit and lazydocker
#!/bin/bash
# a script for updating lazygit and lazydocker
# it downloads the newest release and replaces the installed version
download() {
curl -s https://api.github.com/repos/jesseduffield/${APP}/releases/latest | grep "browser_download_url.*Linux.*x86_64.*gz\"" | cut -d : -f 2,3 | tr -d \" | wget -qi -
}
@millsoft
millsoft / check_outgoing_open_ports.sh
Created February 16, 2020 15:23
Check multiple outgoing ports if they are open or blocked by firewall
#!/bin/bash
# This script checks which ports are open or blocked by the firewall or provider / government.
# Call this script with a port range, eg: ./check_outgoing_open_ports.sh 80-300
# How does it work?
# It simply tries to connect to portquiz.net - this site has all ports open.
# Number of connections
NUM_CONNECTION=10
@millsoft
millsoft / gist:c8694508363ddfd593b349bd465dcbd4
Created October 28, 2019 11:01
Execute a sh script inside screen in detached mode
# this command will execute a long running script inside a screen session
screen -d -m -t jenkins_tunnel sh /root/scripts/global/network/jenkins_tunnel.sh
@millsoft
millsoft / ssh_tunnel.sh
Created September 28, 2019 14:46
SSH Tunnel with auto reconnect
#!/bin/sh
# endless ssh tunnel. Makes sure to reconnect if the connection breaks (eg "broken pipe")
# why? if you want to expose your localhost to the public without dealing with firewalls / routers - works similar to ngrok and is free
#
# what do I need?
# you will need an external server with ssh access.
#
# how?
# you will need to create a ssh key for your external server so you don't need a password. (important for reconnecting)
@millsoft
millsoft / get_ap_channel_by_bssid.sh
Created August 25, 2019 16:15
Get Access Point Channel by BSSID
#!/bin/bash
#you need first the name of your wifi device, enter iwlist to see.
# in the bottom example wlx12345 = wifi device name and the mac address is the bssid of the access point
iwlist wlx12345 scanning | awk '/AA:BB:CC:DD:11:22/,/Frequency/' | awk '/Channel:/ { print substr($1, 9) }
@millsoft
millsoft / console_log.php
Created August 16, 2019 12:27
console.log for php print php Variables in Browser console
<?php
function console_log ($data)
{
$bt = debug_backtrace();
$caller = array_shift($bt);
$caller_string = "{$caller['file']}:{$caller['line']}";
$d = json_encode($data);