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
interface Length { | |
int getLength(); | |
} | |
class CommentStruct { | |
protected String author; | |
protected String content; | |
} | |
public class Comment extends CommentStruct implements Length{ |
# 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]] |
(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)) |
(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" | |
[] |
(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)) |
#!/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 |
#!/bin/bash | |
PRJ=$1 | |
BCKP="backups/$PRJ_`date +%Y-%m-%d_%H:%M`" | |
install -d $BCKP | |
rsync -av --progress $PRJ/ $BCKP/phmsrails --exclude log |
[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 |
(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. %)))) |