Skip to content

Instantly share code, notes, and snippets.

View joshrotenberg's full-sized avatar
🐢

josh rotenberg joshrotenberg

🐢
View GitHub Profile
(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 May 17, 2024 19:11
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;
@compressed
compressed / playground.rs
Created February 1, 2016 15:08 — forked from anonymous/playground.rs
rust: map + filter_map + Result examples
use std::collections::HashMap;
fn main() {
// println!("{:?}", go(&[1, 2, 3]));
// println!("{:?}", go(&[1, 3, 4, 5, 6]));
println!("go_while {:?}", go_while(&[1, 3, -4, 4, 5, 6]));
println!("go_filter_map {:?}", go_filter_map(&[1, 3, 4, -4, 5, 6]));
let mut hm = HashMap::new();
@reiz
reiz / gist:d67512deee814705134e
Created May 5, 2015 09:29
Vagrantfile for a Java dev. environment with Oracle Java 8 and Eclipse.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
module-template: ! 'module MODULE_NAME where
'
extensions: {}
environment: default
cabal-file: project.cabal
version: 1
ghc-args: []
excluded-modules: []
@john2x
john2x / 00_destructuring.md
Last active May 13, 2025 22:05
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

package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)
@rgarcia
rgarcia / basic.go
Created June 11, 2014 17:27
golang basic auth transport
import (
"encoding/base64"
"fmt"
"net/http"
)
type BasicAuthTransport struct {
Username string
Password string
}
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell