Skip to content

Instantly share code, notes, and snippets.

View boutell's full-sized avatar

Tom Boutell boutell

View GitHub Profile
@boutell
boutell / gist:4614579
Created January 23, 2013 22:12
Nightly cron job to clean up dukelist postings
/var/www/dukelist/app/console dukelist:cleanup --env=prod
app/console dukelist:migrate-legacy-database --env=prod
@boutell
boutell / nestedapps.js
Created December 31, 2012 22:41
Nested Express apps. The "Main Wildcard" route always beats all routes in catsApp even though it is added first with app.use. I wish app.use() had the same precedence as adding a route.
// HOPED-FOR BEHAVIOR: /cats says: Cats Home
// ACTUAL BEHAVIOR: /cats says: Main Wildcard
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.send('Main Home');
})
@boutell
boutell / static.js
Created December 31, 2012 22:39
express.static middleware must be added before any routes are added to the project, which is potentially confusing when constructing reusable modules to be added to projects as needed. I wish app.use() behaved as just another route for precedence purposes
// HOPED-FOR BEHAVIOR: both /cats.txt AND /cats/cats.txt say: Cats Static
// ACTUAL BEHAVIOR: /cats.txt says Cats Static, but /cats/cats.txt says: Main Wildcard
var express = require('express');
var fs = require('fs');
var app = express();
// Adding the static middleware at the beginning means it wins out over any routes present
// (but only interferes if the file exists)
// Render a view specific to this module
function render(res, template, info) {
return res.render(__dirname + '/views/' + template, info);
}
@boutell
boutell / gist:4225851
Created December 6, 2012 16:36
Import series for testing
./symfony scrape-legacy-site --series-only && ./symfony create-entities --import-posts
@boutell
boutell / gist:4143757
Created November 25, 2012 14:34
Update to Symfony 1.4.20
svn up && ./symfony apostrophe:deploy staging staging && ./symfony apostrophe:deploy production prod
@boutell
boutell / gist:4125045
Created November 21, 2012 14:16
Scaled up my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Use new password format for compatibility with newer PHP
old_passwords=0
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
PunkAve\GPS\SchoolBundle\Entity\School:
constraints:
- \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: psp_id
- \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: name
@boutell
boutell / gist:3941578
Created October 23, 2012 21:10
Display a Google map with markers linking to pages
// Display a map with markers that link to other pages. Each marker must
// have latitude, longitude and slug properties. There must also be a
// a 'url' option which is used to build the links. The following
// wildcards are replaced in the url: ID (with the id), SLUG (with the
// slug property), PUBLISHED (with /year/month/day taken from published_at),
// and START (with /year/month/day taken from start_date). In other words,
// you can pass most array-hydrated Doctrine objects, including Apostrophe
// blog posts and events, and easily generate links back to them.
// The hover text title of the marker is taken from title if present,