Skip to content

Instantly share code, notes, and snippets.

@bryhal
bryhal / get_remote_image_size.php
Created February 15, 2013 01:04
Workaround for file_exist() on remote server when checking if an image exists
function image_exists($uid) {
$url= getimagesize('http://269.354.158.245/images/someimage.jpg');
if (is_array($url)) {
$path = 'http://269.354.158.245/images/someimage.jpg';
} else {
return FALSE;
}
@bryhal
bryhal / gist:4129042
Created November 22, 2012 02:08
MYSQL: Generate Calendar Table
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53
day_name VARCHAR(9) NOT NULL, -- 'Monday', 'Tuesday'...
@bryhal
bryhal / send_email2.py
Created November 4, 2012 01:04
PYTHON: SMTP Email with HTML and Multiple Attachments
# Found most ofthis at http://ryrobes.com/python/python-snippet-sending-html-email-with-an-attachment-via-google-apps-smtp-or-gmail/
# Adapted to accept a list of files for multiple file attachments
# From other stuff I googled, a little more elegant way of converting html to plain text
# This works in 2.7 and my brain gets it.
######### Setup your stuff here #######################################
attachments = ['test_pdf.pdf', 'test_waiver.pdf']
username = '[email protected]'
@bryhal
bryhal / dirwatch.py
Created November 3, 2012 20:04
PYTHON: FSMonitor skeleton - monitor folder(s) for changes
#!/usr/bin/env python
# depends on FSMonitor https://github.com/shaurz/fsmonitor
import sys
import os
def main():