Skip to content

Instantly share code, notes, and snippets.

View Eidansoft's full-sized avatar

Alejandro Eidansoft

  • Madrid
View GitHub Profile
# Install Raspbian SO, you can get it at https://www.raspberrypi.org/documentation/installation/installing-images/
# Connect to a screen and login onto the raspberry, user "pi", password "raspberry"
# Activate the SSH server running the command:
sudo raspi-config
# Select and then 7-Advance Options -> Expand Filesystem
# Select and 5-Interfacing Options -> Activate the SSH server.
# Also want to 4-Localisation Options -> configure the WiFi country; at select and select your contry.
# After those changes you need to reboot the machine.
@Eidansoft
Eidansoft / 00_multi_jump_ssh.sh
Last active November 28, 2019 14:42
SSH tips to play around the machines
# Doc from https://wiki.gentoo.org/wiki/SSH_jump_host
ssh -J jump_named_configured_at_conf,user@host_jump user@end_machine
@Eidansoft
Eidansoft / Dockerfile
Last active September 30, 2019 09:59
Docker tips
# On a docker container force to not reach Internet/connectivity
# The docker must be started as a privileged with the param --privileged and
# on the running container, you must have iptables installed (apt-get install iptables),
# then you can run:
# To avoid all connectivity at all
iptables -A OUTPUT -j DROP
# Avoid all connectivity on a specific interface
iptables -A OUTPUT -o eth1 -j DROP
# Avoid connectivity to a specific IP
@Eidansoft
Eidansoft / python.py
Last active July 5, 2019 06:55
Python tips
# View the source code of any function in use directly at the debugger, useful to be sure what code are you executing
import inspect
print(''.join(inspect.getsourcelines(NAME_OF_METHOD_TO_SEE_SOURCE_CODE)[0]))
# Create a virtual environment with a specific python version
virtualenv --python=/usr/bin/python2.7 ~/.virtualenvs/test
@Eidansoft
Eidansoft / sql_tips.sql
Last active May 17, 2018 12:20
Generic SQLs to easily solve some issues
-- Look for a table filtering by the name (MySql)
-- If you already has the database selected
SHOW TABLES LIKE '%_name'
-- If the database is not selected
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME like '%_name'
and TABLE_SCHEMA = 'your_db_name'
@Eidansoft
Eidansoft / nano_tips.rst
Created May 1, 2018 09:02
Nano tips that not appear at the window

# Goto the end of file Alt + /

# Goto specific line Ctrl + _

@Eidansoft
Eidansoft / shellscripts_tips.sh
Last active July 23, 2020 08:13
Shellscripts useful tips without category
# Force a shellscript to run from its folder, instead the current directory
# folder where was called from. Useful to use relative paths.
# Set the folder to project, no matter from where the script was called.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $SCRIPT_DIR
# Test the connectivity from a machine to another and the port
nc -vv 192.168.1.200 80
@Eidansoft
Eidansoft / git_tips.sh
Last active August 28, 2020 07:13
Useful quick Git commands
# _____ _
# | __ \ | |
# | |__) |___| |__ __ _ ___ ___
# | _ // _ \ '_ \ / _` / __|/ _ \
# | | \ \ __/ |_) | (_| \__ \ __/
# |_| \_\___|_.__/ \__,_|___/\___|
#
# At the branch containing all the changes you must run...
git checkout BRANCH_WITH_ALL_CHANGES
git rebase -i BRANCH_TO_PUT_CHANGES_INTO
@Eidansoft
Eidansoft / check_conectivity.sh
Created April 4, 2018 08:36
Test to easily check if there is any network issue between two machines
# In the first machine just execute the tool netcat with the port to test and in listening mode
nc -lp 8080
# In the second machine just execute also the netcat but connecting to the previous machine by IP
# or and nameserver, and to the same port
nc 123.123.123.123 1 8080
# From now on all wrote in any machine must appear at the other after INTRO
# This can be used to test connectivity issues between machines, docker containers, etc.
@Eidansoft
Eidansoft / csshX_resize.sh
Last active May 10, 2018 10:53
Control the size and position of a console with a command
# After open a lot of console windows with the csshX (ClusterSSH), if the windows are too small to work with,
# then is better to resize the consoles and view only one (the rest will be also executing the same commands)
# in order to be able to work for example with some editors and other stuff.
# move the console to 0,0
printf '\e[3;0;0t'
# resize to 27x85 characters (laptop)
printf '\e[8;27;85t'