Skip to content

Instantly share code, notes, and snippets.

@jpthomson
jpthomson / simple_pull.clj
Created May 6, 2019 19:35
Simple pull implementation
(defn parse
([q] (parse q {}))
([q m]
(cond (list? q) (parse (first q) (assoc m :params (apply hash-map (rest q))))
(map? q) (apply merge m (map parse (first q)))
(vector? q) (assoc m :children (mapv parse q))
:else (assoc m :dispatch-key q))))
(defn resolve-value [env {:keys [dispatch-key] :as ast} value]
(if-let [f (get-in env [:resolvers dispatch-key])]
@josemarluedke
josemarluedke / from-introspection-schema-result-to-graphql-sdl.js
Created April 3, 2019 14:31
Generate a SDL graphql string from a introspection schema result
const { buildClientSchema, printSchema } = require('graphql');
const fs = require('fs');
const introspectionSchemaResult = JSON.parse(
fs.readFileSync('./graphql.schema.json')
);
const graphqlSchemaObj = buildClientSchema(introspectionSchemaResult);
const sdlString = printSchema(graphqlSchemaObj);
@okutbay
okutbay / free_email_provider_domains.txt
Last active May 29, 2024 09:25 — forked from tbrianjones/free_email_provider_domains.txt
Most complete list of free email provider domains. Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created. I also created a service for it https://emailprovider.yonetic.im/ and use this list in my free link shortener service ht…
This file has been truncated, but you can view the full file.
0-00.usa.cc
0-180.com
0-30-24.com
0-420.com
0-900.com
0-aa.com
0-mail.com
0-z.xyz
0.pl
00.pe
@mhuebert
mhuebert / Readme.md
Last active March 1, 2024 16:55
material-ui's CSS-in-JS with Reagent. (see https://material-ui.com/customization/css-in-js/)

material-ui allows for customizing CSS via a higher-order component called withStyles. Like many higher-order components which expect render props, the purpose of withStyles is to accept some parameters, and then introduce a new variable into the scope of the component tree.

One succinct and simple way to translate the concept of scope into Clojure is via a custom let macro. Usage of such a macro is demonstrated here:

(:require [material-ui.styles :as m])

(m/let [{:keys [leftPad]} {:leftPad 
                           {:paddingLeft 8}}]
 ;; `leftPad` is now the _className_ associated with {:paddingLeft 8} 
;; Copyright (c) Cognitect, Inc.
;; All rights reserved.
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
@saralilyb
saralilyb / make-iso8601-timestamp.clj
Created February 4, 2018 23:27
makes an iso8601 timestamp using JUST CLOJURE WITHOUT SEVEN THOUSAND LIBRARIES COME ON KIDS LEARN HOW TO USE WHAT YOU HAVE
(defn maketimestamp
"makes iso8601 timestamp manually
(works pre java 8)
from https://stackoverflow.com/questions/3914404/how-to-get-current-moment-in-iso-8601-format-with-date-hour-and-minute"
[]
(let [tz (java.util.TimeZone/getTimeZone "UTC")
df (new java.text.SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss'Z'")]
(.setTimeZone df tz)
(.format df (new java.util.Date))))
(require '[clojure.set :as set])
(def info
[{:year 2017
:month 4
:data "x"}
{:year 2017
:month 4
:data "y"}
@favila
favila / datomic-counter.clj
Created September 29, 2017 16:23
Demonstrate the creation and use of an auto-increment counter (with nonce) in datomic
(require '[datomic.api :as d])
(d/create-database "datomic:mem://counter-example")
;=> true
(def c (d/connect "datomic:mem://counter-example"))
;=> #'user/c
;; The essential features of creating and using an auto-increment counter in datomic:
;;
;; 1. A counter entity must store the current value and a nonce.
@rygorous
rygorous / gist:573d91d5b550652511227fff04b0a6d7
Created May 3, 2017 21:04
Unicode! (look at this in a hex editor or otherwise look at the code points)
Google Docs
Goоgle Docs
Gооgle Dоcs
Gоogle Dоcs
Gоοglе Doсѕ
@favila
favila / component-reachable.clj
Created April 17, 2017 15:21
Datomic rule to get all datoms for an entity and for all entities reachable via forward is-component attributes
'[[(component-reachable [?se] ?e ?a ?v ?tx)
[(identity ?se) ?e]
[?e ?a ?v ?tx]]
[(component-reachable [?se] ?e ?a ?v ?tx)
[?se ?sa ?sv ?tx]
[?sa :db/isComponent true]
[?sa :db/valueType ?type]
[?type :db/ident :db.type/ref]
(component-reachable ?sv ?e ?a ?v ?tx)]]