Skip to content

Instantly share code, notes, and snippets.

@psaia
psaia / tls_notes.sh
Last active August 11, 2022 16:21
Handy tls/x.509 debugging notes
View tls_notes.sh
# If you need to export certs from a k8s secret
kubectl get secret/my-secret -n istio-system -ojson | jq -r '.data["tls.key"]' | base64 --decode > tls.key
kubectl get secret/my-secret -n istio-system -ojson | jq -r '.data["tls.crt"]' | base64 --decode > tls.crt
kubectl get secret/my-secret -n istio-system -ojson | jq -r '.data["ca.crt"]' | base64 --decode > ca.crt
kubectl get secret/my-secret-cacert -ojson -n istio-system | jq -r '.data.cacert' | base64 --decode > chain.crt
# Create a mTLS server and connect to it with a client locally. This is useful
# for veryifying the entire stack of certificates work with each other. It will
# actually create a server listening on port 7569.
openssl s_server -accept 7569 -CAfile cacert.crt -cert tls.crt -key tls.key -Verify 10 -tls1_2 -state -quiet
View tictactoe.rs
use std::collections::HashMap;
use std::io;
use std::slice::Iter;
#[derive(Debug, PartialEq)]
enum Player {
X,
O,
}
@psaia
psaia / store.tsx
Created August 7, 2020 03:09
Redux style store without Redux.
View store.tsx
import React, { createContext, useReducer } from "react";
import { CheckType } from "./types";
import update from "immutability-helper";
interface Action {
type: string;
payload: any; // @TODO
}
interface State {
@psaia
psaia / main.go
Created July 27, 2020 17:47
Authenticated request to a Google Cloud Function in Go.
View main.go
package main
import (
"context"
"io/ioutil"
"net/http"
"github.com/kr/pretty"
"google.golang.org/api/idtoken"
"google.golang.org/api/option"
@psaia
psaia / convert.sh
Last active March 29, 2020 19:33
Some handy ffmpeg configs
View convert.sh
# Note: Lower the -crf, higher the quality.
# Good for screencasts:
ffmpeg -i INPUT.mov -preset veryslow -tune stillimage -y -vcodec h264 -crf 29 -an OUTPUT.mp4
# Cropping (84px from top, 555 height):
ffmpeg -i INPUT.mov -filter:v "scale=-1:700,crop=iw:555:0:84" -preset veryslow -tune stillimage -y -vcodec h264 -crf 29 -an OUTPUT.mp4
@psaia
psaia / combinator.py
Created March 5, 2020 21:57
combinator.py
View combinator.py
FRUIT = "fruit"
VEGGIE = "veggie"
class Product:
def __init__(self, name, kind):
self.name = name
self.kind = kind
def __repr__(self):
return "(name: %s / kind: %s)" % (self.name, self.kind)
@psaia
psaia / strapi.yml
Created February 8, 2020 20:49
Quick, immutable (with persistent mongodb), Strapi kubernetes config
View strapi.yml
apiVersion: v1
data:
database.json: |
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": "mongodb://..."
View renderer.tsx
const EnvironmentProvider = environment => props => {
return (
<ReactRelayContext.Provider
{...props}
value={{ environment: environment, variables: {} }}
/>
);
};
async function createRelayEnvironment(req) {
View keybase.md

Keybase proof

I hereby claim:

  • I am psaia on github.
  • I am iisthesloth (https://keybase.io/iisthesloth) on keybase.
  • I have a public key ASDWvdSLS_4WoEJI27h9plisLadYERmpIdyQn92mBWOEgwo

To claim this, I am signing this object:

@psaia
psaia / observer.ts
Last active October 6, 2019 04:06
A typescript observer class with async/await capabilities.
View observer.ts
/**
* A decent observer class.
*/
export type PayloadFn = (payload?: any) => void | Promise<void>;
export interface Subscription {
name: string;
fn: PayloadFn;
}