Skip to content

Instantly share code, notes, and snippets.

@internetsadboy
internetsadboy / translate_address.c
Created November 9, 2014 02:26
Translate a 32-bit virtual (hexadecimal) address and produce its corresponding page number and page offset for a system with 8-KB pages.
#include <stdlib.h>
#include <stdio.h>
#define PAGE_SIZE 8192
/*
* main
*
* Translate a 32-bit virtual (hexadecimal) address and produce
* its corresponding page number and page offset for a system
@internetsadboy
internetsadboy / concat.py
Created November 5, 2014 23:36
Project X: concat.py
"""
Jared Halpert
11/5/14
concat
Concatenate two lists of elements composed of any data type
into one list of elements composed of any data type
@param {list} a list of elements
@internetsadboy
internetsadboy / CenterImage.java
Last active August 29, 2015 14:08
690 Midterm: derive display parameters for centering an image in a display area.
/*
* CenterImage
*
* Derive display parameters for centering an image within an arbitrary display area
*
* @build Processing sketch app
* @fileType .pde
* @description no physical image used, the image is defined by its dimensions (w, h) and position (x, y)
*/
@internetsadboy
internetsadboy / 1d2d.py
Last active August 29, 2015 14:08
690 Midterm: use a 1D array to simulate a 2D array.
"""
Problem: use 1D array to simulate 2D array
"""
array_1D = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
array_2D = [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11]]
"""
simulate_2D_array
@internetsadboy
internetsadboy / api.json
Last active August 29, 2015 14:04
swaggerize-express example from docs
{
"apiVersion": "0.0.1",
"swaggerVersion": "1.2",
"apis": [
{
"path": "/foo",
"description": "test foo.js"
}
]
}
// Euler's Method
// http://en.wikipedia.org/wiki/Euler_method
// user input: n, d, x, and poly
// poly: dx/dt == f(t,x)
// n: # of steps
// d: domain a <= t <= b
// x: initial value
// h: step size
// t: the delta of current steps taken