Skip to content

Instantly share code, notes, and snippets.

@lilactown
lilactown / promises.re
Last active August 20, 2022 07:56
Notes on using JavaScript Promises in ReasonML/BuckleScript
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@huberf
huberf / setup.md
Created May 18, 2017 15:47
Google Assistant Nomie Tracker

This setup uses the Nomie Pro API and IFTTT.

Steps

  1. First you will need to setup the Nomie Proxy service, located at https://github.com/huberf/nomieproxy. This is required because when asking Google 'log that I am angry', you will need to modify the keyword angry to equal the tracker, 'Angry' in my case.
  2. Next, go to IFTTT and create a new applet at the applet creation page.
  3. For the This field, select Google Assistant, and select the trigger Say a phrase with a text ingredient. Now create several phrases. I recommend *log that I just $` as one. Use the $ figure where you want to tracker name to be stated.
  4. After this, for the Then field, select Maker Webhook. Now you just need to put the following format in the URL field: https://YOUR_SERVER.herokuapp.com/PROXY_PASS/{{TextField}}. Replace, YOUR_SERVER and PROXY_PASS with the corresponding values.
  5. Now you just need to press Create and start logging via the Google Assistant.
@reborg
reborg / rich-already-answered-that.md
Last active May 8, 2024 14:20
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@cgrand
cgrand / core.cljc
Last active October 14, 2020 12:18
Mixing macros and code in cljc and supporting clj, cljs and self-hosted cljs, see https://github.com/cgrand/macrovich
;; SEE: https://github.com/cgrand/macrovich
;; macros and code in a single cljc working across clj, cljs and self-hosted cljs
;; require clojurescript from master
(ns foo.core
#?(:cljs (:require-macros
[net.cgrand.meta-macros :refer [macros no-macros]]
[foo.core :refer [add]])
:clj (:require
@swannodette
swannodette / inference.md
Last active August 7, 2023 16:13
Externs Inference

Externs Inference

Integrating third party JavaScript libraries not written with Google Closure Compiler in mind continues to both be a source of error for users when going to production, and significant vigilance and effort for the the broader community (CLJSJS libraries must provide up-to-date and accurate externs).

In truth writing externs is far simpler than most users imagine. You only need externs for the parts of the library you actually intend to use from ClojureScript. However this isn't so easy to determine from Closure's own documentation. Still in the process of writing your code it's easy to miss a case. In production you will see the much dreaded error that some mangled name does not exist. Fortunately it's possible to enable some compiler flags :pretty-print true :pseudo-names true to generate an advanced build with human readable names. However debugging missing externs means compiling your production build for each missed case. So much time wasted for such simple mistakes damages our sen

@idibidiart
idibidiart / GraphQL-Architecture.md
Last active September 16, 2023 18:36
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.

With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.

We use GraphQL to dyn

18.828427654877792 = 113176610252/6010943257
18.828427654877792 = 11644626562/618459851
18.828427654877792 = 1206388604803/64072721680
18.828427654877792 = 1351199027/71763774
18.828427654877792 = 1444300989908416/76708529059475
18.828427654877792 = 14697597531/780606740
18.828427654877792 = 1525114896090/81000650933
18.828427654877792 = 155558666430211/8261904248277
18.828427654877792 = 16070294714071/853512306425
18.828427654877792 = 17750568500/942753629
@currentoor
currentoor / reset_component.clj
Last active January 11, 2016 23:21
Reset the components of an entity without worrying about the current values or their entity-ids.
(defn reset-components [db eid attr new-comps]
(let [current-comps (-> (d/pull db [attr] eid) attr)
;; First we do a value based comparison ignoring component entity ids.
current-comp-vals (into #{} (map #(dissoc % :db/id) current-comps))
new-comp-vals (into #{} new-comps)
deletions (clojure.set/difference current-comp-vals new-comp-vals)
additions (clojure.set/difference new-comp-vals current-comp-vals)
@bartojs
bartojs / profile.boot
Created December 3, 2015 01:51
boot clj profile for fmt and lein tasks
(deftask fmt
"fmt file or dir using cljfmt (changes files)"
[f files VAL str "file(s) to format"]
(set-env! :dependencies '[[cljfmt "0.3.0"]])
(require 'cljfmt.core
'clojure.java.io)
(let [reformat-string (resolve 'cljfmt.core/reformat-string)
file (resolve 'clojure.java.io/file)
fmt-file (fn [f]
(println "formatting" (.getName f))