Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash -ex
REGION=$1
REGISTRY_URL=$2
IMAGE_NAMESPACE=$3
IMAGE_NAME=$4
CONTEXT=$5
if [ -f build.gradle ]; then
VERSION=$(cat build.gradle | grep "version =" | awk '{print $3}' | tr -d "[:space:']")
val store = HashMap<String, CacheEntry>()
fun <T> cache(period: Long, key: String, provider: () -> T): T {
val entry = store[key]
if (entry != null && entry.expires > System.currentTimeMillis()) {
return entry.data as T
}
val data = provider()
store[key] = CacheEntry(System.currentTimeMillis() + period, data as Any)
return data

Keybase proof

I hereby claim:

  • I am superafroman on github.
  • I am superafroman (https://keybase.io/superafroman) on keybase.
  • I have a public key ASC3VIsefzylwJ9szQB3cCp5a_vR6RDgaT1gbH-HIECslwo

To claim this, I am signing this object:

@superafroman
superafroman / queuing_store.js
Created December 21, 2011 17:04
Extension to SC.Store in SproutCore that automatically queues the next update if an entity is saved again before the original request is completed. If multiple updates are made to an entity the latest will be queued and all others ignored.
/*globals Extensions */
Extensions.QueueingStore = SC.Store.extend(
/** @scope Extensions.QueueingStore.prototype */ {
queue: {},
recordDidChange: function(recordType, id, storeKey, key, statusOnly) {
if (!storeKey) {
storeKey = recordType.storeKeyFor(id);