This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/sequelize/sequelize/issues/8984#issuecomment-738790473 | |
// Here is a workaround to delete new indices after calling sequelize.sync({alter: true}); | |
// Be careful, this will delete all indices of the current database that ends with a number after an underline character (e.g. index_1) | |
const rawTables = await this.sequelize.query("SHOW TABLES") | |
const tables = rawTables[0].map(i => i[Object.keys(rawTables[0][0])[0]]) | |
for (const t of tables) { | |
const rawKeys = await this.sequelize.query(`SHOW INDEX FROM ${t}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://www.cybertec-postgresql.com/en/index-your-foreign-key/ | |
SELECT c.conrelid::regclass AS "table", | |
/* list of key column names in order */ | |
string_agg(a.attname, ',' ORDER BY x.n) AS columns, | |
pg_catalog.pg_size_pretty( | |
pg_catalog.pg_relation_size(c.conrelid) | |
) AS size, | |
c.conname AS constraint, | |
c.confrelid::regclass AS referenced_table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://stackoverflow.com/a/33293747/717949 | |
-- NOTE: the WHERE condition at the end can be removed for smaller tables | |
-- check for FKs where there is no matching index | |
-- on the referencing side | |
-- or a bad index | |
WITH fk_actions ( code, action ) AS ( | |
VALUES ( 'a', 'error' ), | |
( 'r', 'restrict' ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef, useState, useEffect, useCallback } from 'react' | |
import cn from 'classnames' | |
import './EditableText.css' | |
const EditableText = ({ | |
className, | |
inputClassName, | |
as: ElementTag = 'span', | |
value, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const randomInt = (from, to) => Math.floor(Math.random() * (to - from + 1) + from) | |
const rs = (input, random = false) => { | |
const len = input.length | |
const upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('') | |
const lower = 'abcdefghijklmnopqrstuvwxyz'.split('') | |
let lastUpper = -1 | |
let lastLower = -1 | |
let output = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2019 The Chromium Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
// 2022-07-06 Updated to null safety | |
import 'package:flutter/gestures.dart'; | |
import 'package:flutter/material.dart'; | |
/// A widget that takes two children, lays them out along [axis], and allows | |
/// the user to resize them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async function() { | |
const cls1 = [ | |
'article[role="presentation"]', | |
'div[style]', | |
'div[style]', | |
'div[role="button"]', | |
'div', | |
'div[role="button"]', | |
'div[style]', | |
'img[crossorigin="anonymous"][class]', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Slashy things are single-line comments, very useful | |
/* | |
* Slashy + star are multi-line comments | |
* | |
* This is a basic inheritence example, | |
* which is a core principle of OOP, or Object Oriented Programming | |
*/ | |
// Imports let you use things from other libraries (code) | |
// that you or others have written |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const table2csv = table => { | |
const rows = [...table.querySelectorAll('tr')] | |
const csv = [] | |
if (rows.length < 20) return null | |
for (let i in rows) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const isValidateEmail = email => { | |
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ | |
return re.test(String(email).toLowerCase()) | |
} |
NewerOlder