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
(defmacro while-> | |
"Takes a predicate, expression, and forms. Threads expr | |
through each form for which applying pred to the returned | |
value is true. Threading short circuits after the first | |
false expression." | |
[pred expr & forms] | |
`(if (~pred ~expr) | |
~(if (not-empty forms) | |
(let [next-expr `(-> ~expr ~(first forms))] | |
`(if (~pred ~next-expr) |
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
;; cond-> | |
;; Takes an expression and a set of test/form pairs. Threads expr (via ->) | |
;; through each form for which the corresponding test | |
;; expression is true. Note that, unlike cond branching, cond-> threading does | |
;; not short circuit after the first true test expression. | |
(cond-> 5 | |
true inc | |
false (+ 100) | |
(= 2 2) (/ 2)) |
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
#(nth (conj (cycle [% % "Fizz" % "Buzz" "Fizz" % % % "Buzz" % "Fizz" % % "FizzBuzz"]) %) %) |
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
-- DEVELOP ( in staging ) | |
-- Doesn't join with beacon table | |
SELECT | |
COALESCE (SUM(results.sightings), | |
0) AS sightings | |
FROM | |
( SELECT | |
COUNT( raw_events_final.event_type = 'beacon_sighting' | |
OR NULL ) AS sightings |
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 str-join | |
([] nil) | |
(^String [^String x ^String y] | |
(if (and x y) (.. (new StringBuilder x) | |
(append "\n") | |
(append y) | |
toString) | |
(if x x | |
(if y y))))) |
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 flatten-keys* [a ks m] | |
(cond | |
(map? m) (reduce into (map (fn [[k v]] (flatten-keys* a (if-not (empty? ks) | |
(str ks "." (name k)) | |
(name k)) v)) (seq m))) | |
(and (sequential? m) | |
(not (instance? clojure.lang.MapEntry m))) (reduce into (map-indexed (fn [idx itm] (flatten-keys* a (str ks "[" idx "]") itm)) (seq m))) | |
:else (assoc a ks m))) | |
(defn flatten-keys [m] (flatten-keys* {} "" m)) |
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
REVEAL_ARCHIVE_IN_FINDER=true | |
FRAMEWORK_NAME="${PROJECT_NAME}" | |
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework" | |
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework" | |
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal" |
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
- (void)receivedBackgroundNotification:(NSDictionary *)notification fetchCompletionHandler:(void ( ^ ) ( UIBackgroundFetchResult result ))completionHandler { | |
// Recieved a pushed message, do we display to this user? | |
if ([self displayPushedMessage]){ | |
// Display message and record event | |
[self didRecieveNotification:notification displayedMessage:true]; | |
completionHandler() | |
} | |
else { | |
// Don't display message and record event | |
[self didRecieveNotification:notification displayedMessage: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
# Get all beacons for org = 3Pd9Ql1jJ7yttGQ9PQ5NFw | |
curl -X GET \ | |
-H "Authorization: Basic <<YOUR AUTH STRING HERE>>" \ | |
-H "Content-type: application/json" \ | |
-v \ | |
"https://entities.datasnap.io/v1.0/beacon?organization_id=3Pd9Ql1jJ7yttGQ9PQ5NFw" | |
# Get beacon with identifier = 1234-5679 | |
curl -X GET \ | |
-H "Authorization: Basic <<YOUR AUTH STRING HERE>>" \ |
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
// ************************************* | |
// FP | |
// ************************************* | |
var Dog = function() { | |
var weight = 15; | |
var age = 1; | |
return { | |
feed : function(amount){ | |
weight += amount; | |
}, |
OlderNewer