Skip to content

Instantly share code, notes, and snippets.

View DanielFGray's full-sized avatar

Daniel Gray DanielFGray

View GitHub Profile
@DanielFGray
DanielFGray / index.html
Created November 13, 2023 21:04
Map to values array, array spread vs array.from (http://jsbench.github.io/#0717707c579f990df95d04e8b276eae6) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Map to values array, array spread vs array.from </title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@DanielFGray
DanielFGray / index.html
Last active October 6, 2023 20:14
object lookup vs map lookup (http://jsbench.github.io/#12b6afb8665e3887c8e1c7dde244fd41) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>object lookup vs map lookup</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
begin;
-- user accounts
create extension if not exists citext;
create table users (
user_id int primary key generated always as identity,
username citext unique not null,
created_at timestamptz not null default now()
);
@DanielFGray
DanielFGray / rc.lua
Created April 22, 2023 01:55
current awesomewm config
-- {{{ libraries
local gears = require('gears')
local awful = require('awful')
awful.autofocus = require('awful.autofocus')
-- Widget and layout library
local wibox = require('wibox')
-- Theme handling library
local beautiful = require('beautiful')
-- Notification library
local naughty = require('naughty')
@DanielFGray
DanielFGray / init.lua
Last active December 9, 2023 20:04
current init.lua
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', lazypath })
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = ' ' -- 'vim.g' sets global variables
vim.g.loaded_netrwPlugin = 1
require('lazy').setup({
@DanielFGray
DanielFGray / .md
Created April 23, 2022 19:35
postgres with extensions
FROM postgres:14
RUN apt-get update && apt-get upgrade -y
ENV build_deps ca-certificates \
    git \
    build-essential \
    libpq-dev \
    postgresql-server-dev-14
RUN apt-get install -y --no-install-recommends $build_deps
@DanielFGray
DanielFGray / alarm.sh
Last active March 6, 2020 23:26
alarm
#!/usr/bin/env bash
declare loud=0
declare urgent
declare old_volume
declare old_volume
cleanup() {
set_volume "$old_volume"
@DanielFGray
DanielFGray / useFetch.js
Created July 6, 2019 18:18
useFetch hook
import { useState, useEffect } from 'react'
export default function useJson(props) {
const [state, _setState] = useState({
data: props.initData,
error: null,
loading: true,
})
const setState = patch => s => _setState({ ...s, ...patch })
@DanielFGray
DanielFGray / hash.js
Created April 3, 2019 18:02
promise wrapper around crypto.createHash
const crypto = require('crypto')
module.exports = function hash({ method }, input) {
return new Promise((res, rej) => {
const h = crypto.createHash(method)
h.on('readable', () => {
const data = h.read()
if (data) {
res(data.toString('hex'))
} else rej()
const tput = require('./tput')()
tput.write('smcup')
tput.write('cup 0 0')
process.stdout.write('foo')
process.on('exit', () => {
tput.write('rmcup')
process.exit()
})