Skip to content

Instantly share code, notes, and snippets.

@samisalkosuo
samisalkosuo / changestr.sh
Created December 10, 2014 10:33
Change string in file.
#!/bin/sh
#change string in file
if [[ $# -ne 3 ]]; then
echo "Wrong number of arguments"
echo "Usage: $0 FILE FROMSTRING TOSTRING"
exit 1
fi
SED_FILE=$1
@samisalkosuo
samisalkosuo / gist:c0811e968d905420b194
Last active August 29, 2015 14:10
Open port in iptables firewall
#Open firewall for port
FW_PORT=9877
iptables -I INPUT 1 -p tcp -m tcp --dport $FW_PORT -j ACCEPT
iptables -I INPUT 1 -p tcp -m tcp --sport $FW_PORT -j ACCEPT
iptables -I OUTPUT 1 -p tcp -m tcp --sport $FW_PORT -j ACCEPT
iptables -I OUTPUT 1 -p tcp -m tcp --dport $FW_PORT -j ACCEPT
#save firewall rules
/sbin/service iptables save
/sbin/service iptables restart
import hashlib
h = hashlib.new('sha256')
h.update(str)
print h.hexdigest()