Skip to content

Instantly share code, notes, and snippets.

View jgomo3's full-sized avatar
🏠
Working from home

Jesús Gómez jgomo3

🏠
Working from home
View GitHub Profile
@jgomo3
jgomo3 / python.rst
Last active March 20, 2024 08:32
Proposal of Python examples for GeoServer REST API Documentation

Python

The examples in this section use the scripting language Python. They will be based en the cURL examples.

We'll be working with Python3 and only with the `Python Standard

@jgomo3
jgomo3 / Comment.java
Created September 1, 2023 14:16
Decouple structure and implementation and delay the coupling to another time.
interface Length {
int getLength();
}
class CommentStruct {
protected String author;
protected String content;
}
public class Comment extends CommentStruct implements Length{
@jgomo3
jgomo3 / inf_req_14.rb
Created October 23, 2022 19:31
Solución al ejercicio 14 de Infinita Recursión
# Genera una nueva lista como `lista`, pero los valores asociados a
# `:id` de cada elemento valen lo miso que su posición en la lista.
#
# Ejemplo:
#
# reindexar([{id: nil, val: :x}, {id: nil, val: :y}])
# # genera
# [{id: 0, val: :x}, {id: 1, val: :y}]
#
# @param lista [[Object]]
@jgomo3
jgomo3 / bb3.clj
Last active August 13, 2022 13:02
Solución al ejercicio 3 de Blackbox
(ns jgomo3.playground.blackbox.bb3)
(def tdc-long 16)
(def tdc-ocult 13)
(def tdc-most (- tdc-long tdc-ocult))
(defn tdc-req? [n]
"String -> Boolean
Condición para procesar `n` como tarjeta de crédito"
(= (count n) tdc-long))
@jgomo3
jgomo3 / bb2.clj
Created August 1, 2022 01:16
Solución al ejercicio 2 de Blackbox
(ns jgomo3.playground.blackbox.bb2)
;; v1: No considera el hecho de que hay combinaciones de Rubik imposibles.
(def v1-rubik-base (flatten (map (partial repeat 9) (range 6))))
(defn v1-generar-cubo-rubik-aleatorio!
"Genera un arreglo de 54 casillas con 9 números repetidos cada uno 6
veces en un orden cualquiera"
[]
@jgomo3
jgomo3 / bb1.clj
Created July 25, 2022 19:48
Solución al ejercicio 1 de Blackbox
(ns jgomo3.playground.blackbox.bb1
(:require [java-time :as jt]))
(def bb-date-format "y-M-d")
(defn en-año
"Determina si `fecha` está en el año `año`."
[año fecha]
(= (jt/as fecha :year) año))
@jgomo3
jgomo3 / mllp-constantly-server.sh
Last active March 3, 2022 22:37
A dummy MLLP server and an MLLP wrapper
#!/usr/bin/env
# mllp-constantly-server port response
#
# Listen on port `port` for messages and response always the same content:
# whatever is in the `response` file.
# Supposing mllp-wrap to excecute the `mllp-wrap.sh` script in this gist.
while true; do mllp-wrap $2; done | nc -k -l $1
@jgomo3
jgomo3 / bk.sh
Created March 2, 2022 13:08
Backup in `backups` folder sufixing date
#!/bin/bash
PRJ=$1
BCKP="backups/$PRJ_`date +%Y-%m-%d_%H:%M`"
install -d $BCKP
rsync -av --progress $PRJ/ $BCKP/phmsrails --exclude log
@jgomo3
jgomo3 / autossh-reverse-tunnel.service
Created June 8, 2021 01:29
AutoSSH reverse tunnel for allowing access
[Unit]
Description=AutoSSH reverse tunnel for allowing access here
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -i /root/us-east-1.pem -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 0.0.0.0:2000:localhost:22 ec2-user@52.207.226.149
[Install]
WantedBy=multi-user.target
@jgomo3
jgomo3 / stream-edn.clj
Created February 15, 2021 22:30
Streaming an edn... failing at the end
(ns playground.stream-edn
(:require [clojure.java.io :as io]
[clojure.edn :as edn])
(:gen-class))
(defn edn-reader [rsrc-name]
(->> rsrc-name
io/resource
io/reader
(#(java.io.PushbackReader. %))))