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
echo "flush_all" | /bin/netcat 127.0.0.1 11211 |
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
python -m smtpd -n -c DebuggingServer localhost:1025 |
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
# switch to user postgres | |
sudo su - postgres | |
# create user (no superuser, no create db, ...) | |
createuser -S -D -R -E -P username | |
# create utf8 encoded db owned by username | |
createdb -E utf8 -O username dbname | |
# edit /etc/postgresql/9.1/main/pg_hba.conf and add the following line (so your user is allowed to connect from localhost): |
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
# create an empty template database | |
createdb -U postgres template_postgis | |
# add the postgis sql to our template | |
psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql | |
# add pgsql suport to template | |
createlang plpgsql template_postgis | |
# add a geospatial reference system to the template |
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
find . -maxdepth 1 -iname '*jpg' -exec convert -resize 1920x1080^ -gravity center -extent 1920x1080 {} out/{} \; |
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
# find all files in all subdirectories and copy them to ../out_directory/ | |
find . -name "*" -type f -printf "processing %p\n" -exec cp '{}' ../out_directory/ \; |
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
\copy (select relname, | |
CAST(reltuples as INT) tuples, | |
pg_total_relation_size(CAST(relname as TEXT)) size, | |
pg_size_pretty(pg_total_relation_size(CAST(relname as TEXT))) pretty_size | |
from pg_class | |
where relnamespace = 2200 and | |
relname not like '%_id_seq' and | |
relname not like '%_pkey' and | |
relname not like '%_key' and | |
relname not like '%_id' |
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
SELECT | |
table_name AS "Table", | |
table_rows as "Tuples", | |
round(data_length/1024/1204,2) as "Data in MB", | |
round(index_length/1024/1024,2) as "Index in MB", | |
round(((data_length + index_length) / 1024 / 1024), 2) "Combined in MB" | |
FROM information_schema.TABLES | |
WHERE table_schema = "[db_name]"; |
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
select | |
l.mode as "lock", | |
substring(sa.current_query from 0 for 50) as "query", | |
c.relname as "relation", | |
l.database, | |
sa.query_start as "start", | |
age(now(), sa.query_start) as "age", | |
sa.procpid as "pid" | |
from | |
pg_stat_activity sa, |
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 user_from_session_key(session_key): | |
""" | |
Returns the User related to the given Django session key. | |
""" | |
from django.conf import settings | |
from django.contrib.auth import SESSION_KEY, BACKEND_SESSION_KEY, load_backend | |
from django.contrib.auth.models import AnonymousUser | |
session_engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) | |
session_wrapper = session_engine.SessionStore(session_key) |
OlderNewer