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 / download.sh
Created September 16, 2020 09:45
Download a website locally
wget -m -p -E -k www.example.com
@jesusalber1
jesusalber1 / open_url.py
Last active March 11, 2019 22:46
Open all found urls in default browser
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 February 26, 2019 22:00
Estimating Pi using the Monte Carlo method
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 20:02
neo4jd3 onNodeClick example
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);
}
});
<!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 November 23, 2016 12:53
Calendar synchronization: EDT (Telecom Bretagne) and GCal
/* 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 November 20, 2016 21:46
Ghost nginx configuration
# 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 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 */
@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 / 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
}
});