Skip to content

Instantly share code, notes, and snippets.

@rlander
rlander / dev_server.clj
Created January 21, 2023 00:08 — forked from ian-moore/dev_server.clj
shadow-cljs dev http server with conditional proxy requests
(ns my-shadow-app.dev-server
(:require [clj-http.client :as client]
[clojure.string :as string]
[shadow.http.push-state :as push-state])
(:import [org.apache.http NoHttpResponseException]))
(defn handler
[{:keys [uri http-config body headers request-method] :as request}]
(if-not (string/starts-with? uri "/api")
(push-state/handle request)

For example, to override the AppBar (https://material-ui-next.com/api/app-bar/) root class we can do the following:

First method (override Material UI classnames):

1 - Add the property classes in the AppBar component:

    <AppBar classes={{root: 'my-root-class'}}
@rlander
rlander / main.clj
Created April 6, 2022 13:26 — forked from mtnygard/main.clj
Use macros to make nested try/catch with values less of an eyesore.
(defn -main
[& args]
(let [file (try-> args
parse-args
(:! clojure.lang.ExceptionInfo ei (fe/print-other-exception ei))
:filename)]
(when (and file (not= ::try/exit file))
(try-> file
fern/load-from-file
(:! java.io.FileNotFoundException fnfe (fe/print-error-message (str "File not found: " (pr-str (.getMessage fnfe)))))
@rlander
rlander / gist:a1d18e6ec693736fddd25ab3f1fb91b7
Created May 11, 2021 21:36 — forked from JLarky/gist:3849736
erlang ultimate debug macro
% use like ?DEBUG_CALL({simple_test, Status, get_value(X)}).
% or even 2 = ?DEBUG_CALL(if true -> 1+1 end).
-define(DEBUG_CALL(Args), (fun() -> DEBUG_CALL = (Args), error_logger:info_msg("~w:~w -> ~s:~n ~150p~n", [?MODULE, ?LINE, ??Args, DEBUG_CALL]), DEBUG_CALL end)()).
@rlander
rlander / hoplon-forex.clj
Created February 11, 2020 15:07
Hoplon Forex
(page "index.html"
(:require [ajax.core :refer [GET POST]]))
(def url "http://127.0.0.1:4567/currencies")
(def currencies (cell []))
(def from (cell "USD"))
(def to (cell "USD"))
(def result (cell nil))
(GET url
@rlander
rlander / tlp
Created October 3, 2019 00:53 — forked from pauloromeira/tlp
My TLP config file (/etc/default/tlp) for ThinkPad
# ------------------------------------------------------------------------------
# tlp - Parameters for power saving
# See full explanation: http://linrunner.de/en/tlp/docs/tlp-configuration.html
# dir: /etc/default/tlp
# Hint: some features are disabled by default, remove the leading # to enable
# them.
# Set to 0 to disable, 1 to enable TLP.
(ns myapi.interceptors)
(def user-auth
{:before (fn [context]
(update-in context :password h/encrypt-password))
:after (fn [context]
(dissoc context [:password]))})
(def interceptors [user-auth])
@rlander
rlander / .circle.yml
Created July 4, 2019 03:48 — forked from lukaszkorecki/.circle.yml
How to setup code coverage for Clojure + Cloverage + CircleCI + CodeClimate
version: 2
jobs:
build:
docker:
- image: circleci/clojure:lein-2.7.1
environment:
- CC_TEST_REPORTER_ID=....set in project settings....
steps:
@rlander
rlander / timetop.erl
Created February 27, 2018 18:19 — forked from stolen/timetop.erl
top processes by scheduled time
-module(timetop).
-export([top/2]).
top(Duration, Count) ->
OldPrio = erlang:process_flag(priority, high),
Result = scheduled_time_top(Duration),
erlang:process_flag(priority, OldPrio),
lists:sublist(Result, Count).
@rlander
rlander / 01-presentation.md
Created October 5, 2017 17:12 — forked from janko/01-presentation.md
PostgreSQL full-text search capabilites (my presentation from our local Ruby meetup)

Full-text search

  • Keywords

  • Typos

  • Stemming

  • Stopword ignore