Skip to content

Instantly share code, notes, and snippets.

View ephys's full-sized avatar
🌸

Alyx ephys

🌸
View GitHub Profile
@ephys
ephys / new-json.md
Last active February 25, 2023 11:36

New JSON support in Sequelize

Sequelize supports a JSON extraction notation similar to the JS . operator:

User.findAll({
  where: {
    'jsonAttribute.address.country': 'Belgium',
  },
});
import {readdir, stat} from 'fs/promises';
import path from 'path';
const dir = process.argv[2];
async function listFiles(dir) {
const subdirs = await readdir(dir);
const files = await Promise.all(subdirs.map(async (subdir) => {
const res = path.resolve(dir, subdir);
return (await stat(res)).isDirectory() ? listFiles(res) : res;
@ephys
ephys / camelize.ts
Last active January 15, 2022 14:49
// note: unfinished implementation, we still need to list a bunch of characters. See below
type CamelCaseImpl<S extends string, Separator extends string> =
S extends `${infer P1}${Separator}${infer P2}${infer P3}`
? CamelCaseImpl<`${P1}${Uppercase<P2>}${P3}`, Separator>
: S;
// must be nested, cannot be CamelCaseImpl<S, '-' | '_' | ' '>
// or strings like 'first-second_third' will not parse properly.
type Camelize<S extends string> = CamelCaseImpl<CamelCaseImpl<CamelCaseImpl<Trim<S>, '-'>, '_'>, ' '>;
---- Minecraft Crash Report ----
// Hey, that tickles! Hehehe!
Time: 11/19/21 7:02 PM
Description: Ticking entity
java.lang.NoSuchMethodError: net.minecraft.entity.monster.ShulkerEntity.func_190769_dn()Lnet/minecraft/item/DyeColor;
at net.minecraft.entity.monster.ShulkerEntity.spawnNewShulker(ShulkerEntity.java:560) ~[?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:cavesandcliffs.mixins.json:common.entity.ShulkerEntityMixin,pl:mixin:A,pl:runtimedistcleaner:A}
at net.minecraft.entity.monster.ShulkerEntity.handler$zfb000$ccb$attackEntityFrom(ShulkerEntity.java:543) ~[?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:cavesandcliffs.mixins.json:common.entity.ShulkerEntityMixin,pl:mixin:A,pl:runtimedistcleaner:A}
at net.minecraft.entity.monster.ShulkerEntity.func_70097_a(ShulkerEntity.java) ~[?:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:APP:cavesandcliffs.mixins.json:common.entity.ShulkerEntityMixin,pl:mixin:A,pl:runtimedistcleaner:A}
@ephys
ephys / overlay-onboarding.module.scss
Created June 26, 2021 18:13
react-overlay-onboarding
.holeyOverlay {
box-sizing: border-box;
position: absolute;
z-index: 9999998;
border-radius: 4px;
box-shadow: rgb(33 33 33 / 0.8) 0 0 1px 2px, rgb(33 33 33 / 0.5) 0 0 0 5000px;
background: transparent;
transition: top 0.3s linear;
transition-property: border-radius, top, left, width, height;
@ephys
ephys / dom-utils.ts
Last active June 26, 2021 18:02
Donuts! With SVG! And they're lightweight!
export function getSvgCircleTotalLength(svgCircle: SVGCircleElement) {
// WORKAROUND - iOS (tested on safari 13):
// getTotalLength always returns 0 on circle SVGs, unless observed through the inspector.
// if (svgCircle.getTotalLength) {
// return svgCircle.getTotalLength();
// }
return 2 * Math.PI * Number(svgCircle.getAttribute('r'));
}
@ephys
ephys / overflow-indicator.module.scss
Created June 26, 2021 17:34
Div Overflow Indicator / Detector
.top {
--mask-top: transparent;
}
.right {
--mask-right: transparent;
}
.bottom {
--mask-bottom: transparent;
function createElement(tagName, attributes) {
const element = document.createElement(tagName);
for (let attributeName of Object.keys(attributes)) {
const attribute = attributes[attributeName];
if (attributeName.startsWith('on') && typeof attribute === 'function') {
const eventName = attributeName.substr(2).toLowerCase();
element.addEventListener(eventName, attribute);
}
@ephys
ephys / transactions.js
Created May 29, 2020 12:19
sequelize's transaction and async_hooks
// @flow
import { AsyncLocalStorage } from 'async_hooks';
import type { Sequelize, Transaction } from 'sequelize';
const asyncStore = new AsyncLocalStorage();
/**
* This works like {@link Sequelize#transaction}, but if this is called inside an active transaction,
* the active transaction will be returned.
// based on https://css-tricks.com/snippets/css/fluid-typography/
// This doesn't have to be limited to font-size! Go wild!
@function strip-unit($value) {
@return $value / ($value * 0 + 1);
}
@function fluid($min-vw, $max-vw, $min-size, $max-size) {
$u1: unit($min-vw);
$u2: unit($max-vw);