Skip to content

Instantly share code, notes, and snippets.

View travishorn's full-sized avatar
💡
Trying new ideas

Travis Horn travishorn

💡
Trying new ideas
View GitHub Profile
@travishorn
travishorn / no-history-filter-change.js
Last active July 20, 2023 20:05
Submit form on control change without pushing new state to history
// A pattern I often find myself using consists of a report-type page that
// displays any amount of data. At the top of that page is a `<form>` containing
// one or more `<select>` elements whose purpose is to filter the data on the
// report.
// The form uses `method="GET"`, which is great to make sure that the URL stays
// in line with what the page shows. A user can bookmark/favorite the URL and
// come back to it later. A user can share the URL so other users can see
// exactly the same page.
@travishorn
travishorn / _Svelte-Settings.md
Last active June 2, 2023 13:23
The git pre-commit hook and the VS Code settings I use when developing Svelte apps.

The git pre-commit hook and the VS Code settings I use when developing Svelte apps.

@travishorn
travishorn / Filter.tsx
Created May 13, 2023 04:32
Next.js Headless UI Listbox as Selection Filter
import { useState } from 'react'
import { useRouter } from 'next/router';
import { Listbox } from '@headlessui/react'
import { ChevronUpDownIcon } from '@heroicons/react/20/solid'
import queryString from "query-string";
export interface FilterOption {
value: string;
label: string;
}
@travishorn
travishorn / clone-identity.sh
Created April 17, 2023 03:53
git clone via SSH with an identity file (private key)
git clone myusername@myserver:/home/git/myrepo
# `myusername` is your username on the server which hosts a bare git repository
# `myserver` is a `Host` configured in `~/.ssh/config` on your local machine
# `/home/git/myrepo` is the path to the bare repository on the server
@travishorn
travishorn / cargo-watch.sh
Created April 17, 2023 03:39
Cargo Watch - Reload and run Rust code on change
cargo watch -c -w src -x run
# -c : Clear the terminal before each reload
# -w : Which files to watch
# -x : What command to execute
# cargo-watch must be installed.
cargo install cargo-watch
@travishorn
travishorn / genericFunctions.ts
Last active January 22, 2023 22:47
TypeScript Generics
function getFilledArray<T>(value: T, n: number): T[] {
return Array(n).fill(value);
}
let stringArray: string[];
let numberArray: number[];
let personArray: {name: string, age: number}[];
let coordinateArray: [number, number][];
// Write your code below:
@travishorn
travishorn / _pure-esm-package.md
Last active February 8, 2022 03:40
npm init for pure ESM package

Use this package.json for initializing new npm packages. It will make the package a pure ESM package. Feel free to fork this and replace the author and/or license information.

@travishorn
travishorn / ._ESLint-Prettier.md
Last active June 7, 2023 16:38
Set up project with ESLint and Prettier

Install the VS Code extension:

  1. Open VS Code
  2. Ctrl + Shift + X
  3. Search for "ESLint"
  4. Click the blue "Install" button

In your project, install the dependencies

@travishorn
travishorn / vue-todo-localstorage.html
Created August 30, 2018 14:11
A very simple todo app with Vue using LocalStorage
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.min.css">
<style>
.completed { text-decoration: line-through; }
@travishorn
travishorn / download-classdojo-media.md
Last active February 4, 2024 08:09
Saving the images and videos from your ClassDojo storyline

Archived

Please see Patrick330's fork of this script.

ClassDojo changes their site regularly, so a script like this needs regular maintenance. I have decided to archive this project and stop providing updates. Patrick330's fork linked above may be a good alternative.

Original Purpose

ClassDojo is a classroom communication app used to share reports between parents and teachers. Teachers track student behavior and upload photos or videos. The gamification style system teaches developmental skills through real-time feedback.