You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: f = open('test.txt')
s = f.read()
f.close()
except IOError:
print("Cannot open the file")
list = [1, 2, 3]
try:
list[8]
except:
print("out of range")
else:
print("in range")
finally:
print("always do this")
Command-Line Arguments
import sys
for (i, value) in enumerate(sys.argv):
print("arg: %d %s " % (i, value))
Note To detach from a screen session use Ctrl+A + d
> **Note**
> To rename it, enter the command mode (**Ctrl+A** + **:**) and then enter the command:
>
> sessionname
List All Screen Sessions
screen -ls
Attach to an Existing Screen Session
screen -dr <pid>
Where <pid> is the screen session PID.
Configuration File
Useful ~/.screenrc configuration:
defutf8 on
# Name the first tab
screen -t "First Tab"
# View the home directory in the "First Tab"
stuff "cd ~/ && clear^M"
# To use **Ctrl+B** instead of **Ctrl+A** add the following to the `~/.screenrc` file:
escape ^Bb
# Autodetach session on hangup instead of terminating screen completely
autodetach on
# Turn the splash screen off
startup_message off
# Use a 30000-line scrollback buffer
defscrollback 30000
# Set messages timeout to one second
msgwait 2
# Bind F11 and F12 (NOT F1 and F2) to previous and next screen window
bindkey -k F1 prev
bindkey -k F2 next
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sysctl vm.swappiness=10
echo "vm.swappiness=10" | tee /etc/sysctl.conf -a
sysctl vm.vfs_cache_pressure=50
echo "vm.vfs_cache_pressure=50" | tee /etc/sysctl.conf -a
sites=(site-name-1 site-name-2 site-name-3)
for site in "${sites[@]}"
do
if [ -d "$site/css/version-1" ]; then
echo "css already exists on $site"
else
echo "css don't exists on $site"
cp -r global/css/version-1/ $site/css
fi
done
Where abcdef... is the ssh key and /usr/bin/ssh is the restricted command
Vagrant Postgre tunnel on localhost
Add to the end of pg_hba.conf (find it with sudo find / -name pg_hba.conf -type f) on vagrant:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
host all all 33.33.33.20/32 trust
Messages are going to 10.0.79.9:L5556 via a tunnel over proxy.server.net.
The message is comming back over proxy.server.net:55562 (10.0.79.1:55562) to the local machine on port 55562.
Open a tunnel from the local mashine (port 3022) to the domain.net server. You should now be able to connect through the domain.net server to the machine. Everything what comes to domain.net:81 will be redirected to the local 3022 port.