Skip to content

Instantly share code, notes, and snippets.

@renatoargh
renatoargh / docker-compose.yml
Created Aug 4, 2022
Basic Flink docker compose setup
View docker-compose.yml
version: '3'
services:
flink-jobmanager:
image: flink:1.7
platform: linux/x86_64
container_name: flink-jobmanager
command:
- "jobmanager"
ports:
View wait-for.ts
const sleep = async (timeout: number = 1000) =>
// tslint:disable-next-line:no-string-based-set-timeout
new Promise((res) => setTimeout(res, timeout));
/**
* A test-only utility that executes a function until a given condition is met.
* Useful to wait for asynchronous operations to complete on integration tests.
* If the condition is never met (`condition` never returns `true`) then tests will eventually timeout accordin to
* the test framework timeout settings.
* @param task Asynchronous function that will be repeatedly executed until the the desired `condition` is met.
View Cloneable.ts
import { isUndefined } from "lodash";
export abstract class Cloneable<T> {
public clone(newValues: Partial<T> = {}): T {
const clone = new (this.constructor as new () => T)();
const newValuesWithNestedClones = Object.getOwnPropertyNames(clone)
.reduce((partial, propertyName) => {
const property = Object.getOwnPropertyDescriptor(clone, propertyName) as PropertyDescriptor;
const isCloneable = property.value instanceof Cloneable;
const isNotProvided = isUndefined(
@renatoargh
renatoargh / config.yml
Created Feb 12, 2021 — forked from sjparkinson/config.yml
Deploy a Fastly service using Terraform and CircleCI 2.0.
View config.yml
version: 2
jobs:
validate_terraform:
docker:
- image: hashicorp/terraform
steps:
- checkout
- run:
name: Validate Terraform Formatting
View classgen.js
const className = 'StateId'
const interfaceName = 'StateIdInterface'
const data = ` state: string;
value: string;
isActive: boolean;
toJSON(): { [key: string]: any };`
const members = data
.replace(/\n/g, '')
.split(';')
View cache.ts
interface ObjectInterface {
[key: string]: any;
}
function initCache<T>(obj: any): T {
const cache = {};
return new Proxy(obj, {
get(target: ObjectInterface, methodKey: string) {
const originalMethod = target[methodKey];
View cache.ts
interface ObjectInterface {
[key: string]: any;
}
function initCache<T>(obj: any): T {
const cache = {};
return new Proxy(obj, {
get(target: ObjectInterface, methodKey: string) {
const originalMethod = target[methodKey];
@renatoargh
renatoargh / pglogical
Created Jul 8, 2019 — forked from ratnakri/pglogical
short tutorial to setup replication using pglogical
View pglogical
Edit /var/lib/postgres/data/postgresql.conf:
# change IP on subscriber
listen_addresses = '*'
wal_level = logical
shared_preload_libraries = 'pglogical'
max_worker_processes = 16
max_wal_senders = 16
max_replication_slots = 16
track_commit_timestamp = on
View initial_expected_usage.js
const validator = new Validator('http://example.com/swagger.yaml')
await validator.init()
validator.validate('UserCreated', payload)