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 timedelta_format(td_object): | |
''' | |
Format a timedelta object to a string such that only the significant | |
portion of it is displayed. | |
Some examples: | |
12 days, 12:55:00 -> 12 days | |
1 day, 12:00:00 -> 1 day | |
1 day, 1:01:00 -> 1 day, 1 hour |
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
SELECT GENERATE_SERIES('2001-02-16', '2001-03-03', '1 day'::INTERVAL); |
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
wget http://www.hpcf.upr.edu/web/sites/default/files/start-stop-daemon.c | |
gcc start-stop-daemon.c -o start-stop-daemon | |
sudo cp start-stop-daemon /usr/sbin/start-stop-daemon |
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/bin/env python | |
import os | |
def list_process(): | |
for pid in os.listdir('/proc'): | |
if not pid.isdigit(): | |
continue |
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
import pytz | |
import datetime | |
tz = [(item, datetime.datetime.now(pytz.timezone(item)).strftime('%z') + " " + item) for item in pytz.common_timezones] | |
sorted(tz, key=lambda x: int(x[1].split()[0])) | |
for name, off in sorted(tz, key=lambda x: int(x[1].split()[0])): | |
print name, '\r\t\t\t', off | |
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
from multiprocessing import Process, Queue | |
def mp_map(pfunc, iterable, debug=False): | |
q = Queue(2) | |
for i, u in enumerate(iterable): | |
t = Process(target=lambda q, i, u: q.put([i, | |
pfunc(u)]), args=(q, i, u)) |
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 access.log | cut -f1 -d ' ' | sort | uniq -c | sort -g -r |
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
sudo yum -y install fail2ban | |
sudo chkconfig --add fail2ban | |
sudo service fail2ban start |
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/sh | |
# | |
# rabbitmq-server RabbitMQ broker | |
# | |
# chkconfig: - 80 05 | |
# description: Enable AMQP service provided by RabbitMQ | |
# | |
### BEGIN INIT INFO | |
# Provides: rabbitmq-server |
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/bin/env python | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
import boto | |
import config | |
import gevent | |
import gevent.pool | |
import os |