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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / example.js
Created August 26, 2016 11:39
CasperJS: quick start
/* Run: $ casperjs example.js */
var casper = require('casper').create({
verbose: true, /* Production mode: false */
logLevel: 'debug',
pageSettings: {
loadImages: false,
loadPlugins: false
}
});
@jesusalber1
jesusalber1 / script.js
Last active February 20, 2023 16:52
[Google Scripts] Replace commas with dots in Google Spreadsheets
function replaceCommasDots() {
var id = ''; /* Your spreadsheet id (value after /id/*): https://docs.google.com/spreadsheets/d/:id/edit */
var sheet = SpreadsheetApp.openById(id);
var range = sheet.getRange("A1:B2"); /* range you want to modify */
var data = range.getValues();
for (var row = 0; row < data.length; row++) {
for (var col = 0; col < data[row].length; col++) {
data[row][col] = (data[row][col]).toString().replace(/,/g, '.');
}
@jesusalber1
jesusalber1 / getWeek.js
Last active November 9, 2016 20:38
Get range of the current week [Monday-Sunday]
/* Based on: http://stackoverflow.com/a/8381494 */
/* Date proptotype extension */
Date.prototype.getWeek = function() {
/* I get the current date and then shift it */
var today = new Date(this.setHours(0, 0, 0, 0)); /* Current date */
var dayOfWeek = today.getDay() - 1; /* It starts on Monday (Sunday by default) */
var dayOfMonth = today.getDate() - dayOfWeek; /* ([1-31]) Beginning of the week */
/* Get range */
var start = new Date(today.setDate(dayOfMonth)); /* Monday */