Skip to content

Instantly share code, notes, and snippets.

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

Enterprise Software Architecture nxpatterns

🍀
I will always be polite to you, even if you're not; you can at most be blocked.
View GitHub Profile
@nxpatterns
nxpatterns / grpo_demo.py
Created January 31, 2025 08:45 — forked from willccbb/grpo_demo.py
GRPO Llama-1B
# train_grpo.py
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
# Load and prep dataset
@nxpatterns
nxpatterns / contemplative-llms.txt
Created January 7, 2025 09:53 — forked from Maharshi-Pandya/contemplative-llms.txt
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
@nxpatterns
nxpatterns / dec64.nasm
Created April 14, 2023 07:33 — forked from jamesdiacono/masm_to_nasm.sh
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
@nxpatterns
nxpatterns / 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'
@nxpatterns
nxpatterns / 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');
@nxpatterns
nxpatterns / 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();
});
}
@nxpatterns
nxpatterns / 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

@nxpatterns
nxpatterns / 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{})
}()