Skip to content

Instantly share code, notes, and snippets.

View xyhp915's full-sized avatar
😇
monadic life ...

Charlie xyhp915

😇
monadic life ...
View GitHub Profile
@xyhp915
xyhp915 / README.md
Created June 13, 2024 04:13 — forked from mfikes/README.md
eval in ClojureScript

ClojureScript master now has cljs.core/eval. This delegates to cljs.core/*eval* which, by default throws, but you can bind it to any implementation that can compile and evaluate ClojureScript forms.

If you require the cljs.js namespace (which is the main support namespace for self-hosted ClojureScript), then cljs.core/*eval* is set to an implementation that uses self-hosted ClojureScript for this capability. This means that all self-hosted ClojureScript environments will now have a first-class eval implementation that just works. For example, Planck master:

$ planck -q
cljs.user=> (eval '(+ 2 3))
5
@xyhp915
xyhp915 / gsync_adapters.md
Created December 21, 2023 05:34 — forked from dreamwhite/gsync_adapters.md
[Google Sync Adapters] How to sync them with microG

Mammamia Marcello what's this?

I know what you're thinking of while reading this gist, but I don't have much spare time to setup a Nextcloud server for syncing my contacts and my calendar This guide is intended for those users like me (lazy af) who wanna sync contacts and calendar with Google server, even if using microG.

Requirements

@xyhp915
xyhp915 / core_util.clj
Created June 19, 2023 04:13 — forked from shamsimam/core_util.clj
deselect-keys: Complement to clojure.core.select-keys
(ns core-util
(:require [clojure.set :as set]))
(defn deselect-keys
"Returns a map containing only those entries in map whose key is not in ks"
[m ks]
(->> (set/difference (set (keys m)) (set ks))
(select-keys m)))
@xyhp915
xyhp915 / viewer.html
Created March 1, 2023 05:22 — forked from larsneo/viewer.html
Pinch zoom implementation for PDF.js viewer
<!-- Goes into viewer.html just before ending </body> -->
<script>
let pinchZoomEnabled = false;
function enablePinchZoom(pdfViewer) {
let startX = 0, startY = 0;
let initialPinchDistance = 0;
let pinchScale = 1;
const viewer = document.getElementById("viewer");
const container = document.getElementById("viewerContainer");
const reset = () => { startX = startY = initialPinchDistance = 0; pinchScale = 1; };
@xyhp915
xyhp915 / actionlist.vim
Created February 8, 2023 05:12 — forked from zchee/actionlist.vim
IdeaVim actionlist
--- Actions ---
$Copy <M-C>
$Cut <M-X> <S-Del>
$Delete <Del> <BS> <M-BS>
$LRU
$Paste <M-V>
$Redo <M-S-Z> <A-S-BS>
$SearchWeb <A-S-G>
$SelectAll <M-A>
$Undo <M-Z>
@xyhp915
xyhp915 / 1) bb.edn
Created January 8, 2023 03:52 — forked from borkdude/1) bb.edn
Work bb.edn files
{:tasks {:requires ([babashka.fs :as fs])
:init (do (when (seq (fs/modified-since "deps.edn"
["deps.template.edn"
"../base/deps.edn"]))
(shell {:dir ".."} "script/gen-deps.clj")))
;; Maintenance tasks
install {:doc "Install frontend dependencies from NPM"
:task (shell "npm install")}
clean {:doc "Clean all artifacts"
@xyhp915
xyhp915 / gist:ad994a207e3d6216467ab394fd6607a8
Created June 9, 2022 03:52 — forked from d-t-w/gist:a239dfca4f57b7ff6f38c895b7f45405
Intellij Cursive+Cljfmt Editor CodeStyle
<code_scheme name="TW" version="173">
<ClojureCodeStyleSettings>{
:cljs.core/as-&gt; :only-indent
:cljs.core/assoc 0
:cljs.core/cond-&gt; :only-indent
:cljs.core/cond-&gt;&gt; :only-indent
:cljs.core/defonce :only-indent
:cljs.core/with-meta :only-indent
:cljs.core.async/go :only-indent
:cljs.core.async/go-loop :only-indent
@xyhp915
xyhp915 / Equity.md
Created May 6, 2021 04:21 — forked from isaacsanders/Equity.md
Joel Spolsky on Equity for Startups

This is a post by Joel Spolsky. The original post is linked at the bottom.

This is such a common question here and elsewhere that I will attempt to write the world's most canonical answer to this question. Hopefully in the future when someone on answers.onstartups asks how to split up the ownership of their new company, you can simply point to this answer.

The most important principle: Fairness, and the perception of fairness, is much more valuable than owning a large stake. Almost everything that can go wrong in a startup will go wrong, and one of the biggest things that can go wrong is huge, angry, shouting matches between the founders as to who worked harder, who owns more, whose idea was it anyway, etc. That is why I would always rather split a new company 50-50 with a friend than insist on owning 60% because "it was my idea," or because "I was more experienced" or anything else. Why? Because if I split the company 60-40, the company is going to fail when we argue ourselves to death. And if you ju

(conj collection item) adds item to collection. To do that, it needs to realize collection. (I'll explain why below.) So the recursive call happens immediately, rather than being deferred.

(cons item collection) creates a sequence which begins with item, followed by everything in collection. Significantly, it doesn't need to realize collection. So the recursive call will be deferred (because of using lazy-seq) until somebody tries to get the tail of the resulting sequence.

The following is how it works internally:

cons actually returns a clojure.lang.Cons object, which is what lazy sequences are made of. conj returns the same type of collection which you pass it (whether that is a list, vector, or whatever else). conj does this using a polymorphic Java method call on the collection itself. (See line 524 of clojure/src/jvm/clojure/lang/RT.java.)

What happens w

@xyhp915
xyhp915 / tree-seq-extra.clj
Created January 24, 2021 08:29 — forked from stathissideris/tree-seq-extra.clj
Like Clojure's tree-seq, but with depth info for each node or the full path (recursive - blow up the stack for deep trees)
(defn tree-seq-depth
"Returns a lazy sequence of vectors of the nodes in a tree and their
depth as [node depth], via a depth-first walk. branch? must be a fn
of one arg that returns true if passed a node that can have
children (but may not). children must be a fn of one arg that
returns a sequence of the children. Will only be called on nodes for
which branch? returns true. Root is the root node of the tree."
[branch? children root]
(let [walk (fn walk [depth node]
(lazy-seq