Skip to content

Instantly share code, notes, and snippets.

@psaia
psaia / strapi.yml
Created February 8, 2020 20:49
Quick, immutable (with persistent mongodb), Strapi kubernetes config
apiVersion: v1
data:
database.json: |
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "mongoose",
"settings": {
"uri": "mongodb://..."
@psaia
psaia / convert.sh
Last active March 29, 2020 19:33
Some handy ffmpeg configs
# 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
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)
const EnvironmentProvider = environment => props => {
return (
<ReactRelayContext.Provider
{...props}
value={{ environment: environment, variables: {} }}
/>
);
};
async function createRelayEnvironment(req) {
@psaia
psaia / observer.ts
Last active October 6, 2019 04:06
A typescript observer class with async/await capabilities.
/**
* A decent observer class.
*/
export type PayloadFn = (payload?: any) => void | Promise<void>;
export interface Subscription {
name: string;
fn: PayloadFn;
}

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 / wiredtiger
Created November 21, 2018 17:25
Syncing wiredtiger data with mongodb docker image
docker run --rm -P -v ~/Desktop/test/prod0-shard-0-1538600622-5bb55f5aff7a255af95eba75/:/data/db mongo:3.4
@psaia
psaia / appname.js
Last active February 19, 2018 03:35
Relay Modern (or anything else) server side rendering for bots.... only.
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const express = require("express");
const jsdom = require("jsdom");
const isBot = require("isbot");
const { Script } = require("vm");
const app = express();
@psaia
psaia / golang-style.sh
Last active September 11, 2017 23:58
Enable idiomatic "golang style" unit testing in node.js with mocha. Add this to npm's scripts or your pipeline.
#!/bin/sh
NODE_ENV=test mocha --recursive ./**/*_test.js
f=$(date +%Y-%m-%d-%H-%M-%S)
dest=$(realpath $(pwd)/..)
# Archive newly deployed files in the releases directory.
cp -R $dest/.tmp/ $dest/releases/$n
# Update the symlink to point to the latest release (atomic).
ln -sfn $dest/releases/$n $dest/live-app
# Clean up.