Launch the instance and connect with ssh.
##Update the server
sudo yum update
##Install php and MySQL packages
ask = (question, format, callback) -> | |
stdin = process.stdin | |
stdout = process.stdout | |
stdin.resume() | |
stdout.write "#{question}:" | |
stdin.once 'data', (data) -> | |
data = data.toString().trim() | |
if format.test(data) |
Launch the instance and connect with ssh.
##Update the server
sudo yum update
##Install php and MySQL packages
app.get('/', function(req, res){ | |
var ua = req.header('user-agent'); | |
if(/mobile/i.test(ua)) { | |
res.render('mobile.html'); | |
} else { | |
res.render('desktop.html'); | |
} | |
}); |
/* function to urlify a string */ | |
var urlify = function(a){return a.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "-").replace(/^-+|-+$/g, '')}; | |
/* usage example */ | |
var str_a = "* The Best Wallpaper Magazine in the . ? & world! : Rjer9238131 & "; | |
urlify(str_a) | |
/* returns */ | |
"the-best-wallpaper-magazine-in-the-world-rjer9238131" |
wget https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz | |
tar zxf libevent-2.0.18-stable.tar.gz | |
cd libevent-2.0.18-stable | |
sudo ./configure | |
sudo ./make | |
DIR="/home/ec2-user/downloads/libevent-2.0.18-stable" | |
wget http://downloads.sourceforge.net/tmux/tmux-1.6.tar.gz | |
tar zxf tmux-1.6.tar.gz | |
cd tmux-1.6 |
Recent releases have been pre-built using cross-compilers and this script and are downloadable below.
If you have found these packages useful, give me a shout out on twitter: @adammw
#!/bin/sh | |
TABLE_SCHEMA=$1 | |
TABLE_NAME=$2 | |
mytime=`date '+%y%m%d%H%M'` | |
hostname=`hostname | tr 'A-Z' 'a-z'` | |
file_prefix="trimax$TABLE_NAME$mytime$TABLE_SCHEMA" | |
bucket_name=$file_prefix | |
splitat="4000000000" | |
bulkfiles=200 |
Some thoughts on using node-postgres in a web application
This is the approach I've been using for the past year or so. I'm sure I'll change and it will change as I grow & am exposed to more ideas, but it's worked alright for me so far.
I would definitely use a single pool of clients throughout the application. node-postgres ships with a pool implementation that has always met my needs, but it's also fine to just use the require('pg').Client
prototype and implement your own pool if you know what you're doing & have some custom requirements on the pool.
The MIT License (MIT) | |
Copyright (c) 2015 Textalk | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |