Skip to content

Instantly share code, notes, and snippets.

View ZakMiller's full-sized avatar
🎧
Focusing

Zak Miller ZakMiller

🎧
Focusing
View GitHub Profile
SELECT
tc.table_schema,
tc.constraint_name,
tc.table_name,
kcu.column_name,
ccu.table_schema AS foreign_table_schema,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM
information_schema.table_constraints AS tc
@ZakMiller
ZakMiller / eager.ts
Created April 9, 2021 11:20
[TypeORM]
@OneToMany(
type => Photo,
photo => photo.user,
{eager: true}
)
photos: Photo[];
@ZakMiller
ZakMiller / example.ts
Last active April 9, 2021 10:11
[Typescript utils]
// @ts-expect-error
const unusedVariableWeWant = "hello";
// Use list as source of union type. The "as const" is necessary.
export const getUserSorts = [
'firstName',
'lastName',
'email',
'createdOn',
'role',
@ZakMiller
ZakMiller / commands.sh
Last active April 3, 2021 21:51
[Git commands]
# update fork
git fetch upstream
# update local branch from fork
git pull upstream master
@ZakMiller
ZakMiller / launch.json
Created March 27, 2021 22:19
[Debug Specific Jest Test in VSCode]
{
"version": "0.2.0",
"configurations": [ {
"type": "node",
"request": "launch",
"name": "Jest Subset of Tests in File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config",
@ZakMiller
ZakMiller / watch.ts
Created March 26, 2021 16:46
[Vue] watch
// selected is the name of the property to watch.
watch: {
selected: function(newValue, oldValue) {
}
},
@ZakMiller
ZakMiller / commands.sh
Last active March 30, 2021 12:47
[npm commands] update a package, check version, see latest version, list all outdated packages
# using node-sass as an example
# upgrade a package
npm upgrade node-sass
# check version
npm list node-sass
# see latest version
npm show node-sass version
@ZakMiller
ZakMiller / count.sh
Created March 25, 2021 12:52
[Count files in directory] #unix #linux
ls | wc -l
@ZakMiller
ZakMiller / shape_to_geojson.py
Created March 25, 2021 12:50
[Convert shape to geojson]
import geopandas
import os
shp_path = './data/example.shp'
shp_file = geopandas.read_file(shp_path)
name = os.path.basename(shp_path)
no_extension = os.path.splitext(name)[0]
shp_file.to_file(f'./data/{no_extension}.geojson', driver='GeoJSON')
@ZakMiller
ZakMiller / base_name.py
Created March 25, 2021 12:48
[Get base name of file]
import os
base = os.path.basename('/root/dir/sub/file.ext')
filename = os.path.splitext(base)[0] # file