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: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:e97ff8462677c8ef4770
Created February 8, 2015 19:02
set javascript mode in emacs local variables comment
// Local Variables:
// mode: javascript
// End:
var images_to_captions = {
"pic1.jpg" : "This is pic one",
"pic2.jpg" : "second pic is here",
"pic3.jpg" : "blargh",
}
$.BgSwitcher.defineEffect("fadeAndSwitchText", function($el) {
$el.animate({opacity: 0}, this.config.duration, this.config.easing, function(){
// new slide so switch text here
var currentimage = '?';// get this from the css or the context or something
@tleen
tleen / gist:3c8fb99ad5873d8af549
Created October 18, 2015 19:36
AWS EC2 instance info url
http://169.254.169.254/latest/
@tleen
tleen / gist:4742207
Created February 8, 2013 21:48
sample nginx to node
server{
listen *:8080;
server_name myproject.com;
location / {
root /usr/share/nginx/myproject/static;
try_files $uri @app;
}
@tleen
tleen / gist:5105182
Created March 7, 2013 02:45
Node: Recurse through a directory and upload files to s3, using async, knox, underscore
// recurse through tempdir and upload all files
(function uploadFile(filepath, callback){
fs.stat(filepath, function(err, stats){
if(err) return callback(err);
else{
if(stats.isDirectory()){
fs.readdir(filepath, function(err, files){
var files = _.map(files, function(file){ return path.join(filepath, file) });
async.each(files, uploadFile, callback);
});