Skip to content

Instantly share code, notes, and snippets.

@beerose
beerose / malleable-approaches.md
Last active August 13, 2023 13:21
Malleable software approaches
Solution Pros Cons
Plugins - Allow extending apps with various functionalities
- Widely adopted in many modern software ecosystems, enhancing versatility
- Allows forming community that creates and maintains plugins
- Non-programmers can use existing plugins that someone else created
- Only allows for a limited form of malleability; plugins are more of an outer layer of customization
- Usually can't modify core functionalities or deeply ingrained software behaviors
- A plugin created for one platform usually can't be used on another, leading to platform lock-in
- Can result in fragmented development, with popular features being redundantly developed for different environments
Black-box Interface Extensions - Allow for the modification of legacy software which doesn't have built-in plugin architectures- Can modify app interfaces without needing access to internal structure or source code, enabling adaptability
@beerose
beerose / blitz-server.ts
Created July 18, 2022 10:53
Blitz.js auth + Redis example
import IoRedis from 'ioredis';
import { setupBlitz } from '@blitzjs/next';
import { AuthServerPlugin, simpleRolesIsAuthorized, SessionModel, Session } from '@blitzjs/auth';
const dbs: Record<string, IoRedis.Redis | undefined> = {
default: undefined,
auth: undefined
};
export function getRedis(): IoRedis.Redis {
import {execSync} from 'child_process';
const destinationRepo = "https://github.com/??/??.git"
const issues = execSync(`gh issue list --json url --jq '[.[].url] | join(",")'`).toString().trim()
for (const issue of issues.split(',')) {
execSync(`gh issue transfer ${issue} ${destinationRepo}`).toString()
}

09.04.2021 — 8h

  • Setup blitz project
  • Add Github and Gmail auth
  • Send emails with link to reset password
  • Create an email template
  • Setup CI for tests and builds
  • Send confirmation email after creating an account with login and password
  • Handle account confirmation on the frontend
  • Update DB models to contain info about origin and confirmed account
SELECT
fk.name AS constraint_name,
sch1.name AS [table_schema],
tab1.name AS [table_name],
sch2.name AS [ref_table_schema],
tab2.name AS [ref_table],
(
SELECT
col1.name AS [column],
col2.name AS [referenced_column]
module.exports = {
"schema": [
{
"https://<YOUR_GRAPHQL_SERVICE>/graphql": {
"headers": {}
}
}
],
"documents": [
"./src/**/*.tsx",
import { NowResponse } from '@now/node';
import { fold } from 'fp-ts/lib/Either';
import * as t from 'io-ts';
import { reporter } from 'io-ts-reporters';
type GetRequestValidator<
QueryValidator extends t.Any,
ParamsValidator extends t.Any
> = t.TypeC<{
query: QueryValidator;
import * as React from 'react';
import { useState } from 'react';
export const useTouch = (ref: React.RefObject<HTMLElement>, defaultState = false) => {
const [state, setState] = useState(false);
React.useEffect(() => {
const element = ref.current;
if (!element) {
return;