Skip to content

Instantly share code, notes, and snippets.

♥️
Terraform v0.12

Renato Gama renatoargh

♥️
Terraform v0.12
Block or report user

Report or block renatoargh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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)
@renatoargh
renatoargh / small-query-builder.js
Last active Jun 7, 2019
A small query builder to help not writing SQL insert by hand
View small-query-builder.js
const withQuotes = (value, quote = '\'') => {
if (typeof value === 'undefined') {
return 'null'
}
if (value === null) {
return 'null'
}
return `${quote}${value}${quote}`
View pg_notify.js
// CREATE TABLE realtime_table (id serial primary key, title varchar, year varchar, producer varchar);
// CREATE FUNCTION notify_trigger() RETURNS trigger AS $$
// DECLARE
// BEGIN
// PERFORM pg_notify('watch_realtime_table', row_to_json(NEW)::text);
// RETURN new;
// END;
// $$ LANGUAGE plpgsql;
// CREATE TRIGGER watch_realtime_table_trigger AFTER INSERT ON realtime_table
@renatoargh
renatoargh / prefixed-sum.js
Created Oct 28, 2018
sum: O(n), get sum of segment: O(1)
View prefixed-sum.js
function prefixedSum(array) {
const sum = new Array(array.length + 1)
sum[0] = 0
for(let k = 1; k < sum.length; k++) {
sum[k] = (sum[k - 1] || 0) + array[k - 1]
}
return sum
}
View tls-keygen
https://www.npmjs.com/package/tls-keygen
View new-mac.md

General

  • chrome
  • sublime text 3
    • Plugin: EditorConfig
  • dropbox
  • spectable
  • skype
  • teamviewer
  • disk inventory X
  • whatsapp web
You can’t perform that action at this time.