Skip to content

Instantly share code, notes, and snippets.

View thomaspoignant's full-sized avatar

Thomas Poignant thomaspoignant

View GitHub Profile
var cache map[string]interface{}
func main() {
ticker = time.NewTicker(3 * time.Second)
defer ticker.Stop() // stop the ticker
updaterChan = make(chan struct{})
defer close(updaterChan) // close the channel
// ...
ticker = time.NewTicker(3 * time.Second)
defer ticker.Stop() // stop the ticker
//...
case <- ticker.C:
// update cache
// ...
@thomaspoignant
thomaspoignant / ticker.go
Last active July 17, 2023 23:27
GO periodically refreshing Cache implementation
package main
import (
"fmt"
"sync"
"time"
)
var mutex sync.RWMutex
var cache map[string]interface{}
language: python
python: "3.8"
env:
global:
# GITHUB_TOKEN to open PR
- secure: "XXX"
# AWS ACCESS KEY
- secure: "XXX"
# AWS SECRET KEY
function open_pull_requests() {
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
STAGES=( dev pre pro )
for STAGE in "${STAGES[@]}"; do
# Run CDK diff
cdk diff -c stage=${STAGE} | tee cdk_diff_${STAGE}.txt
# Prepare PR message
read -r -d '' MESSAGE <<-EOM
> :warning: **Please review this changes before merging.**
language: python
python: "3.8"
stages:
- test
before_install:
- npm i -g [email protected] # Install CDK
- pip install -r requirements.txt --use-feature=2020-resolver # Download CDK python depedencies
@thomaspoignant
thomaspoignant / scim-scenario.json
Last active June 12, 2020 11:04
A scenario to test your SCIM integration
{
"trigger_url": "https://api.runscope.com/radar/e9283ad0-af77-45b4-81ee-0e59bd5ff932/trigger",
"name": "SCIM 2.0 SPEC Test",
"version": "1.0",
"steps": [
{
"url": "{{SCIMBaseURL}}/Users?count=1&startIndex=1",
"variables": [
{
"source": "response_json",
@thomaspoignant
thomaspoignant / scim-scenario-run.sh
Last active June 11, 2020 12:59
Test your scim integration using api-scemario
api-scenario run \
--scenario=scim-scenario.json \
--variable="auth:token" \
--variable="SCIMBaseURL:http://localhost:3000"\
--variable="InvalidUserEmail:[email protected]" \
--variable="UserIdThatDoesNotExist:id_invalid" \
--variable="randomEmail:[email protected]" \
--variable="randomUsername:randomUsername" \
--variable="randomGivenName:randomGivenName" \
--variable="randomFamilyName:randomFamilyName" \
package com.tpoi.monitoring.service;
import java.time.Instant;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
* HitCounter count the number of request in a specific range of time.
*/
{ "schemas":
["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
"Operations":[
{
"op":"add",
"path":"members",
"value":[
{
"display": "Babs Jensen",
"$ref":