Skip to content

Instantly share code, notes, and snippets.

@hjertnes
hjertnes / doom.txt
Created Apr 6, 2018
Doom Emacs Cheatsheet
View doom.txt
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@bobrik
bobrik / README.md
Last active Jul 28, 2021
CFS hiccups
View README.md
@thomasdarimont
thomasdarimont / ConditionalOtpFormAuthenticator.java
Last active Oct 6, 2021
Keycloak Conditional OTP Step-by-Step
View ConditionalOtpFormAuthenticator.java
package org.keycloak.authentication.authenticators.browser;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.models.RoleModel;
import org.keycloak.models.UserModel;
import javax.ws.rs.core.MultivaluedMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@davegurnell
davegurnell / TypeclassDemo.scala
Created Oct 6, 2015
Example of the type class pattern in Scala
View TypeclassDemo.scala
object TypeclasseDemo {
// The parts of the type class pattern are:
//
// 1. the "type class" itself -- a trait with a single type parameter;
//
// 2. type class "instances" for each type we care about,
// each marked with the `implicit` keyword;
//
// 3. an "interface" to the type class -- one or more methods
@MLnick
MLnick / HyperLogLogStoreUDAF.scala
Last active Aug 25, 2021
Experimenting with Spark SQL UDAF - HyperLogLog UDAF for distinct counts, that stores the actual HLL for each row to allow further aggregation
View HyperLogLogStoreUDAF.scala
class HyperLogLogStoreUDAF extends UserDefinedAggregateFunction {
override def inputSchema = new StructType()
.add("stringInput", BinaryType)
override def update(buffer: MutableAggregationBuffer, input: Row) = {
// This input Row only has a single column storing the input value in String (or other Binary data).
// We only update the buffer when the input value is not null.
if (!input.isNullAt(0)) {
if (buffer.isNullAt(0)) {
@msgodf
msgodf / kiczales-oopsla94-black-boxes-reuse.md
Last active Dec 14, 2020
Gregor Kiczales "Why are black boxes so hard to reuse?"
View kiczales-oopsla94-black-boxes-reuse.md

This talk was given by Gregor Kiczales of Xerox PARC at OOPSLA ’94, 10/26/94. © 1994, University Video Communications. A transcript, with point- and-click retrieval of the slides, is available at http:/www.xerox.com/PARC/spl/eca/oi/gregor-invite/gregor- transcript.html

Why are black boxes so hard to reuse?

I think our field will go through a revolution. We will fundamentally change the way we think about and use abstraction in the engineering of software.

The goal of this talk is to summarize the need for and the basic nature of this abstraction framework.

The change is not new problems or new systems, but a new way of thinking about existing problems and existing systems.

@jneen
jneen / variant-multimethods.clj
Created Nov 22, 2014
Multimethods with variants
View variant-multimethods.clj
; it's a bit cumbersome to set up and there's the unfortunate need to ignore the tag
; in the individual methods, but this allows you to leave the interpretation of open
; variants, well, *open* for extension by multimethod.
; dispatch off the first argument, which will be the tag
(defmethod command-multi (fn [tag & data] tag))
; the first argument to the *method* is still the tag
(defmulti command-multi :print [_ val] (println val))
(defmulti command-multi :read [_ fname] (slurp fname))
@erasmas
erasmas / WriteToParquetExample.java
Last active Mar 29, 2017
Cascalog workflow to copy data from CSV to Parquet. How do I fix this so that schema fields are not prepended with '?' ?
View WriteToParquetExample.java
/**
* Same workflow but using Cascading, output fields in Parquet file are obviously fine and not prepended with '?'
*/
package cascading.sandbox;
import cascading.flow.Flow;
import cascading.flow.FlowDef;
import cascading.flow.hadoop.HadoopFlowConnector;
import cascading.pipe.Pipe;
import cascading.property.AppProps;
@john2x
john2x / 00_destructuring.md
Last active Oct 14, 2021
Clojure Destructuring Tutorial and Cheat Sheet
View 00_destructuring.md

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

View toggle_fn.applescript
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
tell application "System Events"
click checkbox 1 of tab group 1 of window 1 of application process "System Preferences"
end tell
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if