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
@jamesdiacono
jamesdiacono / dec64.nasm
Last active May 10, 2023 10:47
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
@rauschma
rauschma / README.md
Last active May 10, 2023 09:53
Better dynamic type checks

Better dynamic type checks

  • Update 2022-07-10: new approach based on Function.prototype.hasInstance()

Problems

In principle, the rule “typeof is for primitive values, instanceof is for objects” works. There are two exceptions:

  • Checking if a value is an object
  • Cross-realm instance checks
@LironHazan
LironHazan / preventDDOS.ts
Created October 13, 2020 17:04
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');
@LironHazan
LironHazan / registerTransitionEnd.ts
Last active January 26, 2022 07:50
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();
});
}
@LironHazan
LironHazan / close-that-stream-if-no-need.ts
Created October 10, 2020 06:14
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) {
@rickdaalhuizen90
rickdaalhuizen90 / .zshrc
Created July 13, 2020 18:03
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"
@kivikakk
kivikakk / whitelist.md
Created November 16, 2018 02:18
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,
@ltciro
ltciro / Observable_in_vanillaJS.md
Last active January 20, 2023 11:16
simulate pattern observable in vanilla JS

Rxjs

const next = (message)=> console.log("First observer message: " + message);
const error = (error) => console.log("Second observer error: " + error);
const complete = () => console.log("complete");

const next1 = (message)=> console.log("First observer message 1: " + message);
const error1 = (error) => console.log("Second observer error 1: " + error);
const complete1 = () => console.log("complete 1");
@magnetikonline
magnetikonline / README.md
Last active February 4, 2024 07:45
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
@marians
marians / CouchDB_Python.md
Last active April 9, 2024 12:21
The missing Python couchdb tutorial

This is an unofficial manual for the couchdb Python module I wish I had had.

Installation

pip install couchdb

Importing the module