Skip to content

Instantly share code, notes, and snippets.

@cn007b
cn007b / 1.2.jpeg
Last active August 12, 2019 21:01
scaling
1.2.jpeg
@cn007b
cn007b / protocols.md
Last active August 12, 2019 20:36
protocols

Protocols

{
"executions": [
{
"id": 132,
"status": "succeeded",
"project": "TEST-Sylvain",
"executionType": "user",
"user": "sthirard",
"date-started": {
"unixtime": 1560946609000,
@cn007b
cn007b / fractal.md
Last active April 24, 2023 19:16
Simple fractal implementation on bash.

Simple bash fractal

Here you can find source code for simple fractal implementation
written in bash for hackerrank, which looks like this:

demo

Source code:

@cn007b
cn007b / no_uflfetch.go
Created May 3, 2019 09:14
Fetch (scrape) product's data by net/http not uflfetch
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
@cn007b
cn007b / Makefile
Last active April 10, 2019 16:09
Deploy AWS Fargate Service - deploy
delete_old_versions:
aws ecs list-task-definitions --sort=DESC \
| grep -Eo $(YourSrvc)':[0-9]+' \
| tail -n +2 \
| while read v; do aws ecs deregister-task-definition --task-definition=$$v; done
@cn007b
cn007b / Makefile
Last active April 10, 2019 15:46
Deploy AWS Fargate Service - deploy
deploy:
aws ecs update-service --cluster=$(YourCluster) --service=$(YourSrvc) --task-definition=`\
aws ecs register-task-definition --cli-input-json file://AWSTaskDefinition.json \
| grep -Eo $(YourSrvc)':[0-9]+' \
`
@cn007b
cn007b / Makefile
Created April 9, 2019 15:11
Deploy AWS Fargate Service - build_and_push_image
build_and_push_image:
docker build \
-t $(YourUserID).dkr.ecr.us-east-1.amazonaws.com/$(YourImage):$(YourTag) \
-f deploy/Dockerfile .
eval $(shell aws ecr get-login --no-include-email)
docker push $(YourUserID).dkr.ecr.us-east-1.amazonaws.com/$(YourImage):$(YourTag)
@cn007b
cn007b / td.json
Last active April 9, 2019 15:13
AWS TaskDefinition JSON example
{
"containerDefinitions": [
{
"name": "$(YourServiceName)",
"image": "$(YourUserID).dkr.ecr.us-east-1.amazonaws.com/$(YourImage):$(YourTag)",
"portMappings": [
{
"protocol": "tcp",
"hostPort": 8080,
"containerPort": 8080
@cn007b
cn007b / DRYinGO.errorHandling.go
Last active January 30, 2019 23:22
DRY in GO - error handling
if err != nil {
httpErrorCode := 500
switch err {
case ErrorInvalidID:
httpErrorCode = 400
case ErrorUnauthorized:
httpErrorCode = 401
case ErrorEmployeeNotFound:
httpErrorCode = 404
// other errors