Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
## Run this bash file to install MongoDB v3.2.7 in your cloud9 workspace
# message functions {
function msg {
colorCode="\033[0;32m"
clearColorCode="\033[0m"
if [ $# -eq 2 ]; then
/* SMOOTH SCROLL */
/* jQuery Required */
/* Source: https://css-tricks.com/snippets/jquery/smooth-scrolling/ */
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
// Event listener for scrolling up or down
// source: http://jsfiddle.net/jquerybyexample/ScQQr/
var iScrollPos = 0;
$(window).scroll(function () {
var iCurScrollPos = $(this).scrollTop();
if (iCurScrollPos > iScrollPos) {
console.log('down');
} else {
/* Customized Responsive Grid System OF 4 columns
/* Customized from http://www.responsivegridsystem.com/
You can use this grid to add any number of elements to
the grid, and this will automatically scale down from 4
to 3, then 2 and lastly 1 column depending on the device
usage:
.grid .grid_of_4 for the grid container.
.col .cell for each cell in the grid.
function setSkillPercentage() {
$(".percentage").each(function(){
var percentage = $(this).data("percentage");
$(this).html("<span style='width:" + percentage + "%'>" + percentage + "%</span>");
});
}
@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;
@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 / ufw_recommended_settings.md
Last active February 1, 2017 04:59
Recommended ufw settings for your https vps
@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 / 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