Skip to content

Instantly share code, notes, and snippets.

View ryands17's full-sized avatar
:electron:
In love with TS & Rust

Ryan Dsouza ryands17

:electron:
In love with TS & Rust
View GitHub Profile
@fritzy
fritzy / 1_triggers.sql
Last active April 7, 2024 20:07
Get table change notifications from Postgres as JSON
CREATE OR REPLACE FUNCTION table_update_notify() RETURNS trigger AS $$
DECLARE
id bigint;
BEGIN
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
id = NEW.id;
ELSE
id = OLD.id;
END IF;
PERFORM pg_notify('table_update', json_build_object('table', TG_TABLE_NAME, 'id', id, 'type', TG_OP)::text);
@popravich
popravich / PostgreSQL_index_naming.rst
Last active July 19, 2024 06:03
PostgreSQL index naming convention to remember

The standard names for indexes in PostgreSQL are:

{tablename}_{columnname(s)}_{suffix}

where the suffix is one of the following:

  • pkey for a Primary Key constraint;
  • key for a Unique constraint;
  • excl for an Exclusion constraint;
  • idx for any other kind of index;
@levlaz
levlaz / types_and_roles_demo.sql
Created March 28, 2016 19:11
Create Types and Roles If Not Exist in PostgreSQL
BEGIN;
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'task_status') THEN
create type task_status AS ENUM ('todo', 'doing', 'blocked', 'done');
END IF;
END
$$;
CREATE TABLE IF NOT EXISTS
@ikouchiha47
ikouchiha47 / tut.md
Last active May 14, 2021 11:12
Implementing a peer to peer chat prototype in nodejs.

prologue

Why another tutorial? Because there are other tutorials which write a server - client or maybe a client client where they have only two clients, maybe by hardcoding ips.

<rant>
  What annoys me more is, that there are 100's of same tutroials on the internet, 
 that just works for a given scenario, but guess what, I don't fucking care what works
@seanhandley
seanhandley / docker-compose.yml
Last active June 7, 2024 19:25
How To Set Up Docker For Mac (Mojave) with Native NFS
version: '2'
services:
api:
volumes:
- "nfsmount:${CONTAINER_DIR}"
volumes:
nfsmount:
driver: local
driver_opts:
@GoNZooo
GoNZooo / text.ts
Created December 24, 2018 21:48
Phantom type variant in TypeScript
interface PlainText extends String {
__plaintext__: never
}
interface Base64Encoded extends String {
__base64Encoded__: never
}
interface Encrypted extends String {
__encrypted__: never
}
@lalitkale
lalitkale / AWSDevOpsStudyNotes
Created September 7, 2019 19:21
AWS DevOps Engineer Professional Study Notes
CI & CD:
========
2 core software development processes
CI process of automating regular code commits followed by an automated build and test process designed to highlight intergration issues early.
Additional tooling and functionality provided by Bamboo, CruiseControl, Jenkins, Go and TeamCity etc.
workflow based
CD takes the form of a workflow based process which accepts a tested software build payload from a CI server. Automates the deployment into a working QA, Pre-prod or Prod environment.
AWS CodeDeploy and CodePipeline provide CI/CD services
Elasticbeanstalk and CFN provide functionality which can be utilized by CI/CD servers.
@christophengelmayer
christophengelmayer / tailwind-resonsive-embed.html
Last active March 26, 2023 13:42
Tailwind CSS responsive Video embed
<div class="relative" style="padding-top: 56.25%">
<iframe class="absolute inset-0 w-full h-full" src="https://www.youtube-nocookie.com/embed/FMrtSHAAPhM" frameborder="0" …></iframe>
</div>
@sibelius
sibelius / filterAsync.ts
Created July 29, 2020 12:31
Simple filter async
function mapAsync<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => Promise<U>): Promise<U[]> {
return Promise.all(array.map(callbackfn));
}
async function filterAsync<T>(array: T[], callbackfn: (value: T, index: number, array: T[]) => Promise<boolean>): Promise<T[]> {
const filterMap = await mapAsync(array, callbackfn);
return array.filter((value, index) => filterMap[index]);
}
@JLarky
JLarky / README.md
Last active July 23, 2024 09:46
Ultimate example of react context hook with nice type-safe (TypeScript) wrappers and reduced boilerplate by using `ReturnType`