Skip to content

Instantly share code, notes, and snippets.

View itsbth's full-sized avatar

Bjørn Tore Håvie itsbth

View GitHub Profile
@itsbth
itsbth / upload-to-gist.sublime-settings
Created November 7, 2011 00:40
Uploaded by UploadToGist for Sublime Text 2
{
// Copy any modified settings to `User/upload-to-gist.sublime-settings`
// otherwise modifications will not survive updates.
// "login": "itsbth",
// "token": "",
"public": true,
"description": "Uploaded by UploadToGist for Sublime Text 2"
}
@itsbth
itsbth / gist2.py
Created November 7, 2011 00:56
Uploaded by gist.py
import urllib2
from subprocess import Popen, PIPE
from os import path
import json
import httplib
CREATE_URL = u'https://gist.github.com/gists'
@itsbth
itsbth / main.lua
Created November 7, 2011 00:58
Uploaded by UploadToGist for Sublime Text 2
local Vector
do
local V_MT, sqrt, type, unpack, setmetatable = {}, math.sqrt, type, unpack, setmetatable
V_MT.__index = V_MT
function V_MT:__add(b)
return Vector(self.x + b.x, self.y + b.y)
end
function V_MT:__sub(b)
return Vector(self.x - b.x, self.y - b.y)
@itsbth
itsbth / vm.c
Created November 9, 2011 15:06
Uploaded by UploadToGist for Sublime Text 2
#include "vm.h"
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#define VM_REG_MASK (1<<31)
#define VM_CODE_MASK (1<<30)
#define VM_DATA_MASK ((1<<16)-1)
@itsbth
itsbth / c.py
Created November 9, 2011 15:14
Uploaded by UploadToGist for Sublime Text 2
# -*- coding: utf-8 -*-
# c.py - sublimelint package for checking c files
import re
from base_linter import BaseLinter
CONFIG = {
'language': 'c',
'executable': 'clang',
@itsbth
itsbth / vm.c
Created November 9, 2011 22:28
Uploaded by UploadToGist for Sublime Text 2
#include "vm.h"
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#define VM_REG_MASK (1<<31)
#define VM_CODE_MASK (1<<30)
#define VM_DATA_MASK ((1<<16)-1)
@itsbth
itsbth / Output.txt
Created November 10, 2011 12:59
Uploaded by UploadToGist for Sublime Text 2
➜ radevm ./main
0: MOV VM_REG(0x0), VM_CODE(0x9) [0, 10]
3: ADDI VM_REG(0x0), VM_CODE(0xa) [10, 20]
6: INT VM_CODE(0xb), 0x0 [1, 0]
Interrupt: 1
10 + 20 = 30
@itsbth
itsbth / vm.c
Created November 19, 2011 20:44
Uploaded by UploadToGist for Sublime Text 2
#include "vm.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <assert.h>
struct _vm_state {
int regi[8];
@itsbth
itsbth / main.c
Created November 19, 2011 20:50
Uploaded by UploadToGist for Sublime Text 2
#include <stdio.h>
#include <stdbool.h>
#define VERBOSE
#include "vm.h"
unsigned int code[] = {
/*0*/ INSTR_MOV, VM_REG(0), VM_CODE(9),
/*3*/ INSTR_ADDI, VM_REG(0), VM_CODE(10),
/*6*/ INSTR_INT, VM_CODE(11), 0,
/*9*/ 10, 20, 1,
# 1 "vm.c"
# 1 "vm.c" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 131 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "vm.c" 2
# 1 "./vm.h" 1
# 27 "./vm.h"