Skip to content

Instantly share code, notes, and snippets.

View sylwit's full-sized avatar

Sylvain Witmeyer sylwit

View GitHub Profile
@sylwit
sylwit / asciinema_rewrite.sh
Last active November 20, 2020 03:00
asciinema rewrite
#!/bin/bash
# This script rewrites history of an asciinema cast from a starting point in time
# ex: ./asciinema_rewrite.sh in.cast 17.452 3 > out.cast, will remove 3 seconds of each record after 17.452sec
if [[ $# -ne 3 ]]; then
echo "Invalid number of arguments"
echo "Usage: $0 filename starting_time remove_time > out.cast"
exit 2
fi
@sylwit
sylwit / Makefile
Created July 18, 2020 15:31
Terraform with aw-vault template
account := acc
VARS_ENV="variables/$(TF_WORKSPACE).tfvars"
VARS_SECRETS="variables/$(TF_WORKSPACE)-secrets.tfvars"
fmt:
terraform fmt
workspace:
aws-vault exec $(account) -- terraform workspace list

Keybase proof

I hereby claim:

  • I am sylwit on github.
  • I am sylwit (https://keybase.io/sylwit) on keybase.
  • I have a public key ASCUccMAcFnMabdxG1YNCq3RK3BR7R2y-omIRLzY_hm2Dgo

To claim this, I am signing this object:

rsync -zarv --exclude="cache" --exclude="img" --include="*/" --include="*.php" --exclude="*" host_alias:public_html/ .
@sylwit
sylwit / .bashrc
Created January 23, 2018 21:01
Alias for docker
function docker.clean_containers() {
docker rm $(docker ps -a | grep -v Up | grep -v CONTAINER | cut -f 1 -d ' ')
}
function docker.clean_images() {
docker rmi $(docker images | grep none | tr -s ' ' | cut -f 3 -d ' ')
}
function docker.clean_volumes() {
docker volume rm $(docker volume ls -qf dangling=true)
@sylwit
sylwit / duproprio ban feature
Created August 8, 2017 04:31
Improve UX by adding a ban feature on duproprio! POC in 30 min
// ==UserScript==
// @name duproprio
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Improve UX by adding a ban feature on duproprio! POC in 30 min
// @author @sylwit
// @match https://duproprio.com/*
// @grant none
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// ==/UserScript==
@sylwit
sylwit / cloudwatch_setup.sh
Created April 5, 2017 14:21
Setup cloudwatch alarms with lambda function
# Create EC2 instance, EBS alarms for all resources in a region
import os
import boto3
# SNS Topic Definition for EC2, EBS
instance_ids = os.environ.get('INSTANCE_ID').split('#')
ec2_sns = os.environ.get('SNS_TOPIC_ARN') # arn:aws:sns:ca-central-1:476697408772:cloudwatch-monitoring
ebs_sns = os.environ.get('SNS_TOPIC_ARN') # arn:aws:sns:ca-central-1:476697408772:cloudwatch-monitoring
# AWS Account and Region Definition for Reboot Actions
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDVchxw56NMCV9pSAXdyHmXBBBvoePIPxxKfdGyZB6crBjUR11ycBv3tTcp4uF7M7uB1JEdm4gIp1QQ54x9576FqIT5Hr0ZXJGYLWRZB/V95h4KxVnNgsyT7rcUJ9J2WOZ1c46lEZ16CHWsbHc3JJACsW4UimVoToqLiP1J4dOTAEIAy8Dg80popraheALG8o4bUOSP2hep/6OsHzhFrjOl2pYqld94QShtTKK9LahcaQWrPSB+TCWSkleIdTupbRKEvG1qey97QDlfy/jG3Kw57lVWKnFsZbE65ua+U1E+w2eep7V/wdhvCZuplFe++7T6AHmk84dt6Gf4OQtfqcqLkzBQWfAJgpvVI+ZqPsE/ZaEpY0pCJFyWqt0Msw17eBuJmucO6JQ6Of6Ztzv/k3qjs+vvBufP2hWFopGEBSclUd+pGH8v7pgYVhK8rvpIGD05jwWL54T+UG68ESwdcmjEBjFfzNCtzfdp94Hrpl8eLruV/suVXQtg1ZP4acK4eQTf8x3kBjEAI80PEix4fBYBo7cZAseVrvpujCgUDeDU3nqpgltBGOl8OZE2zNA1O691iWTmHchZQgpe7nFa7YET6jlcyjextJEVBxUUMXXV52KBFyrNW1eohSfx3YRIRcBOIC9a2XwaU3aKRlSp3Wax6GWhqI7jQKk3BL2GOJkMgw== [email protected]
| Test | How | HTTP code expected | Assertions |
|-----------------------------------|-------------------------------------------------------------|--------------------|------------------------------------------------------------|
| Should return a list of resources | Call URL | 200 | Count property should match rows.length |
| Should filter resources | Call URL with filter parameters (limit, sort, start,filter) | 200 | Count property, rows.length, id of first and last resource |
| Should return a specific resource | Call URL with a resource ID | 200 | Check each property |
| Should fail if resource not found | Call URL with a fake resource ID | 404
@sylwit
sylwit / testCreateCRUDApi.txt
Last active July 28, 2016 04:02
Table for how testing your CRUD API
| Test | How | HTTP code expected | Assertions |
|------------------------------------------------|--------------------------------------|--------------------|------------------------|
| Should create a resource | Send full valid data | 201 | Check each property |
| Should fail returning all mandatory properties | Send a single non mandatory property | 400 | Count number of errors |
| Should fail if ... | Send data against business logic | 400 | |