$ sed -i "/\b\(cat\|rat\)\b/d" filename
This file contains 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
import sys | |
def readfile(file): | |
with open(file) as src: | |
return [line.strip() for line in src.readlines()] | |
lines_1 = readfile(sys.argv[1]); lines_2 = readfile(sys.argv[2]) | |
for line in lines_1: | |
if not line in lines_2: |
This file contains 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
def get_count(q): | |
count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
count = q.session.execute(count_q).scalar() | |
return count | |
q = session.query(TestModel).filter(...).order_by(...) | |
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
print q.count() |
This file contains 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
$ cat file.csv | tr "\\t" "," |
This file contains 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
setxkbmap -option ctrl:nocaps |
$ awk -F, '!seen[$1]++'
This file contains 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
$ date | |
$ more /etc/timezone | |
$ sudo dpkg-reconfigure-tzdata | |
$ /etc/init.d/cron stop | |
$ /etc/init.d/cron start |
This file contains 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
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$+=\-_()|~`#\{\}\[\].,:;<>\\\/"'^@$!%*?&])[A-Za-z\d$+=\-_()|~`#\{\}\[\].,:;<>\\\/"'^@$!%*?&][A-Za-z\d$+=\-_()|~`#\{\}\[\].,:;<>\\\/"'^@$!%*?&A-Za-z]{8,} | |
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$+=\-_()|~`#\{\}\[\].,:;<>\\\/"\'^@$!%*?&])[A-Za-z\d$+=\-_()|~`#\{\}\[\].,:;<>\\\/"\'^\@$!%*?&][A-Za-z\d$+=\-_()|~`#\{\}\[\].,:;<>\\\/"\'^@$!%*?&A-Za-z]{10,15} |
This file contains 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
import paramiko | |
k = paramiko.RSAKey.from_private_key_file("/Users/whatever/Downloads/mykey.pem") | |
c = paramiko.SSHClient() | |
c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
print "connecting" | |
c.connect( hostname = "www.acme.com", username = "ubuntu", pkey = k ) | |
print "connected" | |
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ] | |
for command in commands: | |
print "Executing {}".format( command ) |
This file contains 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
(function () { | |
function tConvert (time) { | |
// Check correct time format and split into components | |
time = time.toString ().match (/^([01]\d|2[0-3])(:)([0-5]\d)(:[0-5]\d)?$/) || [time]; | |
if (time.length > 1) { // If time format correct | |
time = time.slice (1); // Remove full string match value | |
time[5] = +time[0] < 12 ? 'AM' : 'PM'; // Set AM/PM | |
time[0] = +time[0] % 12 || 12; // Adjust hours |