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
def cryptogram(plaintext): | |
from random import shuffle | |
# create cryptogram cypher. You can't shuffle strings, so lists it is. | |
alpha = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') | |
beta = alpha[:] | |
shuffle(beta) | |
cmap = dict(zip(alpha,beta)) | |
# Map the received string to a cryptogram. Note we're not cleaning any input. | |
cryptext = [ cmap[c] if c in alpha else c for c in plaintext.upper()] | |
return ''.join(cryptext) |
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
def escape(seq): | |
jumps = 0 | |
pos = 0 | |
while True: | |
try: | |
offset = seq[pos] | |
seq[pos] +=1 | |
pos += offset | |
jumps +=1 |
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
def build_dict(seq, key): | |
return dict((d[key], dict(d)) for (_, d) in enumerate(seq)) | |
i2stat = build_dict(raw["results"], 'name') | |
rate = {'IdoMysqlConnection': "idomysqlconnection_ido-mysql_queries_1min", | |
'IdoPgsqlConnection': "idomysqlconnection_ido-pgsql_queries_1min"} | |
print( set(i2stat.keys()) ) |
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
I see a few things in /usr/share/glib-2.0/schemas/org.gnome.desktop.wm.preferences.gschema.xml that aren't in Gnome-tweak-tool. | |
So I make a change and then do a find to see where the changes were made: .config/dconf/user -- which is parsed by dconf. | |
$ dconf dump / |grep -C1 raise | |
[org/gnome/desktop/wm/preferences] | |
auto-raise=true | |
That can be changed on the command line. |
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
#!/usr/env/python | |
from __future__ import print_function | |
import socket | |
import threading | |
bind_ip = "127.0.0.1" | |
bind_port = 9999 | |
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
server.bind((bind_ip,bind_port)) |
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
def fizzbuzz(n): | |
for x in range(1,n+1): | |
result='' | |
if not x%3: result += ('fizz') | |
if not x%5: result += ('buzz') | |
yield result if result else str(x) |
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
In [20]: foo = [(3,8), (5,3), (4,6), (1,5), (4,3), (4,7)] | |
In [21]: sorted(foo) | |
Out[21]: [(1, 5), (3, 8), (4, 3), (4, 6), (4, 7), (5, 3)] | |
In [22]: sorted(foo, key=lambda _: (-_[0],_[1])) | |
Out[22]: [(5, 3), (4, 3), (4, 6), (4, 7), (3, 8), (1, 5)] | |
In [23]: sorted(foo, key=lambda X: (-X[0], X[1])) | |
Out[23]: [(5, 3), (4, 3), (4, 6), (4, 7), (3, 8), (1, 5)] |
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
I received the following comment from a web developer after I told him I wouldn't make his volatile files directory chmod 777 so Apache could write to it. | |
"777 tends to scare sys admins, so I understand." | |
Here's my response: | |
"Yes, it scares us and it should scare you. | |
"Think of your account like an apartment. If you set your permissions to 777, anyone who can get into the building (onto the server) can make changes: raid your fridge, steal your cat, replace your pillows, or plant evidence pointing to a crime you didn't commit. Even if they did none of those things, you can get skeeved out by the possiblility. |
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
[~]$ cat <<EOF > suicide.php | |
> <?php | |
> unlink(__FILE__); | |
> ?> | |
> EOF | |
[~]$ php suicide.php | |
[~]$ cat suicide.php | |
cat: suicide.php: No such file or directory | |
[~]$ |
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
#!/bin/env bash | |
CMD='sudo fail2ban-client status'; for J in `$CMD | awk -F':' '/Jail list/ {gsub(/,/,""); print $2}'` ; do $CMD $J ;done |