Skip to content

Instantly share code, notes, and snippets.

View krry's full-sized avatar
🐻
busybear

kerry krry

🐻
busybear
View GitHub Profile
did:3:kjzl6cwe1jw149lkwiavaxlr4b0vy59j94rvg0fjx86ujtmzp4unjz87t3su0nh
@krry
krry / use_nvmrc.fish
Last active December 22, 2021 07:12
Sets the node version automagically when changing dirs in fish shell with nvm when .nvmrc is present or in a parent dir
# use_nvmrc.fish
# TODO: save this in `$HOME/.config/fish/conf.d`
# `nvm use` whenever .nvmrc is present in $PWD when using fish shell
# when traveling deeper, use the parent .nvmrc unless otherwise set
# also go back to default nvm when leaving the nvmrc-specified zone
function set_nvm --on-event fish_prompt
# if the current directory hasn't changed, do nothing
{
"0b111111": {
"hexagram": "䷀",
"kingwen": 1,
"name": {
"chinese": "乾",
"pinyin": "Qián",
"english": "The Creative (Heaven)"
},
"trigramPair": {
@krry
krry / accessibility.css
Last active April 7, 2019 00:17
Helper classes for building inclusive, accessible interfaces/experiences
/* from
https://inclusive-components.design/tooltips-toggletips/
"The visually-hidden class corresponds to some special CSS we've discussed before on Inclusive Components.
It hides the <span> visually without stopping it from being read out in screen readers."
*/
.visually-hidden {
clip-path: inset(100%);
@krry
krry / exercise-web-crawler.go
Created March 4, 2019 07:40
An Answer to A Tour of Go Exercise: Web Crawler Concurrency
// only touching the Crawl func, as instructed
// https://tour.golang.org/concurrency/10
// Crawl uses fetcher to recursively crawl
// pages starting with url, to a maximum of depth.
func Crawl(url string, depth int, fetcher Fetcher) {
m := map[string]bool{url: true}
var mx sync.Mutex
var wg sync.WaitGroup
var subcrawl func(string, int)
@krry
krry / exercise-equivalent-binary-trees.go
Created March 4, 2019 06:28
An Answer to A Tour of Go Exercise: Equivalent Binary Trees
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@krry
krry / exercise-images.go
Created March 4, 2019 02:34
An answer to A Tour of Go: Exercise: Images
package main
import (
"golang.org/x/tour/pic"
"image"
"image/color"
"math/rand"
"fmt"
)
@krry
krry / exercise-rot13-reader.go
Created March 4, 2019 01:55
An answer to A Tour of Go Exercise: Rot13 Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@krry
krry / exercise-readers.go
Created March 4, 2019 01:09
An answer to A Tour of Go Exercise: Readers
package main
import "golang.org/x/tour/reader"
type MyReader struct{}
// TODO: Add a Read([]byte) (int, error) method to MyReader.
func (reader MyReader) Read(b []byte) (int, error) {
for i := range b {
b[i] = 'A'