Skip to content

Instantly share code, notes, and snippets.

geraldodev

Block or report user

Report or block geraldodev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View launch-reply.clj
(ns launch-reply.core
(:require
[clojure.java.io :as io]
)
(:import
[java.nio.file WatchService StandardWatchEventKinds FileSystems Path Paths]
[java.io File]
)
)
@geraldodev
geraldodev / InsertionPoint.re
Created Apr 25, 2018
Implementation in reason of https://material-ui-next.com/customization/css-in-js/#other-html-element to allow creation of <noscript id="jss-insertion-point> for injecting material-ui at the start of the index.html and let others libraries css taking precedence over material-ui 's
View InsertionPoint.re
type jssObj = {
.
"options": {. [@bs.set] "insertionPoint": Dom.element},
};
[@bs.module "jss"] external createJss : {.} => jssObj = "create";
[@bs.module "material-ui/styles"]
external jssPreset : unit => {.} = "jssPreset";
@geraldodev
geraldodev / JssProvider.re
Last active Apr 25, 2018
Bare translation of the bits I needed from react-jss/lib/JssProvider just to integrate with bs-material-ui
View JssProvider.re
[@bs.module "react-jss/lib/JssProvider"]
external myJssProvider : ReasonReact.reactClass = "default";
let make = (~jss: InsertionPoint.jssObj, ~generateClassName: string, children)=>
ReasonReact.wrapJsForReason(
~reactClass=myJssProvider,
~props={ "jss": jss, "generateClassName": generateClassName},
children,
);
View Breakpoints.re
type breakpoint = [ | `lg | `md | `sm | `xl | `xs ];
type breakpointsObj = {
.
"keys": array(string),
"values": {
.
"lg": int,
"md": int,
"sm": int,
View reason on vim
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'reasonml-editor/vim-reason-plus'
let g:LanguageClient_serverCommands = {
\ 'reason': ['ocaml-language-server', '--stdio'],
\ 'ocaml': ['ocaml-language-server', '--stdio'],
\ }
" Automatically start language servers.
let g:LanguageClient_autoStart = 1
@geraldodev
geraldodev / escutar_atom.clj
Last active Oct 27, 2016
Escutando atom, pra capturar a transição :is-open de false para true. Observe que na linha 5 eu uso a desestruturação de mapa sem keys, porque quero fazer com que :is-open do estado anterior fique na variável was-open. A linha 6 já captura o is-open atual
View escutar_atom.clj
(add-watch state-atom :watch
(fn [k
r
{was-open :is-open}
{:keys [is-open input-value]}]
(cond
(and
(not was-open)
is-open
@geraldodev
geraldodev / comp_transducer.clj
Last active Oct 21, 2016
mostra exemplo de comp e sua ordem de execução da direita pra esquerda. E a diferença da ordem de execução quando usamos transducer
View comp_transducer.clj
;; observe que funciona (ordem direita pra esquerda
;; (str (inc 2)) faz sentido né
((comp str inc) 2)
;; porque nao funciona
((comp inc str) 2)
;; rode este pro debaixo ser possível
(def options-map {
"3" {:code "3" :label "tres"}
@geraldodev
geraldodev / boxed_exceptioninfo.clj
Created Sep 6, 2016
It's annoying that exceptions created with ex-info are boxed inside another ex-info, because we need to use guard to capture our ex-info data. Imho (very humble), since core-match is called on ex-data it is data already, a simple map. When catching the exception pedestal could check if it is a ex-info and merge its keys with its data, qualified …
View boxed_exceptioninfo.clj
(def service-error-handler
(error-int/error-dispatch [ctx ex]
[({:exception-type :clojure.lang.ExceptionInfo}
:guard #(= (:type (ex-data (:exception %))) :guts.core/validation-failed))
](do
(pprint (ex-data ex))
(assoc ctx :response {:status 400
:body (:errors (ex-data ex))}))
;; If we don't match, forward it on
:else
View filteroptions.cljs
(defn filter-options
[{:keys [options filter-fn value-key] :as props} filter-value exclude-options]
{:pre [(ifn? value-key)
(or (vector? exclude-options) (nil? exclude-options))]}
(let [exclude-options (if (vector? exclude-options)
(set exclude-options)
#{})]
(cond
(empty? filter-value)
options
View get-in-link.clj
You can’t perform that action at this time.