Skip to content

Instantly share code, notes, and snippets.

View rain-1's full-sized avatar
☂️
Umbrella

rain1 rain-1

☂️
Umbrella
View GitHub Profile
@rain-1
rain-1 / GPT-4 Reverse Turing Test.md
Last active October 8, 2024 02:59
GPT-4 Reverse Turing Test

The reverse turing test

I asked GPT-4 to come up with 10 questions to determine if the answerer was AI or human.

I provided my own answers for these questions and I also asked ChatGPT to answer them.

The result is that GPT-4 was able to correctly differentiate between AI and Human.

@rain-1
rain-1 / LLM.md
Last active March 27, 2025 13:51
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

@rain-1
rain-1 / 0-MNIST.md
Last active March 25, 2023 03:41
MNIST digit classification

MNIST digit recognition

The pytorch (neural network library) examples include a script to try out the training process for MNIST digit recognition data set: https://github.com/pytorch/examples/tree/main/mnist

This builds up a convolutional neural network that takes one of these pictures and processes it down to 10 neurons. The training process uses two sets of labelled data (examples of pictures of digits and which of the 10 possible digits they are): One training set and one testing set. The training set is used to manipulate all of the "weights" inside the neural network by moving in the (very high dimensional) direction of fastest descent, aiming to get the output neurons to produce the intended label given the input picture. The testing set is used as a metric to say how well the neural network is doing.

I ran this, creating mnist_cnn.pt with 99% accuracy on the test data set.

Then I wanted to see if it worked, so I drew images of all 10 digits. There was no way to try this out so I wrote the attach

@rain-1
rain-1 / best fit blog.md
Last active March 6, 2023 01:13
least squares

Introduction

This blog post is about the Linear Least Squares Problem. This method is credited back to Legendre and Gauss, some of my favorite mathematicians. Why are they such inspiring people? Here is a passage from a post that goes into more depth about Gauss's application of least squares:

The 24-year-old Gauss tackled the orbit problem, assuming only Kepler’s three laws of planetary motion, with his newly discovered error distributions and his method of least squares for three months. He spent over 100 hours performing intensive calculations by hand without any mistakes (and without the luxury of today’s computers!). He had to estimate the six parameters of the orbit (as shown in Figure 7) from only 19 data points, subject to random measurement errors. He even invented new techniques such as the Fast Fourier Transform for interpolating trigonometric series, which produced efficient numerical approximations o

@rain-1
rain-1 / Modelling an Uncertain World.md
Last active January 6, 2025 16:54
Modelling an Uncertain World

I have included working code examples that can be run throughout, as well as graphs. I hope this helps make this easier to understand in a more hands on way.

The setup

Suppose you know that there are 10 balls in an urn, some are red and some are blue. So there are 11 different possible models for this situation:

  • M0: 0 red, 10 blue
  • M1: 1 red, 9 blue
  • ...
  • M10: 10 red, 0 blue
@rain-1
rain-1 / ring.md
Created June 26, 2022 18:45
Ring Quotient For Programmers

quick recap on complex numbers

Take a number, square it, the result is non-negative. Because positive * positive = positive and negative * negative is positive. Or $0^2 = 0^2$.

But someone wanted to take square roots of negative numbers, so they did, and called it 'i'. $\sqrt{-1} = i$. A lot of people were frustrated upon learning this "You can't do that!", "How do you know that it doesn't lead to contradictions".

The solution, to put imaginary and complex numbers on a solid foundation is something called a ring quotient. What you do is you start with the ring (meaning number system) of polynomials over the real numbers $R[i]$, which looks like this:

  • $1, 2 3.5, \pi$ etc.
  • $i, i^2, 0.3 + 9.5 i + 23 i^3$ and so on.

How to make a small tweak to free software

The target audience for this is people who are beginners at software engineering and using linux. A lot of the information here may be obvious or already known to you. The language involved is C but you do not need to know any C to read this tutorial. I used mg to write this blog post. I used vs code to edit the source code.

This post is also available on gopher://tilde.team:70/0/~river/tweak-free-software

If you use a piece of free software and it's 99% perfect but there's just this one thing it does that annoys the hell out of you.. you can in theory just fix it! Here's a look at what doing that is like. Hopefully it inspires you, or you pick up a could tricks on the way!

Step 0: Have a problem

@rain-1
rain-1 / a_How is a matrix used to count fish?.md
Last active August 1, 2024 14:29
How is a matrix used to count fish?

This is explaining stuff relevant to AOC 2021 day 6

How is a matrix used to count fish?

First lets do fibonacci numbers because it's smaller (2x2 matrix instead of 9x9) and it's familiar ground.

So you can implement fibs like this:

def fib(n):
@rain-1
rain-1 / docker node tip.txt
Last active December 24, 2021 07:04
Easily build NodeJS projects inside a docker container
Here's a quick dockerfile:
----------------8<-------------[ cut here ]------------------
FROM debian:latest
RUN apt-get update && apt-get install -y nodejs npm
----------------8<-------------[ cut here ]------------------
save that as Dockerfile and do: docker build -t node-builder .
@rain-1
rain-1 / gopher security.md
Created November 11, 2021 21:37
gopher security

HTTPS vs HTTP, security properties

HTTPS provides some very important security properties that HTTP does not.

It provides confidentiality, integrity and authentication.

  • Confidentiality: What you're loading cannot be snooped on by others. Eve is on the same networking as you, and can listen into your traffic - but if it's HTTPS they cannot read it. If it was plain HTTP they could see what you were looking at and copy your session cookies to potentially log in to sites as you.
  • Integrity, Authentication: You know that if a document you recieve is valid it is unmodified. Mallory cannot set up a man in the middle attack and edit the documents in transit, if it was HTTP they could do this with arp poisoning/cain and abel - and change all the images on the pages you are looking at to rick astley.

Implementing confidentiality requires a cipher and a system for keys, initialization vectors and such. It's rather involved.