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
@classmethod | |
def start(cls, port=8080, extra_workers=0): | |
reactor.listenTCP(port, server.Site(cls())) | |
for i in range(extra_workers): | |
pid = os.fork() | |
if pid == 0: | |
# Proceed immediately onward in the children. | |
# The parent will continue the for loop. | |
break | |
else: |
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 relname, pg_size_pretty(relpages::bigint * 8 * 1024) as size, relkind, reltuples::bigint as rows, relpages, relfilenode FROM pg_class ORDER BY relpages DESC; |
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 json | |
from pprint import pprint | |
import requests | |
rtb_request = { | |
"id": "1234FcDe", | |
"imp": [{ | |
"id": "1", | |
"banner": { | |
"w": 100, # width - this be used as width parameter in request in case of dynamic size placements |
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 iter_stack(tb, limit=None): | |
"""modified version of traceback.extract_stack. it yields same tuples, but with frame.f_locals appended.""" | |
if limit is None: | |
if hasattr(sys, 'tracebacklimit'): | |
limit = sys.tracebacklimit | |
n = 0 | |
while tb is not None and (limit is None or n < limit): | |
f = tb.tb_frame | |
lineno = tb.tb_lineno | |
co = f.f_code |
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
nc -U /var/run/memcached/memcached.sock |
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
SET FOREIGN_KEY_CHECKS = 0; | |
SET GROUP_CONCAT_MAX_LEN=32768; | |
SET @tables = NULL; | |
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables | |
FROM information_schema.tables | |
WHERE table_schema = (SELECT DATABASE()); | |
SELECT IFNULL(@tables,'dummy') INTO @tables; | |
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables); | |
PREPARE stmt FROM @tables; |
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
sudo apt-get install build-essential libsqlite3-dev zlib1g-dev libncurses5-dev libgdbm-dev libbz2-dev libreadline5-dev libssl-dev libdb-dev | |
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz | |
tar -xzf Python-2.7.3.tgz | |
cd Python-2.7.3 | |
./configure --prefix=/usr --enable-shared | |
make | |
sudo make install | |
cd .. |
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
tar -c "$srcdir" | tar -C "$destdir" -xv | |
tar -cf archive.tar foo bar | |
tar -xf archive.tar # Extract all files from archive.tar. | |
tar -tvf archive.tar # List all files in archive.tar verbosely. | |
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
sudo su - <username> | |
sudo -u username <cmd> |
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
gitolite admin repo – this is where you add new repos, users, and access. | |
git clone ssh://gitolite@hostname_or_ip:ssh_port/gitolite-admin | |
You now have a gitolite-admin directory with conf/ and keydir/ inside. Conf directory contains gitolite.conf file and you will add users, privileges and projects/repos here. Keydir is where you save the ssh key files. Note: Make sure the filename of ssh key matches the user on gitolite.conf without the .pub. As example, you will have your ssh key file in keydir/user.pub and in gitolite.conf you have the following: | |
repo gitolite-admin | |
RW+ = user | |
To add users, upload the ssh key file inside keydir/ and add his access inside gitolite.conf. | |
vi keydir/user2.pub | |
To create new repository, just add the following lines in conf/gitolite.conf: | |
repo drupal_dev | |
RW+ = user user2 |
OlderNewer