Skip to content

Instantly share code, notes, and snippets.

View aarkerio's full-sized avatar
🐵
Echando rostro en Ixtapa.

Manuel Montoya aarkerio

🐵
Echando rostro en Ixtapa.
View GitHub Profile
;; Clojure hiccup file
[:button {:class "btn btn-success" :onClick (str "zentaur.core.deletetest("id")")} "Löschen"]
;; file: src/cljs/zentaur/core.cljs
(ns zentaur.core
(:require [ajax.core :refer [GET POST DELETE]]))
(defn delete-test [test-id]
@aarkerio
aarkerio / gist:bb978c34c2f7b702530584293cf8db56
Last active December 20, 2019 21:19
Calling ClojureScript from Hiccup
;; Clojure hiccup file
[:button {:class "btn btn-success" :onClick (str "zentaur.core.deletetest("id")")} "Borrar resgistro"]
;; file: src/cljs/zentaur/core.cljs
(defn ^:export deletetest [test-id]
(when (js/confirm (str "Delete test?"))
(set! js/window.location.href (str "/admin/tests/deletetest/" test-id))))
(defn index-by-id
"Get index from a vector of maps using id field"
[v id]
(first (filter #(= (:id (v %)) id) (range (count v)))))
(defn flat?
"true if there is no sequences"
[seq]
(not-any? (fn [x] (isa? (type x) java.util.List)) seq))
(defn my-flatten
"Returns flat sequence"
[seq]
(if (isa? (type seq) java.util.List)
(if (flat? seq)
{
"Records": [
{
"eventSource": "aws:ses",
"eventVersion": "1.0",
"ses": {
"mail": {
"timestamp": "2019-03-27T21:58:29.360Z",
"source": "[email protected]",
"messageId": "ujuocr76opqg7nbrjanfj78792kvpcig4i8g6f81",
{"type":"charge.succeeded",
"event_date":"2019-03-06T12:54:01-06:00",
"transaction":{"id":"trnvybx9sdu6yfd3o4pn",
"authorization":"305180",
"operation_type":"in",
"method":"store",
"transaction_type":"charge",
"status":"completed",
"conciliated":false,
"creation_date":"2019-03-06T12:54:01-06:00",
yarn add -D git+ssh://[email protected]:aarkerio/graphql-api-types.git
@aarkerio
aarkerio / Curl upload file graphql
Created February 18, 2019 03:22
Curl upload file graphql Apollo lambda
curl localhost:3000/graphql \
-F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { filename } }" }' \
-F map='{ "0": ["variables.file"] }' -F 0=@/home/mmontoya/Bilder/mydog12.jpg
@aarkerio
aarkerio / Encode & decode strings Ruby
Last active November 7, 2018 19:55
Encode & decode strings Ruby
class RunLengthEncoding
def self.encode(input)
new_array = split_by_chars input
ordered = new_array.map do |el|
el.length > 1 ? "#{el.length}#{el.chr}" : el
end.join
end
def self.decode(input)
@aarkerio
aarkerio / edit_area.cljs
Last active October 22, 2018 19:17
Hide show ClojureScript reagent edit form
(defn question-item
[{:keys [question explanation hint key qtype id ordnen] :as q}]
(let [counter (reagent/atom 0)
editing (reagent/atom false)] ;; show and switch icons (Edit/Cancel)
(fn []
[:div.div-separator {:key (str "div-question-separator-" id) :id (str "div-question-separator-" id)}
(if @editing
[:img.img-float-right {:title "Cancel question"
:alt "Cancel question"
:key (str "cancel-question-img-" id)