Skip to content

Instantly share code, notes, and snippets.

View tleen's full-sized avatar
🚀
Making things.

Tom Leen tleen

🚀
Making things.
View GitHub Profile
@tleen
tleen / gist:6395808
Created August 31, 2013 02:13
Javascript array of Canadian Provinces
['Alberta', 'British Columbia', 'Manitoba', 'New Brunswick', 'Newfoundland and Labrador', 'Northwest Territories', 'Nova Scotia', 'Nunavut', 'Ontario', 'Prince Edward Island', 'Quebec', 'Saskatchewan', 'Yukon Territory']
@tleen
tleen / gist:6471233
Created September 6, 2013 23:12
node mysql socket connect
var db = mysql.createConnection({
user : 'dbuser',
socketPath : '/tmp/mysql.sock', //wherever the mysql socket is
database : 'dbname'
});
db.connect();
@tleen
tleen / gist:6841963
Created October 5, 2013 15:00
Get a random value from a dropdown w/ JQuery
function dropdownRandomValue(name){
var dropdown = $('#' + name);
var values = _.pluck(dropdown.find('option:enabled'), 'value');
var selectedIndex = Math.floor(Math.random() * values.length);
return values[selectedIndex];
}
@tleen
tleen / gist:31fa7fc6d42ecd6d0eb5
Created June 6, 2014 00:40
Express redirecting from mounted sub-apps / router
res redirect can use patterns to respect an existing external mount point for an express app/router:
res.redirect('/relative/to/host');
res.redirect('relative/to/mount-point');
res.redirect('./relative/to/pathname');
so if you wanted to redirect back to the root mount point for your mounted app, you could do this:
res.redirect('./');
@tleen
tleen / gist:da581ee9d7539a41bf6d
Created June 8, 2014 14:40
passport-local always fails
passport-local always fails if the incoming user login name is not named 'username', not very obvious, especially if you use emails as the login name.
express, express 4 and passport
@tleen
tleen / gist:2e2ec2e4cb8a8a0eb2a0
Created July 26, 2014 15:31
Generate random 1M file on unix
head -c 1048576 </dev/urandom > filename
@tleen
tleen / gist:2d76c5030e3ee9d12619
Created August 15, 2014 02:14
Notes on mixing git and subversion for wordpress plugin
Need to use svn to officially host a wordpress plugin, rather be using git+github, so i mix and match. without git-svn:
- make your initial plugin in github
- issue a release in github
- use the .zip download of the release as your initial submission
- once approved you get a wordpress svn repo
- check out your empty repo: https://wordpress.org/plugins/about/svn/
- copy your plugin files into the /trunk (including your .git/.gitignore)
@tleen
tleen / gist:6fc7055c1a865c56cf94
Created August 16, 2014 00:23
php-fpm access denied .html
By default php-fpm only parses files ending in .php, you can change it in the php-fpm config file (which may be under php-fpm.d/www.conf):
;security.limit_extensions = .php .php3 .php4 .php5
to
security.limit_extensions = .php .html
@tleen
tleen / gist:f7b3e40c8b3ad976df05
Created September 22, 2014 22:33
Create empty gh-pages branch for GitHub Pages
git checkout --orphan gh-pages
@tleen
tleen / gist:e97ff8462677c8ef4770
Created February 8, 2015 19:02
set javascript mode in emacs local variables comment
// Local Variables:
// mode: javascript
// End: