Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Jesús Alberto Polo García jesusalber1

👨‍💻
View GitHub Profile
@jesusalber1
jesusalber1 / download.sh
Created Sep 16, 2020
Download a website locally
View download.sh
wget -m -p -E -k www.example.com
@jesusalber1
jesusalber1 / open_url.py
Last active Mar 11, 2019
Open all found urls in default browser
View open_url.py
import re
import webbrowser
text = """
Text with urls goes here. Let's open Google at https://google.com
"""
urls = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', text)
for url in urls:
@jesusalber1
jesusalber1 / pi.py
Created Feb 26, 2019
Estimating Pi using the Monte Carlo method
View pi.py
import random
import math
inner = 0
total = 0
for i in range(10000):
x = random.random()
y = random.random()
if (math.sqrt(x**2 + y**2) < 1):
@jesusalber1
jesusalber1 / nodeclick.js
Created May 31, 2018
neo4jd3 onNodeClick example
View nodeclick.js
var neo4jd3 = new Neo4jd3('#neo4jd3', {
onNodeClick: function(node) {
if (node.id == 5) { // your node id
$.ajax({
url: "/endpoint", // your API endpoint
dataType: 'json', // if you receive a JSON
success: function(data) {
neo4jd3.updateWithNeo4jData(data);
}
});
View index.handlebars
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Fil Rouge</title>
<link href="https://netdna.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<link rel="stylesheet" href="assets/style.css">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
@jesusalber1
jesusalber1 / Manager.gs
Last active Nov 23, 2016
Calendar synchronization: EDT (Telecom Bretagne) and GCal
View Manager.gs
/* Constants */
var URL_EDT = 'http://edt.telecom-bretagne.eu/xxx'; /* Student's iCal source (EDT) */
var GCAL_ID = 'xxx@group.calendar.google.com'; /* Google Calendar ID */
/* ---Helpers--- */
/* Custom object to handle events between EDT and GCal */
function CustomEvent(title, startTime, endTime, description, location) {
this.title = title;
this.startTime = startTime;
this.endTime = endTime;
@jesusalber1
jesusalber1 / ghost
Created Nov 20, 2016
Ghost nginx configuration
View ghost
# sets the proxy cache path location, max size 512m
proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=STATIC:100m inactive=24h max_size=512m;
# transfers the `Host` header to the backend
proxy_set_header Host $host;
# uses the defined STATIC cache zone
proxy_cache STATIC;
# cache 200 10 minutes, 404 1 minute, others status codes not cached
@jesusalber1
jesusalber1 / getWeek.js
Last active Nov 9, 2016
Get range of the current week [Monday-Sunday]
View getWeek.js
/* 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 */
@jesusalber1
jesusalber1 / script.js
Last active Feb 12, 2021
[Google Scripts] Replace commas with dots in Google Spreadsheets
View script.js
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 / example.js
Created Aug 26, 2016
CasperJS: quick start
View example.js
/* Run: $ casperjs example.js */
var casper = require('casper').create({
verbose: true, /* Production mode: false */
logLevel: 'debug',
pageSettings: {
loadImages: false,
loadPlugins: false
}
});