This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
<html> | |
<head> | |
<script src="./js/jquery-1.7.2.min.js"></script> | |
<script src="./js/jquery.flot.js"></script> | |
<script type="text/javascript"> | |
var plot = null; | |
var flotOptions = { yaxis: { min: -30, max: 125 }, xaxis: { show: false, min: 0, max: 100 }, series: { shadowSize: 0 }, grid: { backgroundColor: { colors: ["#fff", "#eee"] } } }; | |
function refreshChart(points) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Flot Examples</title> | |
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script> | |
<script type="text/javascript" src="js/jquery.flot.js"></script> | |
</head> | |
<body> | |
<h1>Flot Examples</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class RandomNumberGenerator { | |
public static final int MIN = 0; | |
public static final int MAX = 1000000; | |
public static int GenerateRandomNumber(){ | |
Random rand = new Random(); | |
// nextInt is normally exclusive of the top value, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Integer TryParseInt(String someText) { | |
try { | |
return Integer.parseInt(someText); | |
} catch (NumberFormatException ex) { | |
return null; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// servlet is local to the app | |
String requestURL = request.getRequestURL().toString(); | |
String servletPath = request.getServletPath(); | |
String serverPath = requestURL.substring(0,requestURL.indexOf(servletPath)); | |
URL url = new URL(serverPath + "/getScores"); | |
URLConnection conn = url.openConnection(); | |
conn.setConnectTimeout(12000); | |
InputStream is = conn.getInputStream(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extend strings with the method "contains" | |
String.prototype.contains = function(str) { return this.indexOf(str) != -1; }; | |
// profanities of choice | |
var profanities = new Array("ass", "cunt", "pope"); | |
var containsProfanity = function(text){ | |
var returnVal = false; | |
for (var i = 0; i < profanities.length; i++) { | |
if(text.toLowerCase().contains(profanities[i].toLowerCase())){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.replaceAt=function(index, char) { | |
return this.substr(0, index) + char + this.substr(index+char.length); | |
} | |
var REPLACEMENT_CHAR = "*"; | |
var TO = 5; | |
var FROM = 4; | |
var str = "Hello World"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int runSort(){ | |
// get values out of buffer | |
Pointer<Integer> particleInd = _particleIndex.read(_queue); | |
_queue.finish(); | |
int[] particleIndex = new int[_particleCount * 2]; | |
// copy to array of primitives | |
for(int i = 0;i< _particleCount*2;i++){ | |
particleIndex[i] = particleInd.get(i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void allocateBuffers(){ | |
// host allocated pointers (used to write values -- see lines 81/82 in setModels below) | |
_positionPtr = Pointer.allocateFloats(_particleCount * 4); | |
_velocityPtr = Pointer.allocateFloats(_particleCount * 4); | |
// alternative buffer defining | |
_acceleration = _context.createFloatBuffer(Usage.InputOutput, _particleCount * 4 * 2); | |
_gridCellIndex = _context.createIntBuffer(Usage.InputOutput, _gridCellCount + 1); | |
_gridCellIndexFixedUp = _context.createIntBuffer(Usage.InputOutput, _gridCellCount + 1); | |
_neighborMap = _context.createFloatBuffer(Usage.InputOutput, _particleCount * SPHConstants.NEIGHBOR_COUNT * 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public synchronized float[] solveWithDeviceMemory() { | |
// Allocate native (device) memory for the input data | |
CLBuffer<Float> bufIn = _context.createFloatBuffer(CLMem.Usage.Input, _input.length); | |
// Allocate native (device) memory for the output data | |
CLBuffer<Float> bufOut = _context.createFloatBuffer(CLMem.Usage.Output, _input.length); | |
// Copy input data directly to device memory | |
Pointer<Float> ptrIn = bufIn.map(_queue, CLMem.MapFlags.Write); | |
ptrIn.setFloats(_input); | |
bufIn.unmap(_queue, ptrIn); |