Skip to content

Instantly share code, notes, and snippets.

View jesusalber1's full-sized avatar
👨‍💻

Jesús Alberto Polo García jesusalber1

👨‍💻
View GitHub Profile
@jesusalber1
jesusalber1 / gist:66b168cad732487eecf2
Last active August 29, 2015 14:22
Useful OpenSSL commands
#Send HTTP commands in SSL connections (like telnet)
#Standard command
openssl s_client -connect www.google.com:443
# Handshake doesn't mind
openssl s_client -quiet -connect www.google.com:443
@jesusalber1
jesusalber1 / gist:a937cdde33603f63ce26
Last active August 29, 2015 14:22
Get and set cookies
/* Get and set cookies 'manually' */
function setCookie(cookieName, value, expirationYears) {
var CookieDate = new Date;
CookieDate.setFullYear(CookieDate.getFullYear() + expirationYears);
document.cookie = cookieName + '=' + value + '; expires=' + CookieDate.toGMTString( ) + ';';
}
function getCookie(cookieName) {
var currentCookie,
@jesusalber1
jesusalber1 / gist:38919ff63f71d910dd37
Last active August 29, 2015 14:22
LocalStorage manipulation
function setLocalStorage(key, value) {
if (typeof value == 'object') {
value = JSON.stringify(value);
}
localStorage.setItem(key, value);
}
function getLocalStorage(key) {
var value = localStorage.getItem(key);
@jesusalber1
jesusalber1 / gist:b38489934a591c22ca7e
Last active August 29, 2015 14:22
Get random between two integers
/* Forked from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random */
/* This function returns a random integer between two numbers, both included (min - max) */
function getRandomInteger(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/* var random = getRandomInteger(0, 5); */
@jesusalber1
jesusalber1 / gist:0cef04fc46ab418e8811
Last active August 29, 2015 14:22
Weekdays and months
var weekdays = ('Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday').split('|');
var months = ('January|February|March|April|May|June|July|August|September|October|November|December').split('|');
/* if weeks start on Monday... (var weekdays was declared before in global scope) */
function weekStartsOnMonday() {
var sunday = weekdays.shift();
weekdays.push(sunday);
}
@jesusalber1
jesusalber1 / gist:2bd949ec1ece0b1407a8
Last active August 29, 2015 14:22
Sanitize filename
function sanitizeFileName(name) {
return name
.replace(/ /g, '-') /* Spaces as - (slug...) */
.replace(/[^A-Za-z0-9-_\.]/g, '') /* Only letters, numbers and symbols: - _ . */
.replace(/\.+/g, '.') /* .. or more -> . */
.replace(/-+/g, '-') /* -- or more -> - */
.replace(/_+/g, '_'); /* __ or more -> _ */
}
@jesusalber1
jesusalber1 / bubbles.css
Created June 16, 2015 16:44
Bubbles preloader
.preloader {
display: inline-block;
position: relative;
}
.preloader-item {
-webkit-animation: anim-preloader-item 1s ease-in-out infinite alternate;
animation: anim-preloader-item 1s ease-in-out infinite alternate;
background: #2ecc71;
border-radius: 50%;
@jesusalber1
jesusalber1 / bounce.css
Created July 3, 2015 14:51
Bounce preloader
.preloader {
display: inline-block;
position: relative;
-webkit-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.item {
width: 30px;
height: 30px;
@jesusalber1
jesusalber1 / gist:d262ce1c36da3ef13de0
Last active August 29, 2015 14:24
Serialize name
/* Serialize names for cases when:
JESÚS ALBERTO POLO GARCÍA or POLO GARCÍA, JESÚS ALBERTO
I want the first one, then I modify the original String for get the first from the second (when necessary)
POLO GARCIA, JESUS ALBERTO -> JESUS ALBERTO POLO GARCIA */
function serializeName(name) {
if (name.indexOf(',') > -1) {
var reversed = name.split(",");
reversed[0] = reversed[0].trim();
reversed[1] = reversed[1].trim();
@jesusalber1
jesusalber1 / node
Last active February 27, 2024 13:43
Install node.js
# Joyent instructions (https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#debian-and-ubuntu-based-linux-distributions)
# Download from the source
curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
# Installing node directly (latest version)
sudo apt-get install --yes nodejs
# Build tools for npm
sudo apt-get install --yes build-essential