Handy emacs command which will limit your operations (and visibility) to a selected region. Good for regional search/replace and the like.
- Mark your region
- C-x n n / narrow-to-region
- Do what you are going to do
- C-x n w / widen
server{ | |
listen *:8080; | |
server_name myproject.com; | |
location / { | |
root /usr/share/nginx/myproject/static; | |
try_files $uri @app; | |
} |
// 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); | |
}); |
var rfc822Date = moment(yourDate).format('ddd, DD MMM YYYY HH:mm:ss ZZ') |
var html5datetime = moment(yourDate).format('YYYY-MM-DDTHH:mm:ssZ') |
url.parse('http://some.long.hostname.here.com/andpages.html').hostname.split('.').reverse().slice(0,2).reverse().join('.'); |
Not totally obvious from the documentation, but to use html-minifier in node, you need to import the .minify function | |
! var minify = require('html-minifier'); | |
var minify = require('html-minifier').minify, | |
Did not see a node usage pattern out there. |
Handy emacs command which will limit your operations (and visibility) to a selected region. Good for regional search/replace and the like.
// I don't love this but its a quick/dirty create of cache duration using moment's nice date add format | |
// parse cache duration as [integer][unit] via http://momentjs.com/docs/#/manipulating/add/ shorthand | |
var durations = /^([\d]+)([\w]+)/.exec(inputString); | |
var invalidateSeconds = moment(0).add(durations[2],durations[1]).unix(); |
['Alabama','Alaska','American Samoa','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Federated States of Micronesia','Florida','Georgia','Guam','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Marshall Islands','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Northern Mariana Islands','Ohio','Oklahoma','Oregon','Palau','Pennsylvania','Puerto Rico','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virgin Island','Virginia','Washington','West Virginia','Wisconsin','Wyoming'] |
American Express Test Card 370000000000002 | |
Discover Test Card 6011000000000012 | |
Visa Test Card 4007000000027 | |
Second Visa Test Card 4012888818888 | |
JCB 3088000000000017 | |
Diners Club/ Carte Blanche 38000000000006 |