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 / 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. %))))
@jgomo3
jgomo3 / framebuffer.c
Created April 5, 2020 23:31 — forked from FredEckert/framebuffer.c
Paint Pixels to Screen via Linux FrameBuffer
/*
To test that the Linux framebuffer is set up correctly, and that the device permissions
are correct, use the program below which opens the frame buffer and draws a gradient-
filled red square:
retrieved from:
Testing the Linux Framebuffer for Qtopia Core (qt4-x11-4.2.2)
http://cep.xor.aps.anl.gov/software/qt4-x11-4.2.2/qtopiacore-testingframebuffer.html
*/