Skip to content

Instantly share code, notes, and snippets.

View ericclemmons's full-sized avatar
🏠
Working from home

Eric Clemmons ericclemmons

🏠
Working from home
View GitHub Profile
@trvswgnr
trvswgnr / compress_video
Last active November 12, 2024 21:17
portable shell script to compress videos with ffmpeg
#!/bin/sh
print_usage() {
echo "usage: compress_video <input_file>"
echo "supported formats: mp4, webm, mkv, mov, avi, flv"
}
get_extension() {
f="${1##*/}"
case "$f" in
# https://github.com/dependabot/fetch-metadata#enabling-auto-merge
name: Auto-merge Dependabot
on: pull_request_target
permissions:
pull-requests: write
contents: write
jobs:
@OrionReed
OrionReed / dom3d.js
Last active November 15, 2024 17:48
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@KristofferEriksson
KristofferEriksson / useTextSelection.ts
Last active September 25, 2024 22:14
A React Typescript hook that tracks user text selections & their screen positions
import { useEffect, useState } from "react";
type UseTextSelectionReturn = {
text: string;
rects: DOMRect[];
ranges: Range[];
selection: Selection | null;
};
const getRangesFromSelection = (selection: Selection): Range[] => {
@rauchg
rauchg / p.sh
Last active October 16, 2024 00:32
Perplexity CLI in pure shell
#!/usr/bin/env bash
function p() {
jq -n \
--arg content "$*" \
'{
"model": "pplx-7b-online",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
@vgel
vgel / chunkpaper.py
Created November 8, 2023 20:34
ar5iv
# pip install beautifulsoup4 requests markdownify mistletoe
# command line usage: python chunkpaper.py 'https://ar5iv.org/abs/1910.06709'
# will dump the HTML, Markdown, and finally the chunk JSON
# note that (as of Nov 8 '23) ar5iv only has arxiv papers converted up to the end of October,
# but if you need something more recent you could probably do the LaTeX→HTML conversion yourself
# library usage: call `chunk` with some ar5iv HTML. will probably choke on anything else
import dataclasses
// Adapted from https://github.com/go717franciswang/peerjs-chatroom
const CLIENT_MSG = {
CHAT: 1,
GET_MEMBERS: 2,
};
const SERVER_MSG = {
CHAT: 1,
MEMBERS: 2,
@souporserious
souporserious / build.mjs
Created February 24, 2022 02:48
Build script using esbuild and ts-morph to bundle library code.
import glob from 'fast-glob'
import { build } from 'esbuild'
import { Project } from 'ts-morph'
const project = new Project({
compilerOptions: {
outDir: 'dist',
emitDeclarationOnly: true,
},
tsConfigFilePath: './tsconfig.json',
@oieduardorabelo
oieduardorabelo / .env.example
Created February 24, 2021 05:11
Sample of Cognito with Server-Sider Authentication
PORT=xxx
COGNITO_USER_POOL_ID=xxx
COGNITO_CLIENT_ID=xxx
COOKIE_SESSION_SECRET=xxx
COOKIE_SESSION_NAME=xxx
AWS_REGION=xxx
AWS_ACCESS_KEY_ID=xxx
AWS_SECRET_ACCESS_KEY=xxx
@jaredpalmer
jaredpalmer / MarkdownPage.tsx
Created February 17, 2021 13:52
Get headers from MDX in Next.js
import {MDXProvider} from '@mdx-js/react';
import {MDXComponents} from 'components/MDX/MDXComponents';
import {Toc} from 'components/Toc/Toc';
import * as React from 'react';
export interface MarkdownProps<Frontmatter> {
meta: Frontmatter;
children?: React.ReactNode;
}