Skip to content

Instantly share code, notes, and snippets.

// 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
@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"
}
]
}
@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 / 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 / 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 / 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 / index.html
Created November 15, 2014 16:52
d3: scalable bar chart
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Scalable Bar Chart Example">
<meta name="author" content="Jared Halpert">
<title>Scalable Bar Chart</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.js">
@internetsadboy
internetsadboy / primes.rb
Last active August 29, 2015 14:11
for n => return [p1, p2] ; where n is an even integer and p1 and p2 are two prime integers that summate to n.
require 'prime'
# return two prime numbers that summate to n, where n is an even integer
def primes (n)
if n % 2 != 0
return "[ERROR] not an even number"
end
# identify primes
prs = []
@internetsadboy
internetsadboy / README.md
Last active August 29, 2015 14:11
Viusic Readme

Viusic

BUILD INSTRUCTIONS

  1. Go to our project's website
  2. Click the install button (top-left corner) to retrieve the Viusic.zip file
  3. Extract Viusic.zip to a directory of your choice
  4. Install Eclipse (Skip this step if you already have it)
  5. Open Eclipse
  • Click File
/**
* @param {String} str
* @return {Boolean}
*/
function hasQuestionMark (str) {
return /\?/g.test(str);
}
/**