Skip to content

Instantly share code, notes, and snippets.

View joshrotenberg's full-sized avatar
💀

josh rotenberg joshrotenberg

💀
View GitHub Profile
@danielsz
danielsz / polling.clj
Last active November 19, 2023 03:26
Polling endpoint with core.async
(ns clojure.polling
(:require [clj-http.client :as client]
[clojure.core.async :as async :refer [>!! timeout <! go-loop]]
[cheshire.core :as json]
[clojure.tools.logging :as log]))
(defn client
([endpoint]
(client/get endpoint))
([endpoint c e]
@yogthos
yogthos / README.md
Last active March 24, 2024 10:35
command line util for grabbing current weather for a city using OpenWeather API

usage

Create an account at https://openweathermap.org and get an API key. Note that it can take up to a couple of hours for the key to become active. Add an environment variable OPEN_WEATHER_API_KEY with the value of the key.

run the script:

./weather.clj Toronto,CA
@finalfantasia
finalfantasia / shadow_cljs_and_fireplace_vim_integration.md
Last active March 8, 2023 19:10
Shadow-CLJS and Fireplace.vim Integration
  1. Create an app following the official Shadow-CLJS Quick Start instructions.
  2. Modify shadow-cljs.edn
;; shadow-cljs configuration
{:source-paths
 ["src/dev"
  "src/main"
  "src/test"]

 ;; ADD - CIDER middleware for nREPL (required by fireplace.vim)
@cassiozen
cassiozen / pixelbook-dev-setup.md
Last active October 22, 2023 12:06 — forked from denolfe/pixelbook-linux-setup.md
Notes on setting up Pixelbook for development

Pixelbook Setup

Change your channel

Some of the features mentioned in this document only work on the beta or Dev channel. To change your channel:

  1. chrome://help in a browser window
  2. Click Detailed Build Information
  3. Change Channel
  4. Select Beta (Or Dev, if you're feeling adventurous)
@josdejong
josdejong / merge.kt
Last active October 24, 2023 09:30
Merge two data classes in Kotlin
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.primaryConstructor
/**
* Merge two data classes
*
* The resulting data class will contain:
* - all fields of `other` which are non null
* - the fields of `this` for the fields which are null in `other`
*
@cheungnj
cheungnj / script.sh
Last active March 6, 2024 02:35
Convert asciidoc to Github Flavored Markdown
# Adapted from https://tinyapps.org/blog/nix/201701240700_convert_asciidoc_to_markdown.html
# Using asciidoctor 1.5.6.1 and pandoc 2.0.0.1
# Install pandoc and asciidoctor
$ sudo apt install asciidoctor
$ sudo wget https://github.com/jgm/pandoc/releases/download/2.0.0.1/pandoc-2.0.0.1-1-amd64.deb
$ sudo dpkg -i pandoc-2.0.0.1-1-amd64.deb
# Convert asciidoc to docbook using asciidoctor
@teamon
teamon / box.ex
Created August 25, 2017 23:09
Define elixir structs with typespec with single line of code
defmodule Box do
defmacro __using__(_env) do
quote do
import Box
end
end
@doc """
Define module with struct and typespec, in single line
@jordanluyke
jordanluyke / multimap.ts
Last active June 13, 2023 14:16
TypeScript Multimap
export interface Multimap<K, V> {
clear(): void
containsKey(key: K): boolean
containsValue(value: V): boolean
containsEntry(key: K, value: V): boolean
delete(key: K, value?: V): boolean
entries: MultimapEntry<K, V>[]
get(key: K): V[]
keys(): K[]
put(key: K, value: V): MultimapEntry<K, V>[]
(ns background
(:require [clojure.tools.logging :as log])
(:import [java.util.concurrent]))
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool)))
(defn background
"Calls the fn passed in a thread from a thread pool, returning immediately.
Unlike future, background does not swallow exceptions."
[f]
@swankjesse
swankjesse / HostSelectionInterceptor.java
Last active July 20, 2023 19:01
This OkHttp application interceptor will replace the destination hostname in the request URL.
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
/** An interceptor that allows runtime changes to the URL hostname. */
public final class HostSelectionInterceptor implements Interceptor {
private volatile String host;