Skip to content

Instantly share code, notes, and snippets.

View alex3165's full-sized avatar
🇫🇷

Alexandre Rieux alex3165

🇫🇷
View GitHub Profile
import time
import asyncio
from fastapi import FastAPI
app = FastAPI()
# 1/ Request resolved in 5.03s
# 2/ Request resolved in ~10s
@app.get("/not_async")
def not_async():
{
"first": {
"second": {
"foo": {
"isValid": true,
"value": "someValue3"
}
}
},
"new": {
@alex3165
alex3165 / pystp
Created April 27, 2020 08:13
Set python environment to current folder
#!/bin/bash
pystp() {
DIR="./env"
if [ ! -d "$DIR" ]; then
python3 -m venv env
fi
source env/bin/activate
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
state = GPIO.LOW
def callback(channel):
global state

Keybase proof

I hereby claim:

  • I am alex3165 on github.
  • I am alex3165 (https://keybase.io/alex3165) on keybase.
  • I have a public key ASCXKIsitiBTEviQJU0sEw-NP9r9RB_Qqj-JuJqP3cwvYgo

To claim this, I am signing this object:

@alex3165
alex3165 / aws-lambda-authorizer-google.js
Created July 10, 2019 17:25
An AWS lambda authorizer that work with google access token
const axios = require("axios");
exports.handler = async event => {
const token = event.authorizationToken;
console.log(`Received token`, token);
let googleAuthRes;
try {
googleAuthRes = await axios.get(
`https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=${token}`
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
// Send CORS Headers, useful if API is requested from a browser
app.use(cors());
// Parse request body to json
@alex3165
alex3165 / Index.js
Last active May 31, 2019 14:20
Javascript copy vs ref
const a = { byId: {} }
// b is a reference to a, any change on a will mutate b
const b = a
// c is shallow copy of a, any change on the top level properties of a will not affect c although any change of nested object would affect c, if we mutate byId in a it will update byId in c
const c = { ...a }
//or
const cprime = Object.assign({}, a)
'use strict'
const https = require('https');
const data = JSON.stringify({});
const getOptions = (code) => {
return {
host: 'github.com',
method: 'POST',
@alex3165
alex3165 / react-script-cci-aws.yml
Created October 7, 2018 15:18
Quick circleCI 2 config that works with react-script and deploy to aws
defaults: &defaults
docker:
- image: jtredoux/node-aws:latest
version: 2
jobs:
build:
<<: *defaults
steps:
- checkout