Skip to content

Instantly share code, notes, and snippets.

@gmzi
gmzi / openFlaskInRemote.sh
Created May 31, 2022 15:11
Open local Flask server in remote machine
#!/bin/sh
# This script takes the IP of the local machine, then makes a URL pointing to the local Flask server (http://192.168.1.9:5000),
# opens the URL in remote machine's Chrome tab, runs the Flask server, and plays a sound when ready.
# USAGE: in Flask's project folder: ~/path-to-script/openFlaskInRemote.sh [remote_machine_name]
IP=""
# find all the active connections of the local machine,
# and find the IP address of the first one
@gmzi
gmzi / connect.sh
Created May 13, 2022 18:21
Find device by name in .local network, connect via ssh
# This script finds a device in local network by its name (using "devicename.local"), and
# then connects to it via ssh. Default device is "rainbow", other device name can be
# passed as a parameter.
# USAGE: ./connect.sh [machine_name]
#!/bin/sh
@gmzi
gmzi / findAndOpenLocalhost.sh
Created May 13, 2022 14:43
Find and open a remote machine's localhost server
# This script is to find and open the localhost server of a target remote
# machine connected to the same network and identified by name, in cases where `mymachine.local` is not available.
# There's a default machine named "XXX", script accepts custom machine names as first argument.
# The localhost port defaults to 3000 but
# can also be passed as an argument. Script has been tested on Mac OS only.
# USAGE: ./findAndOpenLocalhost.sh <machine_name> <port_number>
#!/bin/sh
@gmzi
gmzi / openLocalhost.sh
Created May 13, 2022 14:39
open remote machine's localhost server
# This script is to open localhost server from a local browser,
# it has a default-machine.local and :3000 as default port, both
# can be passed as arguments. On execution, it will open the target
# remote machine's localhost server in a Chrome tab.
# USAGE: ./openLocalhost.sh <machine_name> <port_number>
#!/bin/sh
# Uppercase user input for machine name, or use default:
@gmzi
gmzi / makeUrl.sh
Last active May 13, 2022 14:29
Find the IP of the local machine and make a url to localhost server
#!/bin/sh
IP=""
# find all the active connections of the machine,
# and find the IP address of the first one
for i in $(ifconfig -lu) ; do
if (ifconfig $i | grep -q "status: active") ; then
IP=$(ifconfig $i | grep -i "inet ")
break