Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
python_3_email_with_attachment.py | |
Created by Robert Dempsey on 12/6/14. | |
Copyright (c) 2014 Robert Dempsey. Use at your own peril. | |
This script works with Python 3.x | |
NOTE: replace values in ALL CAPS with your own values |
Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
This gist contains lists of modules available in
in AWS Lambda.
It also contains the code to run in Lambda to generate these lists. In addition there
is a less_versbose
module in the code that you can call to get a list of the top
level modules installed and the version of those modules (if they contain a version
# Determine if the current directory is a GIT repo | |
# and print out '*' if there are changes to be committed | |
iz_git_dirty() { | |
#IZ_GIT=`git status 2>/dev/null` | |
IZ_DIRTY=`git status 2>/dev/null | grep 'nothing to commit (working directory clean)'` | |
#if [ "." != "$IZ_GIT." ]; then | |
if [ "." == "$IZ_DIRTY." ]; then | |
echo '*' | |
fi |
def reltime(date, compare_to=None, at='@'): | |
r'''Takes a datetime and returns a relative representation of the | |
time. | |
:param date: The date to render relatively | |
:param compare_to: what to compare the date to. Defaults to datetime.now() | |
:param at: date/time separator. defaults to "@". "at" is also reasonable. | |
>>> from datetime import datetime, timedelta | |
>>> today = datetime(2050, 9, 2, 15, 00) | |
>>> earlier = datetime(2050, 9, 2, 12) |
#! /usr/bin/bash | |
#echo 'Obtendo senha do ddg...'; | |
#senha=`wget -q --no-check-certificate -O - \ | |
# https://duckduckgo.com/?q=password+10 | \ | |
# sed -e 's/.*class="zero_click_answer">//' -e 's/ .*//'`; | |
echo 'Obtendo senha do /dev/urandom'; | |
senha=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 10`; | |
"""Asynchronous requests in Flask with gevent""" | |
from time import time | |
from flask import Flask, Response | |
from gevent.pywsgi import WSGIServer | |
from gevent import monkey | |
import requests |
#!/usr/bin/env python | |
from __future__ import with_statement | |
import os | |
import re | |
import shutil | |
import subprocess | |
import sys | |
import tempfile | |
import os | |
import sys | |
# Install venv by `virtualenv --distribute venv` | |
# Then install depedencies: `source venv/bin/active` | |
# `pip install -r requirements.txt` | |
activate_this = '/var/www/apache/csshat.com/csshat.com/venv/bin/activate_this.py' | |
execfile(activate_this, dict(__file__=activate_this)) | |
path = os.path.join(os.path.dirname(__file__), os.pardir) |
# Public Domain, i.e. feel free to copy/paste | |
# Considered a hack in Python 2 | |
import inspect | |
def caller_name(skip=2): | |
"""Get a name of a caller in the format module.class.method | |
`skip` specifies how many levels of stack to skip while getting caller | |
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. |