Skip to content

Instantly share code, notes, and snippets.

View RafaelFigueiredo's full-sized avatar

Rafael Figueiredo RafaelFigueiredo

  • Federal University of Rio de Janeiro
  • Rio de Janeiro, Brazil
View GitHub Profile
@RafaelFigueiredo
RafaelFigueiredo / App.tsx
Created March 25, 2024 18:43
Using context to update state in React
import { useState, createContext, useContext } from 'react'
import './App.css'
const StateContext = createContext<any>(null)
function Form() {
const { state, setState } = useContext(StateContext)
const handleClick = () => {
@RafaelFigueiredo
RafaelFigueiredo / parallel.py
Created February 1, 2024 15:49
decorator for parallel calls on python
from typing import Callable
import threading
import queue
class Promisse:
def __init__(self, q: queue.Queue):
self.q = q
# install linkerd cli
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh
export PATH=$PATH:~/.linkerd2/bin
# install linkerd
linkerd install --set proxyInit.runAsRoot=true | kubectl apply -f -
# enable dashboard
linkerd viz install | kubectl apply -f -
http {
server {
listen 80;
# Force reject to all other locations
location /api {
# Reject requests with unsupported HTTP method
if ($request_method !~ ^(GET|POST|HEAD|OPTIONS|PUT|DELETE)$) {
return 405;
}
# Start a nodejs application in development or production
# depending on enviroment variable
if [ $NODE_ENV = "production" ]
then
echo "starting in production mode"
npm start
else
echo "starting in development mode"
npm run dev
// read documentation of Axios at https://github.com/axios/axios
// <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> - client-side
//
const axios = require('axios')
const Object = (function(){
const endpoint = "/api/object"