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
// Return s, with parameters substituted as in key-values of object params | |
function subsituteParams(s, params) { | |
$.each(params, function(k,v) { | |
s = s.replace(k,v); | |
}); | |
return s; | |
} |
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 parsedatetime.parsedatetime as pdt | |
def datetimeFromString( s ): | |
c = pdt.Calendar() | |
result, what = c.parse( s ) | |
dt = None | |
# what was returned (see http://code-bear.com/code/parsedatetime/docs/) |
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
#!/bin/sh | |
# This file will reset the firewall to allow everything. | |
# | |
# Set the default policy | |
# | |
/sbin/iptables -P INPUT ACCEPT | |
/sbin/iptables -P FORWARD ACCEPT | |
/sbin/iptables -P OUTPUT ACCEPT | |
# | |
# Set the default policy for the NAT table |
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 os | |
import smtplib | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
class Mailer: | |
def __init__(self, **kwargs): | |
mandatory_args = ["username","password","server","port"] | |
for x in mandatory_args: |
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
source venv/bin/activate # Remove if not using a virtualenv | |
export CFLAGS=-Qunused-arguments # /headbashing | |
pip install Pillow # Install with pip | |
python -c "import PIL" # Verify it worked |
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
"""Calculates the end date for any given datetime object""" | |
import calendar | |
def last_day(year, month): | |
return calendar.monthrange(year, month)[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
# Thanks to: http://darklaunch.com/2014/02/02/fix-do-you-want-the-application-python-to-accept-incoming-network-connections | |
. venv/bin/activate | |
codesign -s "Personae Dev Cert" -f $(which python) |
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
#!/bin/sh | |
# | |
# Startup script for persistent tcpdump | |
# | |
PCAP=/data/tcpdump/tcpdump.pcap | |
SIZE=100 | |
COUNT=20 | |
PIDFILE=/var/run/tcpdump |
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 BaseHTTPServer | |
import SocketServer | |
import socket | |
import threading | |
import functools | |
import contextlib | |
code, content = 200, "Ok" | |
class Handler(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_GET(self): |
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
if (window.location.href.indexOf("https://") != 0 && window.location.href.indexOf("http://localhost") == -1) { | |
window.location.href = window.location.href.replace("http://", "https://"); | |
} |
OlderNewer