Skip to content

Instantly share code, notes, and snippets.

View zetafish's full-sized avatar

Endymion Kasanardjo zetafish

  • Eindhoven, Netherlands
View GitHub Profile
SKU price price image title brand
[
{"sku": "001", "title": "appl", "price": 10},
{"sku": "002", "title": "orange", "price": 7}
]
### Keybase proof
I hereby claim:
* I am zetafish on github.
* I am zetafish (https://keybase.io/zetafish) on keybase.
* I have a public key ASDMpVAmV-mm1ihBe45NeLO0WNLO44EiTUFQaADfNOwRCQo
To claim this, I am signing this object:
[{"name": "Mazzel", "kind": "dog"},
{"name": "Shanti", "kind": "cat"}]
@zetafish
zetafish / core.clj
Last active March 12, 2020 12:45
Implement default credentials provider that supports AWS_WEB_IDENTITY_TOKEN for use with cognitect's aws libs.
(ns zetafish.aws.credentials
(:require [clojure.java.io :as io]
[clojure.tools.logging :as log]
[cognitect.aws.client.api :as aws]
[cognitect.aws.credentials :as credentials]))
(defn- web-identity-token-credentials-provider
"Returns credentials from AWS_WEB_IDENTITY_TOKEN_FILE. See also:
https://github.com/cognitect-labs/aws-api/blob/master/examples/assume_role_example.clj
def validate_placeholder_refs(tree):
allowed = set([k for (k, v) in tree['template-set.json']['placeholders'].items()])
def check_refs(placeholder):
for k, v in placeholder.items():
if not k in allowed:
raise Invalid('no-such-placeholder', path=[k])
return placeholder
from abc import ABCMeta, abstractmethod
from collections import defaultdict
import json
import functools
class Validator(object):
__metaclass__ = ABCMeta
@abstractmethod
@zetafish
zetafish / locale-example.clj
Created July 5, 2017 12:53
Locale Example
(ns core
(:import (java.util Locale
Locale$Category
Locale$LanguageRange)))
(def configured-languages
[(Locale. "en") (Locale. "nl") (Locale. "en" "US") (Locale. "fil")])
(def accept-languages
(Locale$LanguageRange/parse "fil,nl;q=0.8,en-GB;q=0.6,en;q=0.4,en-US;q=0.2"))

Assignment

You are going to write a simple webserver that remembers how many times an endpoint is called.

Step 1

Create a simple webserver that responds to '/' by returning hello world. I.e.

$ curl http://localhost:5000/