Latest Snippets
Typescript | As type
TS
Cast object type to another type
const x = obj as CoolType;
Created: Fri Aug 30 2024
SQL | Export table as csv
BASH
Exports a single table as csv file. Useful for sharing data.
mysql database-name --skip-column-names --batch -e "Select * from table_name;" | sed 's/\t/,/g' > ./out.csv
Created: Wed Aug 14 2024
Magento 2 | Add admin user
SH
Add new admin user from cli.
magento admin:user:create --admin-user=dev --admin-password=securepassword --admin-email=developer@example.com --admin-firstname=Great --admin-lastname=Developer
Created: Sat Aug 03 2024
Typescript | As const
TS
Use as const to automatically create type from object values.
export const Ads = {
AUTO: 'auto',
STATIC: 'static',
AB: 'a/b',
} as const;
export type AdsType = typeof Ads[keyof typeof Ads];
Created: Sat Aug 03 2024