Skip to content

Instantly share code, notes, and snippets.

View thinkjrs's full-sized avatar
🎯
Focusing

Jason R. Stevens, CFA thinkjrs

🎯
Focusing
View GitHub Profile
@thinkjrs
thinkjrs / ctrl-y.bash
Created December 27, 2024 16:26
ctrl-y to copy current terminal command
# ctrl-y to copy to clipboard
if [[ -n $DISPLAY ]]; then
copy_line_to_x_clipboard () {
printf %s "$READLINE_LINE" | xclip -selection CLIPBOARD
}
bind -x '"\C-y": copy_line_to_x_clipboard' # binded to ctrl-y
fi
@thinkjrs
thinkjrs / tailwind-colors.js
Created June 18, 2024 20:52
Tailwindcss Colors
const colors = {
slate: {
50: '#f8fafc',
100: '#f1f5f9',
200: '#e2e8f0',
300: '#cbd5e1',
400: '#94a3b8',
500: '#64748b',
600: '#475569',
700: '#334155',
@thinkjrs
thinkjrs / 404Links.tsx
Created March 6, 2024 21:44
Next.js 404 Links
@thinkjrs
thinkjrs / 404.tsx
Created March 6, 2024 21:42
Next.js Custom 404
import React from 'react'
import { HomeLink404, DashboardLink404 } from '@/components/404Links'
export default function NotFound() {
return (
<>
<section className="bg-primary relative z-10 py-[120px]">
<div className="container mx-auto">
<div className="-mx-4 flex">
<div className="w-full px-4">
<div className="mx-auto max-w-[400px] text-center">
@thinkjrs
thinkjrs / uploadS3NextjsAppRouter.md
Last active December 27, 2023 15:55
Steps to create buckets and upload files using AWS S3 and the Next.js App Router
@thinkjrs
thinkjrs / dark-mode-image.html
Created December 12, 2023 16:17
How to add dark and light mode adjustments for an image in HTML
<!-- https://larsmagnus.co/blog/how-to-make-images-react-to-light-and-dark-mode -->
<picture>
<source
srcset="dark-image.png"
media="(prefers-color-scheme: dark)"
/>
<img
src="light-image.png"
alt="Browser with large and small images of a coffee cup and plants"
/>
@thinkjrs
thinkjrs / responseSize.ts
Created December 5, 2023 00:46
Get the response size in TypeScript of a request payload
// https://github.com/vercel/vercel/issues/3825#issuecomment-961295566
function formatBytes(bytes: number, decimals = 2) {
if (bytes === 0) return '0 Bytes'
const k = 1024
const dm = decimals < 0 ? 0 : decimals
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
@thinkjrs
thinkjrs / ssh-copy-id.md
Created March 4, 2023 20:20
Copy an SSH key to a server

Copy an SSH key to a server

Use the built-in ssh-copy-id command to copy keys to servers.

Note: make sure you have enabled password authentication on the server ssh server configuration, first!

ssh-copy-id -i ~/.ssh/mykey user@host
@thinkjrs
thinkjrs / remove-docker-volumes.md
Created February 28, 2023 23:50
Remove all docker volumes

Removing Docker Volumes

It's a common need to remove docker volumes (e.g. Gitlab runners that polute your system).

The command

Below is a quick 'n dirty command to get the job done.

sudo docker volume rm $(sudo docker volume ls -q)
@thinkjrs
thinkjrs / python-date-range.md
Last active February 19, 2023 01:32
Date range in Python

Date Range in Python

This covers how to get a date range in Python using only standard library modules.

The code

"""
MIT LICENSED
(c) 2023 Jason R. Stevens, CFA
"""