Skip to content

Instantly share code, notes, and snippets.

View quan-nh's full-sized avatar
🌗
.

Quân quan-nh

🌗
.
View GitHub Profile
@yogthos
yogthos / clojure-beginner.md
Last active July 15, 2024 20:45
Clojure beginner resources

Introductory resources

@mtnygard
mtnygard / responses.clj
Last active July 16, 2019 20:16
Build Pedestal response maps for every standard HTTP status code.
(defn response
([status body]
{:status status
:headers {}
:body body}))
(defmacro http-status [code sym]
`(def ~sym (partial response ~code)))
(defmacro http-statuses [& pairs]
@ghadishayban
ghadishayban / aproto3.ebnf
Last active August 7, 2020 04:00
instaparse is a super power
proto = <syntax> { import | package | option | message | enum | service | emptyStatement } <ws>
(* Header *)
syntax = ws "syntax" ws "=" ws ( "'proto3'" | '"proto3"' ) ws ";"
import = <ws "import" ws> [ "weak" | "public" ] <ws> strLit <ws ";">
package = <ws "package" ws> fullIdent <ws ";">
option = <ws "option" ws> optionName <ws "=" ws > constant <ws ";">
@toomasv
toomasv / incrementors.red
Created June 12, 2018 12:09
Some incrementation funcs
Red [
Original-idea: "Dave Andersen"
Source: https://gitter.im/red/red?at=5a2a4fb9a2be46682876463d
]
inc: func ['val][set val (get val) + 1]
dec: func ['val][set val (get val) - 1]
incr: func ['val step][set val (get val) + step]
decr: func ['val step][set val (get val) - step]
++: make op! :incr
--: make op! :decr
@mfikes
mfikes / README.md
Last active March 8, 2019 12:11
cljs.main rebel-readline

Start cljs.main with rebel-readline:

clojure -Sdeps '{:deps {github-mfikes/cljs-main-rebel-readline {:git/url "https://gist.github.com/mfikes/9f13a8e3766d51dcacd352ad9e7b3d1f" :sha "27b82ef4b86a70afdc1a2eea3f53ed1562575519"}}}' -i @setup.clj -m cljs.main
@bhb
bhb / README.md
Last active May 15, 2023 01:28
Clojure friendly mode, inspired by https://github.com/slipset/friendly
@bhauman
bhauman / figwheel-simple.cljc
Last active July 4, 2019 14:14
simple figwheel
(ns figwheel.simple
(:require
[clojure.string :as string]
#?@(:cljs [[goog.object :as gobj]])
#?@(:clj [[clojure.walk :as walk]
[cljs.repl.browser :as brow]
[cljs.repl :as repl]
[cljs.env :as env]
[cljs.analyzer :as ana]
[cljs.build.api :as bapi]
@toomasv
toomasv / clock.red
Last active February 6, 2020 09:22
Nostalgic pendulum clock
Red []
system/view/auto-sync?: off
pos: 145x143
nums: does [collect [
repeat i 12 [keep compose [
text (as-pair
(cosine i * 30 - 91) * 50 + (pos/x)
(sine i * 30 - 91) * 50 + (pos/y))
(to-string i)
]]]]
@toomasv
toomasv / graph.red
Last active July 11, 2018 02:22
Toy graph DSL
Red [
Author: "Toomas Vooglaid"
Date: 2017-12-31
History: [
2017-12-28 {First draft}
2018-01-20 {Added arrows, subtree moving, elementary interactive editing}
2018-01-24 {Edges formatting}
2018-02-01 {Added differnt edge-ends, layout orientations, improved options-handling}
2018-02-03 {Implemented stepped (orthogonal) edges, improved star layout}
2018-02-06 {Added directions `across` (default: perpendicular to the step-away direction) and `away` (in the step-away direction).
@int128
int128 / RequestAndResponseLoggingFilter.java
Last active January 13, 2024 10:46
Spring Web filter for logging request and response
/*
Copyright 2017 Hidetake Iwata
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