Skip to content

Instantly share code, notes, and snippets.

View lawrencejones's full-sized avatar

Lawrence Jones lawrencejones

View GitHub Profile
@lawrencejones
lawrencejones / Make.config
Created February 3, 2014 17:44
Platform compatible
# -*- makefile -*-
SHELL = /bin/sh
VPATH = $(SRCDIR)
# Binary utilities.
# If the host appears to be x86, use the normal tools.
# If it's x86-64, use the compiler and linker in 32-bit mode.
# Otherwise assume cross-tools are installed as i386-elf-*.
################################################################################
# Seed data
################################################################################
CITIES = { # LAT, LONG
london: [51.5072, 0.1275]
manchester: [53.4667, 2.2333]
newcastle: [54.9740, 1.6132]
bristol: [51.4500, 2.5833]
southampton: [50.8970, 1.4042]
@lawrencejones
lawrencejones / c_prototype
Created February 16, 2014 22:37
Generates C function stubs
function! GenPrototypes(reg)
let fs=[]
let l:space = '\_s\{-}'
let l:keywd = '\(\(\w\+\s\+\)\+\)' . l:space ") #1
let l:rtype = '\(\w\+\)' . l:space ") #3
let l:fname = '\(\w\+\)' . l:space ") #4
let l:parms = '\((.*)\)' . l:space ") #5
let l:block = '\({\_.\{-}}\)'
let l:regex = l:keywd . l:rtype
\ . l:fname . l:parms
@lawrencejones
lawrencejones / Make.tests
Last active August 29, 2015 13:56
Makes test output colorful- yay\!
# -*- makefile -*-
include $(patsubst %,$(SRCDIR)/%/Make.tests,$(TEST_SUBDIRS))
# Colors!
GREEN =\e[01;38;5;82m
PINK =\e[01;38;5;197m
D =\e[01;37;40m
CLRCOL =\e[0m
@lawrencejones
lawrencejones / b2.coffee
Last active August 29, 2015 13:56
Implements priority donation according to the Imperial Pintos Specification (based on thread niceness and recent cpu time), using Round Robin ordering of threads
PRI_MAX = 63
RUN_TIME = 36/4
TIMER_INTERVAL = 4
TICKS_PER_SEC = 100
crrt = null
ticks = 0
create_thread = (name, nice, pri = PRI_MAX) ->
{ name: name, p: pri, n: nice, rcpu: 0 }
@lawrencejones
lawrencejones / pintos.sh
Created March 2, 2014 12:18
SCP's relevant pintos tools from one machine to another
#!/bin/bash
echo Enter MacBook Air IP:
read IP
echo Enter username for MacBook Air:
read USR
export MBA=$USR@$IP
echo Transferring...
scp -r $MBA:/usr/local/pintos-utils /usr/local/
scp -r $MBA:/usr/local/i386-elf-gcc /usr/local/
@lawrencejones
lawrencejones / DivdeAndConquer.make
Created March 2, 2014 13:33
Makefile for algorithms divide and conquer
# Makefile for Divide and Conquer
## LIST - all categories of source
## TEST - all test related source
## ANAL - all analyse related source
LDFLAGS = -lm -lstdc++
CXXFLAGS = -Wall -g
CXX=g++
VPATH= c++
#include "userprog/exception.h"
#include "userprog/gdt.h"
#include "userprog/pagedir.h"
#include <inttypes.h>
#include <stdio.h>
#include "threads/interrupt.h"
#include "threads/thread.h"
#include "threads/pte.h"
#include "vm/page.h"
In kernel.o:
0xc0020c92: thread_foreach (..../../threads/thread.c:532)
0xc0028ada: debug_backtrace_all (...../lib/kernel/debug.c:122)
0xc002bf7c: page_fault (.../userprog/exception.c:178)
0xc002207d: intr_handler (..../threads/interrupt.c:367)
0xc0022280: intr_entry (threads/intr-stubs.S:38)
In kernel.o:
0xc0020c92: thread_foreach (..../../threads/thread.c:532)
@lawrencejones
lawrencejones / get_token.sh
Last active August 29, 2015 13:58
Example of how to pull data from new cate api.
#!/bin/sh
echo "Enter college login:"
read user
echo "Enter password:"
read -s pass; echo
creds="{\"user\":\"$user\",\"pass\":\"$pass\"}"
# Pull JSON { token: <token> }