Skip to content

Instantly share code, notes, and snippets.

View jplaza's full-sized avatar

Juan Antonio Plaza jplaza

View GitHub Profile
@jplaza
jplaza / routes.clj
Last active December 30, 2015 15:39
Pedestal interceptors per HTTP verb
(defroutes routes
["/contact" {:get [:contact home/contact-page] ;; Handler for GET /contact
:post [^:interceptors [home/verify-contact-form] ;; Interceptors for POST /contact
:contact-submit home/contact-submit-form]} ;; Handler for POST /contact
^:interceptors [middlewares/keyword-params]]) ;; Interceptors for any HTTP verb in the /contact route
@jplaza
jplaza / modulo-11.clj
Created October 9, 2014 23:26
Código de control
;; Implementación de Código de control con módulo 11
;; http://es.wikipedia.org/wiki/C%C3%B3digo_de_control
(defn verificador-suma-parcial [grupo] (reduce + 0 (map * grupo (range 2 8))))
(defn digito-verificador [clave-acceso]
(let [c (partition 6 6 nil (map #(Integer/parseInt (str %)) (reverse clave-acceso)))
digito (reduce + 0 (map verificador-suma-parcial c))
m (mod digito 11)]
(if (> m 1) (- 11 m) m)))
@jplaza
jplaza / guia_remision_datil_1.0.json
Last active August 29, 2015 14:11
Emisión de Guía de Remisión
{
"apikey": "497eacaa70f34afb86e343d568540cc5",
"codigoestablecimiento": "001",
"codigopuntoventa":"001",
"secuencia": "000000003",
"fechainiciotransporte":"12-12-2014",
"fechafintransporte": "12-12-2014",
"direccionpartida": "Victor Emilio Estrada",
"transportista": {
"tipoidentificacion":"RUC",
@jplaza
jplaza / facturas.json
Last active September 14, 2015 19:51
Consulta de facturas en app.datil.co
{
"count":2,
"next":null,
"previous":null,
"results":[
{
"numero":"001-001-000000110",
"comprador_correo":"[email protected]",
"detalle":[
{
@jplaza
jplaza / legacy_support_invoice_response.json
Created September 21, 2015 20:09
Support for legacy (factora) JSON schema
{
"emisor": null,
"total_sin_impuestos": "225.57",
"secuencia": "263",
"tipo": "factura",
"total_impuestos": [
{
"codigo": "2",
"codigo_porcentaje": "2",
"base_imponible": "200.58",
{
name: "Guayaquil",
photos: [{
file: "peñas.jpg",
description: "Barrio las Peñas",
created: "2015-10-24"
}, {
file: "malecón.jpg",
description: "Vista Aérea del Malecón",
created: "2014-12-30"
{
"id":"07f471bcfd434d13897a6edcf190441d",
"secuencial":"42578",
"clave_acceso":"0911201501099258144100120010010000425781993590512",
"autorizacion":{
"numero":"0911201516311709925814410010997052341",
"fecha":"2015-11-09T16:31:17.000968",
"estado":"AUTORIZADO",
"mensajes":[
@jplaza
jplaza / poll-sqs.clj
Last active November 17, 2015 18:59
Minimal implementation of an SQS long polling daemon written in Clojure
(ns co.datil.sqsd
"Polls SQS periodically for messages."
(:require [amazonica.aws.simpleworkflow :as swf]
[amazonica.aws.sqs :as sqs]
[clojure.tools.logging :as log]
[environ.core :refer [env]]))
(defn process-msg
"Task: body of the message placed in the queue"
[queue-url msg]
@jplaza
jplaza / error-firmando.json
Created December 18, 2015 22:40
Datil sign issue error
{
"secuencial":766,
"firma":{
"result":"bad",
"error":"Ocurrió un error al tratar de firmar el comprobante, por favor inténtalo nuevamente.",
"status":400
},
"fecha_emision":"2015-12-16T15:38:01-05:00",
"emisor":{
"ruc":"1792478103001",
@jplaza
jplaza / cli_clock.clj
Last active May 4, 2018 19:38
Convert seconds to a stop watch
(defn strftime [secs]
(format "%02d:%02d:%02d"
(mod (int (/ secs 3600)) 24)
(mod (int (/ secs 60)) 60)
(mod secs 60)))
(defn secs-elapsed-since-midnight []
(let [now (java.time.ZonedDateTime/now)
midnight (.truncatedTo now java.time.temporal.ChronoUnit/DAYS)
duration (java.time.Duration/between midnight now)]