This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def split-into-words (partial re-seq #"\w+")) | |
(comment | |
;; split-into-words, implemented with the trivial \w+ regular | |
;; expression, it works fine in English: | |
(split-into-words "Have a nice day.") | |
;; => ("Have" "a" "nice" "day") | |
;; But it fails with other languages, like in Spanish. In the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns map-threads) | |
(defmacro map-> [coll & body] | |
`(for [e# ~coll] | |
(-> e# ~@body))) | |
(defmacro map->> [coll & body] | |
`(for [e# ~coll] | |
(->> e# ~@body))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;=============== play with flow ============== | |
(require '[clojure.core.async :as async] | |
'[clojure.core.async.flow :as flow] | |
'[clojure.pprint :as pp]) | |
(defn monitoring [{:keys [report-chan error-chan]}] | |
(prn "========= monitoring start") | |
(async/thread | |
(loop [] | |
(let [[val port] (async/alts!! [report-chan error-chan])] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Length { | |
int getLength(); | |
} | |
class CommentStruct { | |
protected String author; | |
protected String content; | |
} | |
public class Comment extends CommentStruct implements Length{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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" | |
[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PRJ=$1 | |
BCKP="backups/$PRJ_`date +%Y-%m-%d_%H:%M`" | |
install -d $BCKP | |
rsync -av --progress $PRJ/ $BCKP/phmsrails --exclude log |
NewerOlder