Skip to content

Instantly share code, notes, and snippets.

@coryhouse
coryhouse / AllComponents.test.ts
Created May 25, 2022 19:02
Enforce tests exist for each component
// This file assures that a Jest test file and Cypress test file exists for each component.
import path from "path";
import fs from "fs";
function getFiles(filepath: string) {
return fs.readdirSync(filepath).filter(function (file) {
return fs.statSync(path.join(filepath, file)).isFile();
});
}
@j-bullard
j-bullard / App.tsx
Created July 4, 2021 07:15
Headless UI with React Hook Forms
import "./styles.css";
import { Person } from "./types";
import { Listbox } from "./listbox/listbox";
import { useForm } from "react-hook-form";
const people: Person[] = [
{ id: 1, name: "Durward Reynolds", unavailable: false },
{ id: 2, name: "Kenton Towne", unavailable: false },
{ id: 3, name: "Therese Wunsch", unavailable: false },
{ id: 4, name: "Benedict Kessler", unavailable: true },
<link rel="shortcut icon" width=32px>
<canvas style="display: none" id="loader" width="16" height="16"></canvas>
<script>
class Loader {
constructor(link, canvas) {
this.link = link;
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.context.lineWidth = 2;
@flybayer
flybayer / Link.tsx
Last active July 1, 2021 07:40
Much nicer and more intuitive Next.js Link abstraction
git rm -r --cached .
git add .
git commit -m ".gitignore fix"
@pqt
pqt / reset_git_history.sh
Created March 26, 2020 03:30
Are you about to open-source a private repository? Do you want to squash all history into a single commit before making the code public? This one-liner takes care of it
# Modified slightly from https://twitter.com/mathias/status/1045312837671882752
git reset $(git commit-tree HEAD^{tree} -m 'first commit')
@sr2ds
sr2ds / gitlab-ci.yml
Created January 16, 2019 17:27
Continuous Integration - Laravel GitLab on Heroku
image: lorisleiva/laravel-docker:latest
phpunit:
stage: test
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
- phpunit --colors=never
@bendc
bendc / simulate-typing.js
Created September 1, 2017 08:57
Fake typing animation
const trackTime = timing => {
const now = performance.now();
if (!timing.startTime) timing.startTime = now;
const elapsed = now - timing.startTime;
const {duration} = timing;
if (duration != null && duration <= elapsed) timing.startTime = null;
return elapsed;
};
const delay = (callback, duration) => {
@CodeMyUI
CodeMyUI / index.jade
Created May 28, 2017 03:40
Sticky Avatars Dashboard
- var images = [ 'https://static.pexels.com/photos/5938/food-salad-healthy-lunch-medium.jpg', 'https://static.pexels.com/photos/5927/food-salad-red-lunch-large.jpg', 'https://static.pexels.com/photos/6118/food-water-corn-cooking-medium.jpg', 'https://static.pexels.com/photos/5876/food-salad-healthy-vegetables-medium.jpg', 'https://static.pexels.com/photos/5928/salad-healthy-diet-spinach-medium.jpg'];
.container
ul.posts
each img in images
li.post
.post-content
header: a(href="https://twitter.com/@kamciesla") @kamciesla posted this
img(src=img)
footer
a(href="https://kamilciesla.pl")
@staringispolite
staringispolite / asciiputsonglasses
Last active March 22, 2024 06:39
Ascii art sunglasses meme
Puts on glasses:
(•_•)
( •_•)>⌐■-■
(⌐■_■)
Takes off glasses ("mother of god..."):
(⌐■_■)
( •_•)>⌐■-■