Let's say you want to host domains first.com
and second.com
.
Create folders for their files:
Ansible playbook to setup HTTPS using Let's encrypt on nginx. | |
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS. | |
The server pass A rating on [SSL Labs](https://www.ssllabs.com/). | |
To use: | |
1. Install [Ansible](https://www.ansible.com/) | |
2. Setup an Ubuntu 16.04 server accessible over ssh | |
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain | |
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder) |
TL;DR
9.4 -> 9.5:
sudo pg_dropcluster 9.5 main --stop
sudo service postgresql stop
sudo pg_upgradecluster -m upgrade -k 9.4 main
sudo su postgres -c "/usr/lib/postgresql/9.5/bin/vacuumdb --all --analyze-in-stages"
sudo pg_dropcluster 9.4 main
#!/bin/bash | |
TIMESTAMP=$(date +"%F") | |
BACKUP_DIR="/backups/$TIMESTAMP" | |
MYSQL_USER="user_DB" | |
MYSQL=/usr/bin/mysql | |
MYSQL_PASSWORD="password_DB" | |
MYSQLDUMP=/usr/bin/mysqldump | |
mkdir -p "$BACKUP_DIR/mysql" | |
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"` | |
for db in $databases; do |
var myApp = angular.module('myApp').service('CordovaNetwork', ['$ionicPlatform', '$q', function($ionicPlatform, $q) { | |
// Get Cordova's global Connection object or emulate a smilar one | |
var Connection = window.Connection || { | |
"CELL" : "cellular", | |
"CELL_2G" : "2g", | |
"CELL_3G" : "3g", | |
"CELL_4G" : "4g", | |
"ETHERNET" : "ethernet", | |
"NONE" : "none", | |
"UNKNOWN" : "unknown", |
** Find commmonly accessed tables and their use of indexes: | |
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct; | |
Returns output like: | |
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct | |
----------------------+--------------+---------------+------------------------ | |
schema_migrations | 817 | 0 | 0.00000000000000000000 | |
user_device_photos | 349 | 0 | 0.00000000000000000000 |
$(document).ready(function() { | |
$('html,body').animate({scrollTop: $("#dataTable").offset().top},'slow'); | |
}); |
the default index.html does not work well in prodution mode, so do not borther to config that, just delete it and go on.
To put things in production mode, do
rails g scaffold items name:string
rake db:migrate RAILS_ENV=production
rm public/index.html
#change route.rb point root to items#index
rake assets:precompile
sudo service nginx restart
./config/unicorn_init.sh stop
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software. | |
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module | |
# This module "secure-link" helps you to protect links from stealing away. | |
# | |
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg | |
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.2.2.tar.gz | |
$ tar xzvf ./nginx-1.2.2.tar.gz && rm -f ./nginx-1.2.2.tar.gz |