Demo of multipart form/file uploading with hapi.js.
npm install
npm run setup
npm run server
Then ...
| /* | |
| * Nunjucks + Express | |
| * I couldn't find anything that helped me setup the enviornment | |
| * correctly for these in the latest vesion of Express 4 (at the time | |
| * of writing this). | |
| * | |
| * This Gist for those that want to keep using Nunjucks with Express 4. | |
| * This also goes over working with a Nunjucks environment to use custom | |
| * filters, extensions, etc. | |
| * |
| 'use strict'; | |
| // simple express server | |
| var express = require('express'); | |
| var app = express(); | |
| var router = express.Router(); | |
| app.use(express.static('public')); | |
| app.get('/', function(req, res) { | |
| res.sendfile('./public/index.html'); |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');Those suck for maintenance and they're ugly.
| var gm = require('gm'); | |
| var canvasWidth = 248; | |
| var canvasHeight = 389; | |
| gm(__dirname + '/original.jpg').size(function(error, size) { | |
| if (error) { | |
| console.error(error); |
| function RemoveAccents(strAccents) { | |
| var strAccents = strAccents.split(''); | |
| var strAccentsOut = new Array(); | |
| var strAccentsLen = strAccents.length; | |
| var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; | |
| var accentsOut = "AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz"; | |
| for (var y = 0; y < strAccentsLen; y++) { | |
| if (accents.indexOf(strAccents[y]) != -1) { | |
| strAccentsOut[y] = accentsOut.substr(accents.indexOf(strAccents[y]), 1); | |
| } else |
| A warning occurred (42 apples) | |
| An error occurred |
| #!/bin/bash | |
| #=============================================================================== | |
| # | |
| # FILE: getgeo.sh | |
| # | |
| # USAGE: ./getgeo.sh | |
| # | |
| # DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your | |
| # database | |
| # |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |