Skip to content

Instantly share code, notes, and snippets.

View zephraph's full-sized avatar

Justin Bennett zephraph

View GitHub Profile
@schacon
schacon / better-git-branch.sh
Created January 13, 2024 18:41
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@cowboyd
cowboyd / use-websocket.ts
Created October 31, 2023 15:35
Effection WebSocket Resource
import { type Stream, type Operation, action, each, once, resource, spawn, createChannel, createSignal } from "effection";
export interface WebSocketHandle extends Stream<MessageEvent, CloseEvent> {
send(value: string): Operation<void>;
close(code?: number, reason?: string): Operation<void>;
}
export function useWebSocket(url: string | URL, protocols?: string | string[]) {
return resource<WebSocketHandle>(function*(provide) {
let input = createChannel<string, {code?: number; reason?: string}>();
@ichizok
ichizok / deno.patch
Last active May 31, 2024 06:46
for Solaris/illumos
diff --git a/.cargo/config.toml b/.cargo/config.toml
index f5b2f124b..6cd093e8e 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -23,6 +23,9 @@ rustflags = [
"link-args=-fuse-ld=lld -weak_framework Metal -weak_framework MetalPerformanceShaders -weak_framework QuartzCore -weak_framework CoreGraphics",
]
+[target.x86_64-unknown-illumos]
+rustflags = ["-C", "link-args=-latomic -lffi -lstdc++"]
(defn point-outside-circle [c r p]
(if (< (vec2/dist c p) r)
(vec2/scale (vec2/normalize (vec2/- p c)) r)
p))
(defn circle-tangent-point [c r b dir]
(let [B (point-outside-circle c r b)
cB (vec2/dist c B)
S (vec2/scale (vec2/normalize (vec2/- B c)) r)
@ityonemo
ityonemo / test.md
Last active June 13, 2024 09:10
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@Rich-Harris
Rich-Harris / http-apis.md
Last active November 3, 2022 09:02
Next-gen Node HTTP APIs

I saw this poll on Twitter earlier and was surprised at the result, which at the time of writing overwhelmingly favours option 1:

Screen Shot 2020-09-10 at 10 19 22 AM

I've always been of the opinion that the (req, res, next) => {} API is the worst of all possible worlds, so one of two things is happening:

  • I'm an idiot with bad opinions (very possibly!)
  • People like familiarity
import {useState, useCallback, useRef} from 'react'
// Hook
const useHover = <T extends HTMLElement>(): [
(node?: T | null) => void,
boolean,
] => {
const [value, setValue] = useState(false)
// Wrap in useCallback so we can use in dependencies below
@MaggieAppleton
MaggieAppleton / roam-kanban.css
Created February 3, 2020 09:22
Roam Kanban Styling
.kanban-board {
background-color: #fff;
}
.kanban-card {
background-color: white;
margin: 8px;
box-shadow: 0px 1px 2px #9EB3C0;
padding: 10px;
border-radius: 2px;
@rjhansen
rjhansen / keyservers.md
Last active April 14, 2024 12:28
SKS Keyserver Network Under Attack

SKS Keyserver Network Under Attack

This work is released under a Creative Commons Attribution-NoDerivatives 4.0 International License.

Terminological Note

"OpenPGP" refers to the OpenPGP protocol, in much the same way that HTML refers to the protocol that specifies how to write a web page. "GnuPG", "SequoiaPGP", "OpenPGP.js", and others are implementations of the OpenPGP protocol in the same way that Mozilla Firefox, Google Chromium, and Microsoft Edge refer to software packages that process HTML data.

Who am I?

@gr2m
gr2m / octokit_pika_build_setup.md
Last active August 16, 2019 15:42
This is a living document on JavaScript Octokit’s build setup using pika pack and semantic-release on GitHub Actions

Octokit.js build setup using @pika/pack

Install @pika/pack and build plugins

npm install --save-dev @pika/pack @pika/plugin-build-node @pika/plugin-build-web @pika/plugin-ts-standard-pkg

Configuration