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 / 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 / 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 / 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: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: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: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: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