Skip to content

Instantly share code, notes, and snippets.

@AlexandroPerez
AlexandroPerez / nginx_postgresql_provision.sh
Created June 28, 2017 08:07
Vagrant provision for installing latest stable nginx and postgresql 9.6 in Ubuntu Xenial (16.04)
echo "Adding nginx deb and deb-src packages to /etc/apt/sources.list"
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list
echo "Downloading nginx_signing.key..."
curl -Os https://nginx.org/keys/nginx_signing.key
echo "Adding it to the apt program keyring"
apt-key add ./nginx_signing.key
echo "Adding postgresql deb packages..."
@AlexandroPerez
AlexandroPerez / nginx_provision.sh
Last active June 28, 2017 07:44
Vagrant provision for installing nginx in Ubuntu Xenial
echo "Adding nginx deb and deb-src packages to /etc/apt/sources.list"
echo "deb http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/ubuntu/ xenial nginx" >> /etc/apt/sources.list
echo "Downloading nginx_signing.key..."
curl -Os https://nginx.org/keys/nginx_signing.key
echo "Adding it to the apt program keyring"
apt-key add ./nginx_signing.key
echo "Installing nginx..."
.element {
-webkit-user-select: none;
-moz-user-select: -moz-none;
/*IE10*/
-ms-user-select: none;
user-select: none;
/*You just need this if you are only concerned with android and not desktop browsers.*/
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
@AlexandroPerez
AlexandroPerez / site.conf
Created March 24, 2017 03:43
nginx configuration file for a nodejs app listening on port 3030
server {
listen 8080;
server_name localhost;
location / {
root /var/www/local.com;
index index.html index.htm;
}
location /api {
@AlexandroPerez
AlexandroPerez / new-project.sh
Created March 17, 2017 08:44
Add a new project to your Google Cloud Platform in its own www folder, and ready for automatic deployment using git. Just provide the name of your new project, and this script will take care of the rest.
#!/bin/sh
# Make sure this script is not run using sudo privileges
if [ "$USER" = "root" ]; then
echo "\033[0;31mERROR: You shouldn't run this shell script as root..."
exit
fi
NGINXREADY=true
if [ ! -d "/etc/nginx/conf.d/projects" ]; then
@AlexandroPerez
AlexandroPerez / jquery_end_example.js
Last active March 3, 2017 02:37
How jQuery END works
$('#lists')
.find(' > li') // FILTER1 #lists > li
.filter('li:last') // FILTER1_1 #lists > li:last
.addClass('coloring2')
.end() // go back to previous filter: FILTER1 #lists > li
.find('ul') // FILTER1_2: find ul inside #lists > li
.filter('> li') // FILTER1_2_1: ul > li inside #lists > li
.addClass('coloring')
.end() // go back one filter FILTER1_2
.end() // go back one filter FILTER1
@AlexandroPerez
AlexandroPerez / ufw_recommended_settings.md
Last active February 1, 2017 04:59
Recommended ufw settings for your https vps
@AlexandroPerez
AlexandroPerez / failed2ban_unban_ip.md
Last active September 4, 2018 07:58
Unban an IP from fail2ban

Unban an IP from fail2ban using interactive mode

the fail2ban-client has an interaction mode which will make it easy to unban an IP without many complications. To access interactive mode use:

$ fail2ban-client -i

once in interactive mode type ssh, or in some cases sshd (this was the case in my installation)

@AlexandroPerez
AlexandroPerez / caesars_cipher.js
Created November 24, 2016 01:05
Free Code Camp - Basic Algorithm Scripting - Caesars Cipher
function rot13(str) { // LBH QVQ VG!
var decodedStr = "";
var charShift = 0;
for (var i = 0, length = str.length; i < length; i++) {
if ( /[a-m]/i.test(str[i]) ) {
charShift = 13;
} else if ( /[n-z]/i.test(str[i] ) ) {
charShift = -13;
} else {
charShift = 0;
function setSkillPercentage() {
$(".percentage").each(function(){
var percentage = $(this).data("percentage");
$(this).html("<span style='width:" + percentage + "%'>" + percentage + "%</span>");
});
}