Skip to content

Instantly share code, notes, and snippets.

View xaratustrah's full-sized avatar
🎲
What were the chances?

xaratustrah

🎲
What were the chances?
View GitHub Profile
@xaratustrah
xaratustrah / bash_profile.md
Last active August 27, 2018 12:00
bash_profile.md

BASH login vs non-login shell

login-shell

like in remote SSH reads ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order.

non login shell

like in Terminal in GUI reads /etc/bash.bashrc and ~/.bashrc

.profile

contains general things like the environment variables

@xaratustrah
xaratustrah / ssh_friends.md
Last active November 20, 2023 12:30
ssh_friends.md

ssh and friends

I use SSH as a powerful tool that it deserves its own gist.

SSH proxy SOCKS

Create a dynamic port:

ssh -fNCq -D 8123 -p 22 [email protected]
@xaratustrah
xaratustrah / frequently_used_git_commands.md
Last active August 27, 2018 12:00
frequently_used_git_commands.md

Frequently used git commands

hard reset:

git fetch --all
git reset --hard origin/master

undo local changes of a file match origin master:

@xaratustrah
xaratustrah / jupyter_service_osx.md
Last active August 27, 2018 12:01
jupyter_service_osx.md

Running Jupyter at boot in OSX using launchctl

Create a plist file in your user directory. In the following change USERNAME to your own.

/Users/USERNAME/Library/LaunchAgents/local.jupyter.notebook.plist

With this content:

@xaratustrah
xaratustrah / sdr.md
Last active August 27, 2018 12:01
sdr.md
@xaratustrah
xaratustrah / flask_nginx_gunicorn.md
Last active February 24, 2023 15:39
flask_nginx_gunicorn.md

Python Flask + nginx + gunicorn

Setting up a python flask web application using nginx, gunicorn and systemd on a Rasperry Pi

In the following, we assume a working Flask application with the name of SCRIPT_NAME. First we need to install a couple of things:

sudo apt-get update && sudo apt-get upgrade

Installing nginx will fail if apache is running. If your installation breaks half ways, then remove the fragments, stop apache (and I actually suggest removing it in case not needed) and then install nginx again:

sudo apt-get remove nginx* --purge

sudo /etc/init.d/apache2 stop

@xaratustrah
xaratustrah / python_snippets.md
Last active September 29, 2022 09:44
python_snippets.md

Python snippets

numpy genfromtxt using names

You can plot all columns of a CSV file at once using the structured array. Assuming that your file looks like this

# col1 | col2
0.34 | 0.134
1.4 | 1.5

you then use:

@xaratustrah
xaratustrah / android_rooting.md
Last active August 27, 2018 12:02
android_rooting.md

Android rooting how to

Heimdal

heimdall flash --RECOVERY ./clockworkmod_6.0.3.2_jfltespr.img --no-reboot

note that the word RECOVERY should be written in all upper case

Installing APKs

You can install APKs in a loop:

@xaratustrah
xaratustrah / linux_password_recovery.md
Last active August 27, 2018 12:02
linux_password_recovery.md

linux password recovery

under debian

  • interrupt the boot process by any key
  • in the boot menu press 'e' for edit
  • add init=/bin/bash after ro quiet in the line that begins with linux
  • press ctrl-x
  • type mount -rw -o remount / dont't forget the trailing slash
  • use passwd to change to a new password
@xaratustrah
xaratustrah / get_number_notation.py
Last active August 27, 2018 12:03
get_number_notation.py
# show number notation
def get_number_notation(value, decimal_place=2, unit=''):
ref = {24: 'Y', 21: 'Z', 18: 'E', 15: 'P',
12: 'T', 9: 'G', 6: 'M', 3: 'k', 0: '',
-3: 'm', -6: 'u', -9: 'n', -12: 'p',
-15: 'f', -18: 'a', -21: 'z', -24: 'y',
}
num = max([key for key in ref.keys() if value > 10 ** key])
mult = ref[num] if unit else 'e{}'.format(num)
return '{}{}{}'.format(int(value / 10 ** num * 10 ** decimal_place) / 10 ** decimal_place, mult, unit)