Skip to content

Instantly share code, notes, and snippets.

@metaphox
metaphox / microgpt.py
Created March 1, 2026 17:25 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@metaphox
metaphox / DCPU-16Spec.txt
Created October 14, 2012 09:40
DCPU-16 Specification
DCPU-16 Specification
Copyright 1985 Mojang
Version 1.7
=== SUMMARY ====================================================================
* 16 bit words
* 0x10000 words of ram
@metaphox
metaphox / gist:1644401
Created January 20, 2012 01:34
Fixing the postgresql initdb fatal shared memory error on Leopard
Fixing the postgresql initdb fatal shared memory error on Leopard
Published Tue 18 December 2007 11:09 (+1300)
Tagged
software (43 posts and 3 photos)
mac os x (6 posts)
When doing the post-install setup of postgresql default database using initdb, you may hit this error:
FATAL: could not create shared memory segment: Cannot allocate memory
DETAIL: Failed system call was shmget(key=1, size=1646592, 03600).
@metaphox
metaphox / QtPlayer.py
Last active June 17, 2023 19:21
probing frame number
#!/usr/bin/env python
#############################################################################
##
## Copyright (C) 2013 Riverbank Computing Limited.
## Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
## All rights reserved.
##
## This file is part of the examples of PyQt.
#!/bin/bash
SCRIPTNAME=`basename "$0"`
print_help() {
cat << EOF
Usage: $SCRIPTNAME filename
Uses 'inotifywait' to sleep until 'filename' has been modified.
Inspired by http://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes/181543#181543
@metaphox
metaphox / gist:1755841
Created February 6, 2012 23:23
General principles for good URI design
General principles for good URI design:
Don't use query parameters to alter state
Don't use mixed-case paths if you can help it; lowercase is best
Don't use implementation-specific extensions in your URIs (.php, .py, .pl, etc.)
Don't fall into RPC with your URIs
Do limit your URI space as much as possible
Do keep path segments short
Do prefer either /resource or /resource/; create 301 redirects from the one you don't use
Do use query parameters for sub-selection of a resource; i.e. pagination, search queries
@metaphox
metaphox / terminwatch.py
Created April 15, 2012 23:28
watch shanghai german consulate termin
#!/usr/bin/env python
#-*- coding: utf-8 -*-#
import smtplib, time, urllib2
from bs4 import BeautifulSoup
from email.mime.text import MIMEText
def mailme(message):
msg = MIMEText(message)
msg['Subject'] = 'German Consu Termin!'
msg['From'] = 'fox@antares.metaphox.com'
" MINIMAL VERSION WITHOUT ANY DEPENDENCY
" For compatibility's sake, all defaults that are different between Vim and
" Neovim are excplicity specified again.
" look and feel
set t_Co=256
set background=dark
" remove windows toolbar
@metaphox
metaphox / bling.js
Last active June 14, 2020 00:30 — forked from paulirish/bling.js
/* bling.js */
window.$ = document.querySelectorAll.bind(document)
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn)
}
NodeList.prototype.__proto__ = Array.prototype
@metaphox
metaphox / toolbox.md
Last active June 2, 2020 10:29
Toolbox Construction

Rebuild Your OS X Toolbox: A Reminder

From Metaphox for Metaphox

Prerequisites

  1. XCode
  2. xcode-select --install
  3. iTerm2 http://iterm2.com/