Skip to content

Instantly share code, notes, and snippets.

View superstructor's full-sized avatar
🎯
Focusing

Isaac Johnston superstructor

🎯
Focusing
View GitHub Profile
@jkrasnay
jkrasnay / re-frame-subs.adoc
Last active June 17, 2022 08:59
Re-frame Subscription Helpers

Re-frame Subscription Helpers

There are a couple of common problems with Re-frame subscriptions that I’d like to solve:

  1. Because subscriptions are registered via keywords, the ClojureScript compiler does nothing to help check that we haven’t made a typo when subscribing.

  2. We often need to use the same logic to access a value in the app DB in both a subscription and in events.

I’ve come up with the following structure. First we create the accessor function, which can be used by both the subscription and any events. (This of course implies that the namespace where we implement our events must refer to the namespace where we define our subscriptions.)

@athomasoriginal
athomasoriginal / reitit-routing.cljs
Created April 15, 2020 01:50
reitit routing clojurescript
(ns ^:figwheel-hooks reitit-routing
(:require
[reagent.core :as r]
[reagent.dom :as r.dom]
[reitit.frontend :as rf]
[reitit.frontend.easy :as rfe]
[reitit.coercion.spec :as rss]
[fipp.edn :as fedn]))
;; State
@saurabhnanda
saurabhnanda / tuning-postgres-zfs.md
Last active August 2, 2023 06:06
Tuning Postgres + ZFS

Tuning ZFS + Postgres to outperform EXT4 + Postgres

Please refer to ZFS 2-3x slower than EXT4 to see how ZFS defaults + Postgres defaults severely underperform EXT4 defaults + Postgres defaults (and also to know more about the system on which these benchmarks were performed). This page documents how to tune ZFS + Postgres to give better performance for the tpcb-like benchmark.

BIG FAT WARNING

Please do not copy these settings blindly because I am myself not clear on why/how these settings had the impact they did. For example, I cannot explain why full_page_writes=off independently did not give that much boost, nor did an optimized PG configuration. However, putting both of them together gave a 2-4x boost compared to baseline numbers.

Benchmark results

@PhilipSchmid
PhilipSchmid / ubuntu-1804-lacp-bonding.md
Last active January 31, 2023 20:48
Ubuntu 18.04 LACP Network Interface Bonding

Interface bonding

Configure a LACP active network interface bonding on Ubuntu 18.04 using netplan:

root@srv01:~# mv /etc/netplan/50-cloud-init.yaml /etc/netplan/01-netcfg.yaml
root@srv01:~# cat /etc/netplan/01-netcfg.yaml 
network:
    version: 2
    renderer: networkd
 ethernets:
@mort3za
mort3za / git-auto-sign-commits.sh
Last active January 30, 2024 10:31
Auto sign your git commits
# Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands)
gpg --gen-key
# maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null`
# check current keys:
gpg --list-secret-keys --keyid-format LONG
# See your gpg public key:
gpg --armor --export YOUR_KEY_ID
# YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333)
@conan
conan / url-gen.clj
Created October 4, 2017 14:13
Clojure.spec URL and email specs with generators
(require '[cemerick.url :as url]
'[clojure.spec.alpha :as s]
'[clojure.spec.gen.alpha :as gen]
'[clojure.string :as string])
(def non-empty-string-alphanumeric
"Generator for non-empty alphanumeric strings"
(gen/such-that #(not= "" %)
(gen/string-alphanumeric)))
@oznu
oznu / README.md
Last active November 22, 2023 19:49
QEMU + Ubuntu ARM aarch64

QEMU + Ubuntu ARM aarch64

These are the steps I used to get Ubuntu ARM aarch64 running with QEMU on OSX.

Get Ubuntu Image and QEMU EFI:

wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-arm64-uefi1.img
wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd
@pesterhazy
pesterhazy / reagent-ref-functions.clj
Last active January 19, 2023 11:31
Using ref functions with reagent
;; React supports "refs" as a way for a component to get a
;; handle to its children. Classically, refs were string-based.
;; Recent versions of React support callback attributes as a
;; more elegant variant of accessing DOM notes or components.
;;
;; This example uses a Form-3 component as per
;; https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components
;;
;; For callback refs, see React's documentation
;; https://facebook.github.io/react/docs/more-about-refs.html
@ghoseb
ghoseb / clj_spec_playground.clj
Last active March 30, 2019 22:35
Examples of Clojure's new clojure.spec library
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
@jbnunn
jbnunn / Gist
Last active April 6, 2021 16:38 — forked from kurokikaze/gist:350fe1713591641b3b42
Install Google Chrome from Powershell
$LocalTempDir = $env:TEMP; $ChromeInstaller = "ChromeInstaller.exe"; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', "$LocalTempDir\$ChromeInstaller"); & "$LocalTempDir\$ChromeInstaller" /silent /install; $Process2Monitor = "ChromeInstaller"; Do { $ProcessesFound = Get-Process | ?{$Process2Monitor -contains $_.Name} | Select-Object -ExpandProperty Name; If ($ProcessesFound) { "Still running: $($ProcessesFound -join ', ')" | Write-Host; Start-Sleep -Seconds 2 } else { rm "$LocalTempDir\$ChromeInstaller" -ErrorAction SilentlyContinue -Verbose } } Until (!$ProcessesFound)