Skip to content

Instantly share code, notes, and snippets.

View inaiat's full-sized avatar

Inaiat Henrique inaiat

View GitHub Profile
@inaiat
inaiat / index.js
Created December 20, 2022 23:49
benchmark merge object
import _ from 'lodash-es'
import Benchmark from 'benchmark'
function getItems(count) {
let id = 1
return _.times(count, () => (
{
name: 'city' + id++,
visited: true,
id,
@inaiat
inaiat / main.rs
Created February 23, 2021 22:40
rust actix + reqwest
use actix_web::{web, App, HttpResponse, HttpServer};
use reqwest::Client;
use serde_json::Value;
async fn test(data: web::Data<AppState>) -> HttpResponse {
let client = &data.client;
let result = async {
client
.get("https://httpbin.org/json")
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver
namespace: foo
spec:
replicas: 1
selector:
matchLabels:
app: echoserver
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: api-key-filter
namespace: foo
spec:
workloadLabels:
app: echoserver
filters:
- listenerMatch:
@inaiat
inaiat / envoy-filter.yaml
Created April 25, 2020 16:50
Setting request headers with values from a JWT
apiVersion: "security.istio.io/v1beta1"
kind: RequestAuthentication
metadata:
name: echoserver
namespace: default
spec:
selector:
matchLabels:
app: echoserver
jwtRules:
@inaiat
inaiat / decode-jwt.lua
Last active February 5, 2024 06:29
Lua script to decode jwt token
-- Json Parsing based on https://gist.github.com/tylerneylon/59f4bcf316be525b30ab
-- Base64 decoding based on wikipedia description of 8/6bit encoding.
-- base64 char array.. note final 2 chars are for RFC4648-URL encoding
-- as per JWT spec section 2 terminology 'Base64url Encoding'
local alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
-- convert to 6 char long binary string. (max int 64!)
local function toBinaryString(int)
if int > 64 then error("Bad number " .. int .. " to convert to binary") end
local remaining = tonumber(int)
local bits = ''