Skip to content

Instantly share code, notes, and snippets.

@paulp
paulp / kMDItemWhereFroms.sh
Created May 9, 2015 17:19
Exploit extended file attributes to figure out where some downloads came from.
#!/usr/bin/env bash
#
for file in "$@"; do
attr="$(xattr -p com.apple.metadata:kMDItemWhereFroms "$file" 2>/dev/null)"
url () {
echo "$attr" | xxd -r -p | plutil -convert xml1 -o - - | \
ack --output='$1' '(?:<string>)(.+?)</string>' | head -n1
}
@viktorklang
viktorklang / Gistard.scala
Last active June 9, 2017 07:27
Gistard — an sbt autoplugin for depending on Gists — such as Gistard itself
/*
Copyright 2015 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
nREPL server started on port 64499 on host 127.0.0.1 - nrepl://127.0.0.1:64499
REPL-y 0.3.1
Clojure 1.7.0-alpha6
Reflection warning, /tmp/form-init8946539659736038022.clj:1:1389 - reference to field ns can't be resolved.
Reflection warning, /tmp/form-init8946539659736038022.clj:1:3631 - reference to field name can't be resolved.
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
@tbroyer
tbroyer / OkHttpClientEngine.java
Last active May 31, 2022 07:19
Use OkHttp as JAX-RS Client implementation with RESTEasy
/*
* Copyright 2015 Thomas Broyer
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Luzifer
Luzifer / README.md
Last active August 25, 2019 12:34
Strategies for persistent data storage on CoreOS-cluster

Persistent data storage on CoreOS-cluster

Storing the data on the host machine

Data directories are created in /home/coreos and mounted into the container using volume cli options of docker run. All data the container writes is stored on the host and as long as the host persists safe against container restarts / recreates.

  • Pro
    • No effort, just create the directories and mount them into the container
  • Contra
  • Container is bound to host (unable to failover)
@paulirish
paulirish / readme.md
Last active April 2, 2024 20:18
resolving the proper location and line number through a console.log wrapper

console.log wrap resolving for your wrapped console logs

I've heard this before:

What I really get frustrated by is that I cannot wrap console.* and preserve line numbers

We enabled this in Chrome DevTools via blackboxing a bit ago.

If you blackbox the script file the contains the console log wrapper, the script location shown in the console will be corrected to the original source file and line number. Click, and the full source is looking longingly into your eyes.

@tonyg
tonyg / fusion-caselambda.rkt
Created January 24, 2015 22:28
Experiments with fusable streams and transducers in Racket
#lang racket
;; Fusable Streams, after Coutts, Leshchinskiy and Stewart 2007.
;; Haskell:
;; data Stream a where Stream :: (s -> Step s a) -> s -> Stream a
;; data Step s a = Yield a s | Skip s | Done
;; Clojure transducers support:
;; - early termination
;; - completion cleanup
@tonyg
tonyg / monad.rkt
Last active March 30, 2024 09:05
Monads in Racket
#lang racket/base
;; Monads in Racket, including polymorphic bind, return and fail.
;; Haskell-like do-notation.
(provide define-monad-class
(struct-out monad-class)
monad?
gen:monad
monad->monad-class
determine-monad
@diversit
diversit / mockito-optional-empty-returns.java
Last active August 29, 2015 14:10
Mockito: return default Optional.empty for unstubbed methods
public static final Answer DEFAULT_OPTIONAL_EMPTY_ANSWER = invocation ->
invocation.getMethod().getReturnType() == Optional.class ? Optional.empty() : null;
Mockito.mock(YourClassWithOptionalReturnValues.class, DEFAULT_OPTIONAL_EMPTY_ANSWER);
// unfortunately this does not work since Mockito's Answers enum is not extendable (yet, issue 345)
@Mock(answer = DEFAULT_OPTIONAL_EMPTY_ANSWER)
private YourClassWithOptionalReturnValues mockInstance;
(ns interop.core
(:require [cljs.nodejs :as nodejs]))
(nodejs/enable-util-print!)
(def Immutable (js/require "immutable"))
(extend-type Immutable.List
ISeqable
(-seq [coll]