Skip to content

Instantly share code, notes, and snippets.

View armchair-traveller's full-sized avatar
🔥
GPT-4. This is fine.

Armchair Traveller armchair-traveller

🔥
GPT-4. This is fine.
View GitHub Profile
@armchair-traveller
armchair-traveller / +page.svelte
Created June 19, 2024 22:06
IMX Ray bottom hanging action bar backup
<script>
import { binX, lineY, rectY } from '@observablehq/plot'
import CarbonThumbsDown from '~icons/carbon/thumbs-down'
import CarbonThumbsDownFilled from '~icons/carbon/thumbs-down-filled'
import CarbonThumbsUp from '~icons/carbon/thumbs-up'
import CarbonThumbsUpFilled from '~icons/carbon/thumbs-up-filled'
import CornerDownLeft from '~icons/lucide/corner-down-left'
import Mic from '~icons/lucide/mic'
import Paperclip from '~icons/lucide/paperclip'
import { browser } from '$app/environment'
@armchair-traveller
armchair-traveller / md_extractor.fish
Created January 3, 2024 13:07
File Content Extractor (to markdown)
# Just run this straight in fish shell!
# Define the output file
set output_file "output.md"
# Empty the output file if it already exists
if test -f $output_file
echo "" > $output_file
end
# Find all files in the src directory and its subdirectories
@armchair-traveller
armchair-traveller / .eslintrc.cjs
Last active January 2, 2024 02:30
ESLint SvelteKit
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:svelte/recommended',
'prettier',
'plugin:unicorn/recommended',
'plugin:sonar/recommended',
],
@armchair-traveller
armchair-traveller / grokking_to_leetcode.md
Created May 29, 2022 18:29 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

<!-- @component Provides a generic UI that indicates that page is loading -->
<script>
import { onMount } from 'svelte';
import { fade } from 'svelte/transition';
let hidden = true;
// Loading indicators can actually be a jarring distraction for the user when your app is loading fast (e.g. when cached or good connection), so we only show it to them when their connection is slow or services aren't responding as fast as they should be.
onMount(() => setTimeout(() => (hidden = false), 2500));
</script>
<section class="grid h-full place-items-center">
// Courtesy of: https://www.smashingmagazine.com/2021/07/dynamic-header-intersection-observer/
// * A little weird when scrolling up on high height dimensions, but more performant. A complete solution would require significantly more logic see: https://benfrain.com/building-a-table-of-contents-with-active-indicator-using-javascript-intersection-observers/
let curContSect = '';
onMount(() => {
const observer = new IntersectionObserver(([entry]) =>
entry.isIntersecting && (curContSect = entry.target.querySelector('.section-heading').id), { threshold: 0 })
for (let el of [...document.querySelectorAll('.section-heading')]) observer.observe(el.closest('section'))
return () => observer.disconnect();
});
@armchair-traveller
armchair-traveller / twAccessibleProgressbar.svelte
Last active April 7, 2022 18:30
accessible progressbar [Tailwind]
<!-- progress bar, accessible — see: https://courses.joshwcomeau.com/css-for-js/03-components/18-workshop-progress & https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_progressbar_role -->
<div
class="h-2 rounded-full bg-teal-600"
name="remote tactile funding progress indicator"
role="progressbar"
aria-valuenow={value}
aria-valuemin={0}
aria-valuemax={100}
style="width: {value}%; transition: width 2s"
>
@armchair-traveller
armchair-traveller / parser.js
Last active August 23, 2022 18:45
better-comments svelte support
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const vscode = require("vscode");
class Parser {
constructor() {
this.tags = [];
this.expression = "";
this.delimiter = "";
@armchair-traveller
armchair-traveller / App.svelte
Last active June 25, 2021 00:20
[Svelte] onMount doesn't have to be defined/called specifically in the component
<script>
import mountIt from './mountIt';
mountIt(); // logs when the component is mounted. Must be called in the component's script tag, during initialization.
// if you want to get a value out of the onMount, you could use promises, reactive declarations, stores, etc.
</script>
@armchair-traveller
armchair-traveller / App.svelte
Last active June 24, 2021 23:15
[Svelte] Attach components to classes/objects for use in template
<script>
import Menu from "./Menu"
</script>
<Menu>
<!-- the Items component on the Menu component's (class) Items property -->
<Menu.Items />
</Menu>