This file contains 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
users = User.all | |
newall = users.map do |u| | |
u.attributes[:new_field] = Time.now | |
end |
This file contains 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
# | |
# 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 |
This file contains 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
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> | |
); |
This file contains 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
(: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))))) |
This file contains 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
(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"))] |
This file contains 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 answer {:answer "France" :correct "true" :age 11}) | |
(update answer :correct #(if (= % "true") true false)) |
This file contains 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
(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) |
This file contains 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
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) |
This file contains 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
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 | |
This file contains 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
yarn add -D git+ssh://git@github.com:aarkerio/graphql-api-types.git |
OlderNewer