Skip to content

Instantly share code, notes, and snippets.

View mrbrianevans's full-sized avatar

Brian Evans mrbrianevans

View GitHub Profile
@mrbrianevans
mrbrianevans / GenerateTypescriptDefs.groovy
Created July 31, 2021 13:18
A groovy script to generate typescript definitions in Jetbrains IDE's. Put this file in your \JetBrains\{ProductName}\extensions\com.intellij.database\schema directory, and right click a database table > scripted extensions to use it
import com.intellij.database.model.DasTable
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
/*
* Available context bindings:
* SELECTION Iterable<DasObject>
* PROJECT project
* FILES files helper
*/
@mrbrianevans
mrbrianevans / sqlEscape.js
Last active August 14, 2024 08:30
Template string literal
const _query = async (client, text, values) => {
const queryText = text.reduce((query, phrase, index)=>`${query} ${phrase}$${index+1}`, '')
const { rows } = await client.query(queryText, values)
return rows
}
const query = (stringArray, ...args) => {
const client = new Client()
const result = await _query(client, stringArray, args)