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
@aarkerio
aarkerio / gist:5b9676f2b935fbea796581dc51db643a
Created August 31, 2018 20:48
Clojure: change value in map from string to boolean
(def answer {:answer "France" :correct "true" :age 11})
(update answer :correct #(if (= % "true") true false))
@aarkerio
aarkerio / ClojureScript Ajax POST
Last active August 27, 2018 21:10
ClojureScript Ajax POST
(defn set-message [response]
(.log js/console (str ">>> RESPONSE #####" response)))
(defn error-handler [response]
(.log js/console (str ">>> RESPONSE #####" response)))
(defn save-json []
(let [json (.-value (gdom/getElement "json-field"))
id (.-value (gdom/getElement "upload-id"))
csrf-field (.-value (gdom/getElement "__anti-forgery-token"))]
(:require [goog.dom :as gdom]
[goog.style :as style])
(defn my-toggle [element-str]
(let [div-message (gdom/getElement element-str)]
(style/showElement div-message (not (style/isElementShown div-message)))))
@aarkerio
aarkerio / appointments.jsx
Created October 21, 2015 21:23
React SyntaxError: unknown: Unexpected token
render: function() {
var trNodes = this.props.data.map(function (appointment) {
return (
<tr><td>{appointment.id}</td><td>{appointment.scheduled_time}</td><td>{appointment.pet_id}</td><td>Delete</td></tr>
);
});
var commentNodes = return (
<div className="commentBox">trNodes</div>
);
#
# I need to know if one product in the purchased "order_list" has an 'Event' product_type
# The models: order_list table belongs_to order_items and order_items belongs_to products
#
def has_event?(order_list)
order_list.order_items.each do |oi|
oi.product.each do |product|
return true if product.product_type == 'Event'
end
end
users = User.all
newall = users.map do |u|
u.attributes[:new_field] = Time.now
end