Skip to content

Instantly share code, notes, and snippets.

@MrFunctor
MrFunctor / tsconfig.json
Created November 19, 2023 16:16
tsconfig.json with common fp-ts namespace imports configured with @unsplash/ts-namespace-import-plugin
{
"compilerOptions": {
"plugins": [
{
"name": "@unsplash/ts-namespace-import-plugin",
"namespaces": {
"A": {
"importPath": "fp-ts/Array"
},
"B": {
@mhuebert
mhuebert / _doc.md
Last active October 19, 2023 06:09
clj(s) environment config w/ Shadow-CLJS using a build hook

Objectives/approach

  • Load config conditionally, based on a release flag passed in at the command line. We use juxt/aero to read a static config.edn file, passing in the release flag as aero's :profile.
  • Config should be exposed at runtime (in the browser / cljs) and macro-expansion time (clj). We store config in a plain map, app.env/config. Our build hook, app.build/load-env, updates this using alter-var-root!.
  • Whenever config has changed, shadow-cljs must invalidate its caches so that changes are picked up immediately. We do this in app.build/load-env by putting the current environment in the shadow build state, under [:compiler-options :external-config ::env].

Why this approach?

  • Reading config directly from macros breaks compiler caching - changing config will not cause changes to propagate to the build.
  • :clojure-defines (ie. goog-define) are not exposed in clj, & therefore can't be used by macros. We want one single way to expose config that
@itod
itod / split_keyboards.md
Last active November 14, 2024 19:07
Every "split" mechanical keyboard currently being sold that I know of
@Zenexer
Zenexer / Internet Slang and Emoticons.md
Last active February 14, 2022 23:32
Internet slang, abbreviations, and emoticons
@john2x
john2x / 00_destructuring.md
Last active August 23, 2024 07:45
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@sebastianseilund
sebastianseilund / merged_array.js
Last active December 20, 2015 07:58
An implementation of a merged array in Ember.js that combines items from multiple source arrays so you can easily list them together in your Handlebars templates. Read the blog post at the [Billy's Billing Developer Blog](http://dev.billysbilling.com/blog/How-to-merge-multiple-data-sources-into-one-array-in-Ember-js)
/**
* `Ember.MergedArray` is an array that observes multiple other arrays (called source arrays) for changes and includes
* all items from all source arrays in an efficient way.
*
* Usage:
*
* ```javascript
* var obj = Ember.Object.create({
* people: [
* {
@rkh
rkh / chat.rb
Created December 14, 2011 12:55
Simple Chat Application using the Sinatra Streaming API
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
end
get '/stream', provides: 'text/event-stream' do