Skip to content

Instantly share code, notes, and snippets.

View osorionicolas's full-sized avatar

Nicolás Osorio osorionicolas

View GitHub Profile
@osorionicolas
osorionicolas / LinkWardenExportjson2htmlconverter.py
Created April 28, 2025 23:38
A simple convertor in Python to take the backup.json file that is supplied by LinkWarden on clicking export or through the migration API and convert it into the Netscape bookmark HTML format which is supported by most other major bookmarking, read-it-later and link-saving applications
import json
import logging
from datetime import datetime
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
def date_to_timestamp(date_str):
try:
dt = datetime.fromisoformat(date_str.replace('Z', '+00:00'))
return int(dt.timestamp())
@osorionicolas
osorionicolas / ansible.Dockerfile
Created January 18, 2023 06:16
Ansible Dockerfile
FROM alpine:latest
RUN apk add \
--update \
--no-cache ansible && \
rm -rf /tmp/* /var/cache/apk
@osorionicolas
osorionicolas / ytVideoDownloader.py
Created July 4, 2022 18:07
Youtube videos downloader
import pytube
url = input("Enter video url: ")
path="/etc/"
pytube.YouTube(url).streams.get_highest_resolution().download(path)
@osorionicolas
osorionicolas / proxy.js
Created March 2, 2022 07:31
Proxy validation
const userValidator = {
set(object, prop, value) {
const validProps = ['name', 'email'];
if(!validProps.includes(prop)) {
throw new Error(`Can't set ${prop}`);
} else {
object[prop] = value;
return true;
}
},
@osorionicolas
osorionicolas / condProp.js
Created March 2, 2022 07:25
Conditionally add properties to an Object
const obj = {
a: 1,
...(true && { b: 5 }),
...(false && { c: 10 }),
};
obj; // output: { a: 1, b: 5 }
#!/bin/bash
HOST=$1
# port defaults to 8080
PORT=${2:-8080}
RETRIES=50
echo -n "Waiting for keycloak to start on ${HOST}:${PORT}"
# loop until we connect successfully or failed
until curl -f -v "http://${HOST}:${PORT}/" >/dev/null 2>/dev/null
@osorionicolas
osorionicolas / send-email.ps1
Created January 27, 2022 02:00
Send email script for Powershell
$smtpServer = "smtp.gmail.com"
$mail = new-object Net.Mail.MailMessage
$mail.From = ""
$mail.To.Add("")
$mail.Subject = "Subject"
$mail.Body = "Body"
$smtp = new-object Net.Mail.SmtpClient($smtpServer, 465)
$smtp.EnableSs1 = $true
$SMTP.Credentials = New-Object System.Net.NetworkCredential(MAIL, PASSWORD)
$smtp.Send($mail)
@osorionicolas
osorionicolas / keycloak-export.sh
Created January 25, 2022 06:53
Bash script used to generate an export from Keycloak including users in the json
docker exec -it b691cd6a3902 /opt/jboss/keycloak/bin/standalone.sh \
-Djboss.socket.binding.port-offset=100 \
-Dkeycloak.migration.action=export \
-Dkeycloak.migration.provider=singleFile \
-Dkeycloak.migration.file=/tmp/keycloak-export.json
@osorionicolas
osorionicolas / find_max.js
Last active January 24, 2022 17:50
Find maximum item of an Array by given key
const people = [
{ name: 'Naruto', age: 24 },
{ name: 'Sasuke', age: 32 },
{ name: 'Minato', age: 42 },
{ name: 'Kakashi', age: 36 }
]
const maxBy = (arr, key) => arr.reduce((max,obj) => {
return max[key] >= obj[key] ? max : obj)
}, {})
@osorionicolas
osorionicolas / capitalize.scala
Created January 11, 2021 13:15
Scala - Capitalize
def capitalizeAll(args: String*) = {
args.map { arg =>
arg.capitalize
}
}
capitalizeAll("rarity", "applejack")