Skip to content

Instantly share code, notes, and snippets.

View Protonk's full-sized avatar
🗯️
Before the hinge

Adam Hyland Protonk

🗯️
Before the hinge
View GitHub Profile
@Protonk
Protonk / sisr.R
Created December 11, 2024 18:20
Slow Inverse Square Root
## there are simpler ways to do this in R. See
## for example https://github.com/itchyny/fastinvsqrt/blob/main/src/r/fastinvsqrt.r
## contains a reasonable way to do this unreasonable thing.
## What follows is an unreasonable way to do an unreasonable thing.
doubleTofloatBits <- function(x) {
# Convert double to character in scientific notation
x_char <- format(x, scientific = TRUE)
# Parse the character representation
@Protonk
Protonk / kadlec-blend.R
Last active December 8, 2024 19:58
Kadlec plotting
### Compare original and adjusted values
library(dplyr)
library(ggplot2)
library(latex2exp)
## blends from standard form to original Kadlec constants
## A = 0.70395 & B = 2.38924
original_kadlec_blend <- read.csv(text = "
input,output,error,diff,iters,alpha
@Protonk
Protonk / NRkadlecplot.R
Last active December 5, 2024 21:19
Kadlec pools without converging
kadlec <- read.csv(text = "
reference,kadlec,iters,error,input
1.189297,1.189539,1,0.000242,0.707000
1.189297,1.162983,2,0.026314,0.707000
1.189297,1.173180,3,0.016117,0.707000
1.189297,1.169557,4,0.019740,0.707000
1.189297,1.170886,5,0.018411,0.707000
1.189297,1.170404,6,0.018893,0.707000
")
@Protonk
Protonk / interstate76-ShanePeelar.c
Created November 18, 2024 19:39
A version of Shane Peelar's discovered FISR in Interstate 76
// accepts a double and splits it, like KahanNg
// See https://inbetweennames.net/blog/2021-05-06-i76rsqrt/
// for more details and the original recovered code (in C++)
// It is different from KahanNg as it splits the double into
// exponent and mantissa, whereas KahanNg splits it into
// high 32 and low 32 bits
double i76ISR(double x, int NR) {
// Interstate76's lookup table generator
// uint8_t LUT[256];
// void generateLUT(){
@Protonk
Protonk / SMBDIS.ASM
Created November 13, 2024 04:58 — forked from 1wErt3r/SMBDIS.ASM
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger ([email protected])
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@Protonk
Protonk / nanof2a.cpp
Created May 8, 2024 19:19 — forked from fpsunflower/nanof2a.cpp
Tiny float to ascii conversion (with lossless roundtrip, based on the Ryu algorithm)
// c++ -O3 -o nanof2a nanof2a.cpp && ./nanof2a
#include <cstdint>
#include <cstring>
namespace { // anonymous namespace to encourage inlining
struct f2a {
char str[16];
f2a(float f) { // example usage: printf("%s", f2a(f).str)
@Protonk
Protonk / allergen.R
Last active November 16, 2023 17:57
Allergy example
food.allergy.analysis.Zenodo <- read.csv("~/Downloads/food-allergy-analysis-Zenodo.csv")
allergyDF <- food.allergy.analysis.Zenodo[, c("SUBJECT_ID", "BIRTH_YEAR", "GENDER_FACTOR", "RACE_FACTOR", "ETHNICITY_FACTOR", "PAYER_FACTOR", "AGE_START_YEARS", "AGE_END_YEARS")]
allergyDF[, "SPAN_IN_YEARS"] <- with(food.allergy.analysis.Zenodo, AGE_END_YEARS - AGE_START_YEARS)
allergyDF[, "SOY_SPAN"] <- with(food.allergy.analysis.Zenodo, SOY_ALG_END - SOY_ALG_START)
allergyDF[, "MILK_SPAN"] <- with(food.allergy.analysis.Zenodo, MILK_ALG_END - MILK_ALG_START)
allergyDF[, "FISH_SPAN"] <- with(food.allergy.analysis.Zenodo, FISH_ALG_END - FISH_ALG_START)
allergyDF[, "SHELLFISH_SPAN"] <- with(food.allergy.analysis.Zenodo, SHELLFISH_ALG_END - SHELLFISH_ALG_START)
@Protonk
Protonk / softsqrt.c
Last active November 18, 2024 19:42
Illustrate the core path of Kahan and Ng's SoftSqrt
/* Kahan and Ng's SoftSqrt
See http://www.netlib.org/fdlibm/e_sqrt.c
or https://adampunk.com/documents/softsqrt.pdf (for the original)
specifically section B. 1 of the comment block labeled "other methods"
Method for operating in a logarithmic domain described in
section 2.3 "A Poor Man's Logarithm" of
J. T. COONEN, "CONTRIBUTIONS TO A PROPOSED STANDARD FOR BINARY
FLOATING-POINT ARITHMETIC (COMPUTER ARITHMETIC). PhD Thesis,
University of California Berkeley, 1984.

Evaluate an article

Handout: Evaluating Wikipedia

  • Review pages 4-7 of the Evaluating Wikipedia brochure. This will give you a good, brief overview of what to look for in other articles, and what other people will look for in your own.
  • Evaluate an existing Wikipedia article related to the class, and leave suggestions for improving it on the article's talk page.
    • A few questions to consider (don't feel limited to these):
      • Is each fact referenced with an appropriate, reliable reference?
      • Is everything in the article relevant to the article topic? Is there anything that distracted you?
      • Is the article neutral? Are there any claims, or frames, that appear heavily biased toward a particular position?
      • Where does the information come from? Are these neutral sources? If biased, is that bias noted?
  • Are there viewpoints that are overrepresented, or underrepresented?