Skip to content

Instantly share code, notes, and snippets.

View chriswk's full-sized avatar
🖥️
coding @Unleash

Christopher Kolstad chriswk

🖥️
coding @Unleash
View GitHub Profile
export const tokenMiddleware = (tokenValidator: TokenValidator) => {
return async (req: Request, res: Response, next: NextFunction) => {
const apiToken = req.header('authorization');
if (!apiToken) {
return res
.status(401)
.send({ message: 'You must authenticate to use Unleash on the Edge' });
}
await tokenValidator.registerToken(apiToken);
@chriswk
chriswk / dynatrace-definition.ts
Created May 24, 2022 18:26
Dynatrace unleash addon
import {
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
FEATURE_STALE_ON,
FEATURE_STALE_OFF,
FEATURE_ENVIRONMENT_ENABLED,
FEATURE_ENVIRONMENT_DISABLED,
FEATURE_STRATEGY_REMOVE,
public class CustomVersionRangeStrategy implements Strategy {
@Override
public String getName() {
return "CustomVersionStrategy";
}
@Override
public boolean isEnabled(Map<String, String> parameters) {
return false;
}
@chriswk
chriswk / unleash-event.json
Last active November 17, 2021 10:58
Unleash schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://docs.getunleash.io/schema/event.schema.json",
"title": "Unleash Event",
"description": "...",
"type": "object",
"required": ["eventId", "eventType", "featureName", "context"],
"properties": {
"eventId": {
"type": "string",

Blackjack

Rules:

Two players: You and the Dealer

Deck

  • A deck is represented as a json list of Card objects.
  • Your application should accept an URL on the command line. You should do a GET against this URL. This will give you the deck we expect you to play the game with
  • The response will contain a json list of Card objects: {"suit":"HEARTS","value":"5"} , where suit is one of HEARTS | CLUBS | SPADES | DIAMONDS and value is one of the set 2,3,4,5,6,7,8,9,10,J,Q,K,A
id project environment strategy_name parameters constraints feature_name stale feature_type variants
70e1a60c-d891-49c3-8042-b88da112b14f default :global: 4days {"b2b": "true", "currentSubsription": "true"} [] 4dayscancel false operational []
2d42e3f1-2430-473f-aa74-4c39404c793b default :global: email {"email": "test@test.co.za"} [] 4dayscancel false operational []
2e54152e-c43e-4a46-9430-397f8fc7bae0 default :global: flexibleRollout {"groupId": "asadsad", "rollout": 72, "stickiness": "userId"} [{"values": ["asia"], "operator": "IN", "contextName": "region"}] asadsad false release []
9256d882-3147-414a-98f9-b01943422cfb default :global: default {} [] asdas false kill-switch []
9f804c9c-01b0-423e-93b6-a325628560be default :global: default {} NULL asdasd false operational [{"name":"123","wei

Bootstrap Unleash

We just released unleash-client-java 4.2.1. This version includes a new way to bootstrap Unleash using a JSON string matching the /api/client/features format.

First; update your Unleash dependency to 4.2.1

  • Maven
    <dependency>
        <groupId>no.finn.unleash</groupId>
        <artifactId>unleash-client-java</artifactId>
@chriswk
chriswk / Topbar.elm
Created July 8, 2016 11:04
Minimal example
module Topbar exposing (..)
import Http
import Task exposing (..)
type Msg =
NoOp
| Error Http.Error
| Success String
@chriswk
chriswk / Main.elm
Last active April 20, 2016 10:36
ZombieElm - Getting something on the page
module Main (..) where
import Signal exposing (Signal, map)
import Random exposing (Seed)
import Html exposing (..)
import Effects exposing (Effects, Never)
import Task
import Components.Zombie exposing (..)
import StartApp
import Random exposing (initialSeed)
publish {
dependsOn assemble
}
dependencyManagement {
imports {
mavenBom 'org.springframework:spring-framework-bom:4.2.4.RELEASE'
}
}