Skip to content

Instantly share code, notes, and snippets.

View webia1's full-sized avatar
🍀
I will always be polite to you, even if you're not; you can at most be blocked.

Webia1 webia1

🍀
I will always be polite to you, even if you're not; you can at most be blocked.
  • Milky Way
View GitHub Profile
@webia1
webia1 / dec64.nasm
Created April 14, 2023 07:33 — forked from jamesdiacono/dec64.nasm
The DEC64 number type for Linux, MacOS (Intel and Silicon) and Android. Include these files alongside https://github.com/douglascrockford/DEC64.
; title dec64.nasm for x64.
; dec64.com
; 2022-09-03
; Public Domain
; No warranty expressed or implied. Use at your own risk. You have been warned.
; This file implements the elementary arithmetic operations for DEC64, a decimal
; floating point type. DEC64 uses 64 bits to represent a number. The low order
@webia1
webia1 / appify
Created September 9, 2022 13:15 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh

hasType(): function and protocol for dynamic type checks

The problem

Depending on what kind of type check we want to perform, we have to choose between:

  • Does a value v have a given primitive type – e.g.:
    typeof v === 'string'
@webia1
webia1 / preventDDOS.ts
Created January 26, 2022 07:52 — forked from LironHazan/preventDDOS.ts
Doron Sever's snippet for rxjs post
private myStream = new Subject();
private myStream$ = this.myStream.asObservable();
ngOnInit() {
// Will only fire after 100 ms.
this.myStream$
.pipe(auditTime(100))
.subscribe(e => console.log('will only fire after 100 miliseconds');
@webia1
webia1 / registerTransitionEnd.ts
Created January 26, 2022 07:50 — forked from LironHazan/registerTransitionEnd.ts
Amir Baraks's registerTransitionEnd used in an Angular directive for rxjs blog post
registerTransitionEnd<T extends {propertyName}>(el: FromEventTarget<T>, propName: string) {
// Returns an Observable from DOM event
fromEvent(el, 'transitionend')
.pipe(
filter(({ propertyName }: T) => propertyName === propName) // Will only emit value for the wanted css prop name e.g. height
)
.subscribe((_) => {
this.transitionEnd.emit();
});
}
@webia1
webia1 / close-that-stream-if-no-need.ts
Created January 26, 2022 07:49 — forked from LironHazan/close-that-stream-if-no-need.ts
Irena's stop fetching recipe - for rxjs blog post
private unsubscribeDataFetch: Subject<void> = new Subject<void>();
// polling data till we get what we need and stop
fetchData() {
this.dataService
.pipe(takeUntil(this.unsubscribeDataFetch))
.subscribe((data) => actOnData(data));
}
actOnData(data) {

some tools for diagrams in software documentation

Diagrams For Documentation

Obvious Choices

ASCII

@webia1
webia1 / main.go
Created May 21, 2021 20:38 — forked from filewalkwithme/main.go
Listening multiple ports on golang http servers (using http.Handler)
package main
import (
"net/http"
)
func main() {
go func() {
http.ListenAndServe(":8001", &fooHandler{})
}()
@webia1
webia1 / .zshrc
Created January 13, 2021 15:37 — forked from rickdaalhuizen90/.zshrc
Enhance your terminal with zsh and Prezto
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
@webia1
webia1 / whitelist.md
Created November 26, 2020 21:13 — forked from kivikakk/whitelist.md
HTML sanitizer whitelist for user content on GitHub.com
  • Any allowed id and name attributes have "user-content-" prefixed to their value.
  • A maximum of 2 nested sub or sup tags are allowed.
  • A maximum of 10 nested ul or ol tags are allowed.
Allowed Element Allowed Attributes
All allowed elements abbr, accept, accept-charset, accesskey, action, align, alt, axis, border, cellpadding, cellspacing, char, charoff, charset, checked, clear, color, cols, colspan, compact, coords, datetime, dir, disabled, enctype, for, frame, headers, height, hreflang, hspace, id, ismap, itemprop, label, lang, maxlength, media, method, multiple, name, nohref, noshade, nowrap, open, prompt, readonly, rev, rows, rowspan, rules, scope, selected, shape, size, span, start, summary, tabindex, title, type, usemap, valign, value, vspace, width
a As above plus href (must be github-mac, github-windows, http,