Skip to content

Instantly share code, notes, and snippets.

@jezhalford
jezhalford / Labels.php
Created April 4, 2012 11:27
Zend Framework view helper to render a sheet of address labels as a PDF
<?php
/**
* A view helper to render a sheet of address labels as a PDF.
*/
class My_View_Helper_Labels extends Zend_View_Helper_Abstract {
/**
* @var int A page size constant from Zend_Pdf_Page
*/
private $_pageSize;
@jezhalford
jezhalford / gist:2480871
Created April 24, 2012 15:45
Map Lat/Lon onto map pixels
/**
* Convert Latitude and Longitude to CSS top and left positions for a map image.
* Works with any map image that uses Spherical Mercator Projection (the same as Google Maps)
*
* From http://stackoverflow.com/a/7021776/86780
*/
var latLonToTopLeft = function(lat, lon) {
var imageNorthLat = 59.545457; // Latitude of the image's northern edge
var imageSouthLat = 49.431947; // Latitude of the image's southern edge
@jezhalford
jezhalford / Default.sublime-theme
Last active December 16, 2015 00:08
Entire default sublime text 2 theme file, modified to have a dark sidebar and bold folders as per https://gist.github.com/larrybotha/2935636
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@jezhalford
jezhalford / Preferences.sublime-settings
Created April 23, 2013 12:02
Preferences > Settings - User
{
"auto_complete_commit_on_tab": false,
"bold_folder_labels": true,
"caret_style": "phase",
"draw_minimap_border": false,
"fade_fold_buttons": false,
"find_selected_text": true,
"font_face": "Menlo",
"highlight_line": true,
"highlight_modified_tabs": true,
@jezhalford
jezhalford / crontab2puppet.html
Last active December 21, 2015 07:28
Thing to turn crontabs into puppet manifests
<!doctype html>
<html>
<head>
<title>crontab2puppet - Convert a crontab to a puppet manifest.</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body style="padding: 20px">
<h1>crontab2puppet</h1>
#!/bin/sh
#
# Execute phing commands inside a vagrant VM, without having
# to `vagrant ssh` first.
#
CMD="cd /vagrant && phing $@"
vagrant ssh --command "cd /vagrant && $CMD"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
@jezhalford
jezhalford / constraints.sql
Created March 30, 2015 15:21
Get DROP and CREATE statements for all foreign key constraints on a given table.
-- source http://stackoverflow.com/a/13764961/86780
SELECT `DROP`,`CREATE` FROM (
SELECT
CONCAT("ALTER TABLE `", `K`.`TABLE_NAME`, "` DROP FOREIGN KEY `", `K`.`CONSTRAINT_NAME`, "`;") "DROP",
CONCAT("ALTER TABLE `",
`K`.`TABLE_NAME`,
"` ADD CONSTRAINT ",
"`fk_",
`K`.`TABLE_NAME`,
@jezhalford
jezhalford / trawl.sh
Created April 16, 2015 13:25
Trawl for broken links
wget --spider -o ./wget.log -r -p http://www.example.com
grep -B 2 '\.\.\. 40[0-9]\|\.\.\. 50[0-9]' wget.log | sed '/Reusing/d' | sed 's/^HTTP.*\.\.\. //' | sed 's/--.*-- //' | sed '/^--$/d' > broken-links.log