Skip to content

Instantly share code, notes, and snippets.

View klange's full-sized avatar
🤔
Contemplative.

K Lange klange

🤔
Contemplative.
View GitHub Profile
@klange
klange / gist:801253
Created January 28, 2011 23:40
ext2fs y u no make constants the same width
#define EXT2_FLAG_RW 0x01
#define EXT2_FLAG_CHANGED 0x02
#define EXT2_FLAG_DIRTY 0x04
#define EXT2_FLAG_VALID 0x08
#define EXT2_FLAG_IB_DIRTY 0x10
#define EXT2_FLAG_BB_DIRTY 0x20
#define EXT2_FLAG_SWAP_BYTES 0x40
#define EXT2_FLAG_SWAP_BYTES_READ 0x80
#define EXT2_FLAG_SWAP_BYTES_WRITE 0x100
#define EXT2_FLAG_MASTER_SB_ONLY 0x200
@klange
klange / gist:852477
Created March 3, 2011 07:45
So close, and yet, still quite far away.
[ToAruOS 0.0.1]
MULTIBOOT header at 0x00009500:
Flags : 0x0000004f Mem Lo: 0x00000280 Mem Hi: 0x00060000 Boot d: 0x8001ffff
cmdlin: 0x00009700 Mods : 0x00000001 Addr : 0x00009600 Syms : 0x00000000
Syms : 0x00000000 Syms : 0x00000000 Syms : 0x00000000 MMap : 0x00000078
Addr : 0x00009000 Drives: 0x00000000 Addr : 0x00000000 Config: 0x00000000
Loader: 0x00000000 APM : 0x00000000 VBE Co: 0x00000000 VBE Mo: 0x00000000
VBE In: 0x00000000 VBE se: 0x00000000 VBE of: 0x00000000 VBE le: 0x00000000
Started with: toaruos-kernel
640kB lower memory
@klange
klange / gist:886417
Created March 25, 2011 05:56
toaru's internal sbrk()
void *
sbrk(
uintptr_t increment
) {
ASSERT(increment % 0x1000 == 0);
ASSERT(heap_end % 0x1000 == 0);
uintptr_t address = heap_end;
heap_end += increment;
uintptr_t i;
for (i = address; i < heap_end; i += 0x1000) {
@klange
klange / gen-sk.py
Created May 6, 2011 01:12
LastFM session key generator
#!/usr/bin/env python
import sys, md5
import pycurl, simplejson, webbrowser
class CurlReader:
def __init__(self):
self.contents = ''
def body_callback(self, buf):
self.contents = self.contents + buf
BITS 32
global _start
_start:
pop eax
extern main
call main
mov ebx, eax
mov eax, 0x0
int 0x7F
@klange
klange / TransparentLabel.cs
Created January 6, 2012 23:59
Stroked Transparent Label
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Linq;
using System.Windows.Forms;
public class TransparentLabel : Label {
public TransparentLabel() {
@klange
klange / hw.tex
Created January 19, 2012 07:48
Homework template
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{enumerate}
@klange
klange / gist:1651197
Created January 21, 2012 03:56
Bumblebee!
[klange piko 01/20 21:55:09 1 ~]
$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 02)
01:00.0 VGA compatible controller: nVidia Corporation GT218 [NVS 3100M] (rev a2)
[klange piko 01/20 21:55:34 130 ~]
$ optirun glxspheres # nVidia
Polygons in scene: 62464
Visual ID of window: 0x21
Context is Direct
OpenGL Renderer: NVS 3100M/PCI/SSE2
@klange
klange / image-to-ansi.py
Created January 27, 2012 06:29 — forked from MicahElliott/colortrans.py
Convert images to ANSI escape sequences
#! /usr/bin/env python
""" Convert an image (argv[1]) to an ANSI text string (xterm-256color)
Original readme from colortrans.py follows:
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
#include <stdio.h>
int main(int argc, char * argv[]) {
int i;
for (i = 1; i <= 100; ++i) {
if ((i % 5) && (i % 3)) {
printf("%d", i);
} else {
if (!(i % 3)) {
printf("Fizz");