This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {QueryResult, Client} from 'pg' | |
const doQuery = (query: string): Promise<QueryResult>=>{ | |
return new Promise((resolve, reject)=>{ | |
const client: Client = new Client(clientConfig) | |
client.connect((connectError: Error)=>{ | |
if(connectError) | |
return reject(connectError.message) | |
client.query(query, (queryError: Error, queryResult: QueryResult)=>{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## INSTALL NGINX | |
sudo add-apt-repository ppa:nginx/stable | |
sudo apt-get update | |
sudo apt-get install nginx | |
## ADD PAGESPEED DINAMICALLY | |
(from https://github.com/itbdw/nginx_pagespeed_dynamic_module) | |
cd /etc/nginx | |
sudo wget https://github.com/itbdw/nginx_pagespeed_dynamic_module/blob/master/nginx_versions/1.12.1/ngx_pagespeed.so?raw=true | |
sudo mv ngx_pagespeed.so?raw=true ngx_pagespeed.so |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
###### NVM (from https://github.com/creationix/nvm) | |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash | |
(restart the shell) | |
nvm install stable | |
###### echo script | |
var http = require('http'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## controller: | |
function action(){ | |
// validate($request).... <- this doesn't work, it doesn't send the named bag to the view | |
$validator = Validator::make($request->all(), [ | |
'nombre' => 'required|unique:clientes|max:50|min:2', | |
'nombreCorto' => 'required|unique:clientes|max:10|min:2', | |
], [ | |
"required" => ':attribute es obligatorio', | |
"unique" => ':attribute debe ser unico' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -u backup-operator crontab -e | |
on crontab, add: | |
## backup the files every hour | |
00 * * * * sh /home/backup-operator/backup_files.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# use "gunzip -k file.sql.gz" to unzip and keep the files | |
echo "INICIANDO RESPALDO...." | |
DB_USER=backup | |
DB_PASS=backup | |
DB_TABLE_1=TABLE_1 | |
DB_TABLE_2=TABLE_2 | |
DAY=$(date +%Y-%m-%d) | |
TIME=$(date +%H-%M-%S) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########## USO DIARIO ########## | |
# eliminar un branch remoto | |
git push --delete origin thebranch | |
# eliminar un branch local | |
git branch --delete thebranch | |
#### otra forma: | |
# primero eliminar el local | |
git branch -d mybranch | |
# luego empujar los cambios al servidor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============== IN THE DEV MACHINE | |
git remove list | |
git remote add prod-falp1 ssh://user@domain/home/user/repo.git | |
git remote -v | |
// prod-falp1 ssh://user@domain/home/user/repo.git (push) | |
============== IN THE PROD MACHINE | |
cd ~ | |
mkdir repo.git && cd repo.git | |
git init --bare |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash +x | |
ip=/sbin/iptables | |
ipPublica="200.111.191.3/29" | |
redLocal="192.168.1.1/24" | |
tothEntel="186.67.103.122" | |
tothMovistar="186.103.220.254" | |
admins="$tothEntel $tothMovistar $ipPublica $redLocal" | |
tcpservices=21,22,smtp,80,443,104,8080,5432,5096,8008 | |
# 53 udp, 123 ntp, 161 snmp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## fijar timezone | |
timedatectl set-timezone America/Santiago | |
# instalar git | |
sudo-apt get install git | |
git config --global user.email "pm5k.sk@gmail.com" | |
git config --global user.name "AlejandroSilva" | |
## create new user | |
adduser demouser |