I hereby claim:
- I am samn on github.
- I am samn (https://keybase.io/samn) on keybase.
- I have a public key ASCxXfhjXadKKe-hABsbXWeL-2pIT9cqWPyzCYyj3hVXhQo
To claim this, I am signing this object:
# This script uses the output from fetch-favs-json.rb | |
# (json files with data about posts you've liked) to download | |
# images and videos for these posts. It also constructs JSON objects | |
# formatted to be used in your archive downloaded from vine. | |
# This data will be written to posts.json | |
# Look for window.VINE_DATA in index.html from your vine archive and | |
# replace the value for the "posts" key with the data in posts.json | |
# You'll then be able to browse your favorites in a convenient web interface. | |
# Set this to false to only generate posts.json |
I hereby claim:
To claim this, I am signing this object:
(defn wait-for-persistence | |
"Dereferences and waits on the value of persistence-lock-atom, | |
if the value is dereferenceble & returns the dereferenced value. | |
Otherwise returns nil." | |
[persistence-lock-atom] | |
(when (instance? clojure.lang.IDeref @persistence-lock-atom) | |
;; This could deref with a timeout by using `deref` instead of `@` | |
@@persistence-lock-atom)) | |
(defn persist! |
(def fetch-set (ref (hash-set))) | |
(def resource-map (ref {})) | |
(defn fetch-resource | |
[resource-key] | |
;; perform some expensive operation that returns a value | |
) | |
(defn request-fetch | |
"Requests an asynchronous fetch of some resource." |
(ns media-dog | |
(:require [twitter.oauth :as oauth] | |
[twitter.callbacks.handlers :as handlers] | |
[twitter.api.streaming :as streaming] | |
[cheshire.core :as json]) | |
(:import (twitter.callbacks.protocols AsyncStreamingCallback))) | |
(def creds (oauth/make-oauth-creds | |
; consumer key | |
"CDdirssorFxBYmWWQmM1xw" |
#_( | |
Let's say you have a threadpool doing work that requires access to some shared resource. | |
And this resource needs to be refreshed at times. E.g. an OAuth bearer token that can expire or be revoked. | |
If this resource were expensive to refresh, or subject to rate limiting (OAuth tokens are often both) | |
then it's desirable to refresh as little as possible. | |
It's undesirable, however, to mix complicated synchronization code for updating the resource in | |
with the business logic consuming it. | |
Enter the lock less monster, a lock free method for coordinating updates to a shared reference. |