Skip to content

Instantly share code, notes, and snippets.

View shekodn's full-sized avatar

Sergio Díaz shekodn

  • MX
View GitHub Profile
@shekodn
shekodn / deploy.sh
Created April 20, 2020 17:11
deploy script used for Deploying a Bastion Host in AWS using CloudFormation
#!/bin/bash
STACK_NAME=bastion-poc
REGION=us-east-1
CLI_PROFILE=your-aws-profile-with-an-appropiate-role
EC2_INSTANCE_TYPE=t2.micro
KEY_NAME=your-key-pair-name
# Deploy the CloudFormation template
echo -e "\n\n=========== Deploying main.yml ==========="
@shekodn
shekodn / crapi_diagram.pu
Created March 10, 2020 21:02
crapi_diagram.pu
@startuml
left to right direction
actor "Alice" as a
rectangle "Not So crAPI App" as r {
rectangle "Application Logic" as logic
rectangle "Authenticator" as auth
rectangle "Access Controller" as ac
@shekodn
shekodn / init-auth.go
Last active September 20, 2019 14:29
auth.go
func init() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
googleOauthConfig = &oauth2.Config{
RedirectURL: "http://localhost:" + os.Getenv("PORT") + "/callback",
INFO[0000] Starting the service...
INFO[0000] The service is ready to listen and serve.
INFO[0004] Processing URL /contacts
INFO[0009] Processing URL /importContacts
INFO[0009] Redirecting to URL https://accounts.google.com/o/oauth2/auth?client_id=xxx.apps.googleusercontent.com&redirect_uri
http%3A%2F%2Flocalhost%3A8000%2Fcallback&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcontacts.readonly&state=pseudo-random
INFO[0009] Client is redirecting user agent to authorization endpoint.
INFO[0019] Processing URL /callback
INFO[0019] Getting user info...
INFO[0019] Client is sending authorization code and its own credentials to token endpoint
@shekodn
shekodn / trendlit-latest.json
Last active May 31, 2019 01:00
This is the configuration to retrieve the 'latest' tag from Docker Hub
{
"AWSEBDockerrunVersion":"1",
"Image":{
"Name":"docker.io/your-username/trendlit-tutorial-1",
"Update":"true"
},
"Ports":[
{
"ContainerPort":"80"
}
@shekodn
shekodn / docker_build.sh
Last active May 26, 2019 17:55
docker_build script
#!/usr/bin/env bash
set -e
echo "build image"
REPOSITORY=CHANGE-ME # Change this to your Docker Hub's name
IMAGE=trendlit-tutorial-1
TAG=`make version`
HASH=`git log --format="%H" -n 1 | cut -c1-6`
@shekodn
shekodn / config.yml
Last active May 22, 2019 18:46
trendlit's CircleCI configuration file
version: 2
jobs: # (1)
test: # (2)
docker: # use the docker executor type
- image: python:3.7-alpine # the primary container, where the job's commands are run
steps:
- checkout # check out the code in the project directory
- run: python3 -m unittest tests/test_compiled_code.py
deploy: # (3)
docker: # use the docker executor type
@shekodn
shekodn / final_fibonacci_recursive.tl
Created May 21, 2019 06:20
final_fibonacci_recursive.tl
program factorial_recursive
script {
def factorial(int n) : int {
if (n is 0) {
spit 1;
}
spit n * (factorial(n - 1))
}
eval(factorial(10))