Skip to content

Instantly share code, notes, and snippets.

View albinekb's full-sized avatar
🤖
AgentAgentAgentAgentAgent

Albin Ekblom albinekb

🤖
AgentAgentAgentAgentAgent
View GitHub Profile
import * as React from 'react'
import Table from '@material-ui/core/Table'
import TableBody from '@material-ui/core/TableBody'
import TableHead from '@material-ui/core/TableHead'
import TableRow from '@material-ui/core/TableRow'
import TableCell from '@material-ui/core/TableCell'
const ArrayOf = ({ type }) => (
<React.Fragment>
{
"editor.fontFamily": "FiraCode-Light",
"editor.fontLigatures": true,
"window.zoomLevel": 4,
"prettier.printWidth": 140,
"prettier.semi": false,
"prettier.singleQuote": true,
"prettier.trailingComma": "all",
"editor.formatOnSave": true,
"workbench.iconTheme": "seti",
@albinekb
albinekb / wrapper.ts
Last active September 12, 2018 13:33
express async route wrapper
type Method = 'get' | 'post' | 'put' | 'delete'
type Handler = (req: Request) => Promise<any>
function route (method: Method, path: string, handler: Handler) {
app[method](path, (req, res, next) => {
handler(req)
.then(result => result ? res.json(result) : res.status(204).end(''))
.catch(next)
})
}
@albinekb
albinekb / download.js
Last active September 25, 2018 19:10
function download(csv) {
if (csv == null) return
const filename = `export-${new Date()}.csv`
if (!csv.match(/^data:text\/csv/i)) {
csv = 'data:text/csv;charset=utf-8,' + csv
}
const data = encodeURI(csv)
@albinekb
albinekb / Material UI Color Palette.less
Last active November 21, 2019 09:19
Material UI Color Palette, for use with Less Preprocessor
@red: #e51c23;
@red--50: #fde0dc;
@red--100: #f9bdbb;
@red--200: #f69988;
@red--300: #f36c60;
@red--400: #e84e40;
@red--500: #e51c23;
@red--600: #dd191d;
@red--700: #d01716;
@red--800: #c41411;
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
<div