Skip to content

Instantly share code, notes, and snippets.

@jstarrdewar
jstarrdewar / http
Created September 30, 2012 00:36
Convenient way to launch WEBrick to serve the current directory and prevent caching.
#!/usr/bin/env ruby
require 'webrick'
class NonCachingFileHandler < WEBrick::HTTPServlet::FileHandler
def prevent_caching(res)
res['ETag'] = nil
res['Last-Modified'] = Time.now + 100**4
res['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'
res['Pragma'] = 'no-cache'
res['Expires'] = Time.now - 100**4
@karpathy
karpathy / min-char-rnn.py
Last active July 27, 2025 12:08
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@michaeltelford
michaeltelford / extract.rb
Last active July 23, 2025 17:02
Ruby script using Wgit to extract the meaningful content from a webpage (without the crap e.g. cookie banners)
require "wgit"
# Remove the default extractors since we won't be using them.
Wgit::Document.remove_extractors
# The default name of the output file containing the clean HTML.
def default_file_name
"webpage.html"
end