Skip to content

Instantly share code, notes, and snippets.

View krisajenkins's full-sized avatar
💭
:: Geek

Kris Jenkins krisajenkins

💭
:: Geek
View GitHub Profile
@jarohen
jarohen / rafting.clj
Last active September 12, 2023 16:12
A quick hack at actually implementing the Raft algorithm to aid my learning - thanks @bbengfort and @krisajenkins for the podcast!
(ns rafting
(:require [clojure.tools.logging :as log])
(:import java.lang.AutoCloseable
(java.util.concurrent CompletableFuture Executors TimeUnit)))
(defn new-timeout-ms []
(+ (System/currentTimeMillis)
200
(rand-int 150)))
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
import Prelude hiding (log)
--------------------------------------------------------------------------------
-- The API for cloud files.
class Monad m => MonadCloud m where
saveFile :: Path -> Bytes -> m ()
@k0001
k0001 / hello.hs
Last active September 25, 2015 19:32
-- | Add a prefix and a suffix to a given monoid. Problem: which of the arguments is which?
surround :: (Monoid a) => a -> a -> a -> a
-- | Add a prefix and a suffix to a given monoid. No problem!
surround :: (Monoid a, prefix ~ a, suffix ~ a) => prefix -> suffix -> a -> a
@gfredericks
gfredericks / hiccup-type.clj
Created March 6, 2014 20:19
The core.typed description of hiccup data
(t/def-alias HTML-Atts (IPersistentMap t/Keyword String))
(t/def-alias HTML
(Rec [HTML]
(U String
nil
(HVec [t/Keyword (U HTML (t/Seq HTML)) *])
(HVec [t/Keyword HTML-Atts (U HTML (t/Seq HTML)) *]))))
package wlhn
import java.net.ServerSocket
import scala.io.BufferedSource
import java.io.PrintStream
import java.net.Socket
import java.net.InetAddress
import scala.collection.mutable.ArrayBuffer
/**
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: