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 / queryselector.js
Created July 8, 2016 09:29
query selector shortcut
/* It returns only the first match || null */
var $ = document.querySelector.bind(document);
/* Ex: $('a.link') */
@jesusalber1
jesusalber1 / download.py
Last active May 9, 2016 20:07
Download files from authenticated websites using cookies
#!/usr/bin/python
import requests
import urllib2
# Current cookies (use 'document.cookie' in Console to get them)
cookies = ''
# Create a dict from that given ookies
cookies = dict(item.split("=", 1) for item in cookies.split("; "))
# Files to be downloaded (paste them manually, use 'Copy link address'). Be careful to add ',' at the end of each line unless last
@jesusalber1
jesusalber1 / scp.sh
Created March 16, 2016 22:29
SCP simple usage
# SCP (Secure Copy, over SSH)
# Local to server
scp /path/to/retrieve user@domain.com:/path/to/save
# Server to local
scp user@domain.com:/path/to/retrieve /path/to/save
# Server to server
scp user@domain.com:/path/to/retrieve user2@domain2.com:/path/to/save
@jesusalber1
jesusalber1 / input-background.scss
Created December 26, 2015 13:35
Prevent yellow auto-complete background in Chrome
/* Idea from http://stackoverflow.com/a/14205994/4296439 */
$input-background-color: white;
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px $input-background-color inset;
box-shadow: 0 0 0 1000px $input-background-color inset;
}
@jesusalber1
jesusalber1 / NewObject.js
Last active December 2, 2015 20:25
Why !(this instanceof Object)?
/* http://stackoverflow.com/questions/22211755/function-f-if-this-instanceof-f-return-new-f,
If constructor is called without 'new' keyword before, it returns a new instance of the object. */
function MyObject(foo){
if (!(this instanceof MyObject)){
return new MyObject(foo);
}
this.bar = foo;
}
@jesusalber1
jesusalber1 / AJAXrequest.js
Created November 24, 2015 21:38
AJAX request to API with callback
function sendRequest(method, targetURL, content, callback) {
var http = new XMLHttpRequest(),
message = (content !== undefined) ? JSON.stringify(content) : undefined;
http.open(method, targetURL, true);
if (message !== undefined) { /* GET requests may not have JSON content */
http.setRequestHeader('Content-type', 'application/json; charset=utf-8');
}
@jesusalber1
jesusalber1 / Bundle.txt
Created August 21, 2015 13:27
COMODO PositiveSSL installation order
Documentation: https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/620/1/which-is-root-which-is-intermediate
Certification chain:
-UserTrust / AddTrust External Root
-COMODO RSA Certification Authority
-COMODO RSA Domain Validation Secure Server CA
-End-Entity/Domain Certificate
Bundle is created by certificates in reversing order (Domain Certificate first!).
@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
@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 / 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;