Skip to content

Instantly share code, notes, and snippets.

View reportbase's full-sized avatar

Tom Brinkman reportbase

View GitHub Profile
@reportbase
reportbase / is_bit_set
Created March 22, 2015 21:15
is bit set?
inline int is_bit_set(unsigned int val, int n)
{
static unsigned int mask[] =
{
1, //0x1 << 0
2, //0x1 << 1
4, //0x1 << 2
8, //0x1 << 3
16, //0x1 << 4
32, //0x1 << 5
@reportbase
reportbase / extentsplit
Created March 22, 2015 21:16
split an array and normalize it
inline void extentsplit(float* e, int size, int width)
{
int empty_slots = 0;
int awidth = 0;
for(int n = 0; n < size; ++n)
{
if(e[n] < 1)
e[n] = width * std::abs(e[n]);
awidth += e[n];
empty_slots += e[n] == 0 ? 1 : 0;
@reportbase
reportbase / markets
Created March 22, 2015 21:22
compare markets
market marketlst [] =
{
{"AMEX", "American Stock Exchange", "www.nyse.com", "www.nyse.com"},
{"AMS", "Euronext Amsterdam", "www.aex.nl", "www.aex.nl"},
{"ASX", "Australian Stock Exchange", "www.asx.com.au", "www.asx.com.au"},
{"BRU", "Euronext Brussels", "www.euronext.com", "www.euronext.com"},
{"BSE", "Bombay Stock Exchange", "www.bseindia.com", "www.bseindia.com"},
{"CBOT", "Chicago Board of Trade", "www.cmegroup.com", "www.cmegroup.com"},
{"CFE", "Chicago Futures Exchange", "cfe.cboe.com", "cfe.cboe.com"},
{"CME", "Chicago Merchantile Exchange", "www.cmegroup.com", "www.cmegroup.com"},
@reportbase
reportbase / binary_split
Created March 22, 2015 21:28
binary split
inline void binary_split(int* arr, int size, int split)
{
if(size <= split)
return;
arr[size - 1] = true;
int n = (int)ceil(size / 2.0);
binary_split(arr, n, split);
binary_split(arr + n, size - n, split);
}
@reportbase
reportbase / rgb
Created March 22, 2015 21:31
rgb utilities
// This is a subfunction of HSLtoRGB
inline void HSLtoRGB_Subfunction(unsigned int& c, const float& temp1, const float& temp2, const float& temp3)
{
if((temp3 * 6) < 1)
c = (unsigned int)((temp2 + (temp1 - temp2) * 6 * temp3) * 100);
else if((temp3 * 2) < 1)
c = (unsigned int)(temp1 * 100);
else if((temp3 * 3) < 2)
c = (unsigned int)((temp2 + (temp1 - temp2) * (.66666 - temp3) * 6) * 100);
@reportbase
reportbase / reverse
Created March 22, 2015 21:33
reverse array
template <typename node_t> inline
void reverse(node_t** head)
{
node_t* prev = 0;
while(*head)
{
node_t* next = (*head)->next;
(*head)->next = prev;
prev = *head;
*head = next;
@reportbase
reportbase / gist:dada68b9e6617a85ad30
Created April 3, 2015 14:42
Eeasel Tweenjs Show bouncing ball
function bouncing_ball2(cnv)
{
var ball = new createjs.Shape();
ball.graphics.setStrokeStyle(5, 'round', 'round');
ball.graphics.beginStroke(('#000000'));
ball.graphics.beginFill("#FF0000").drawCircle(0, 0, 50);
ball.graphics.endStroke();
ball.graphics.endFill();
ball.graphics.setStrokeStyle(1, 'round', 'round');
ball.graphics.beginStroke(('#000000'));
@reportbase
reportbase / gist:cd57c28dd0d3695572f1
Created April 3, 2015 14:44
git hub - load from the repository
<script type="text/javascript" src="ext/underscore/underscore-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="ext/gh3/gh3.js"></script>
function load_github()
{
var gh = new Gh3.User("reportbase");
var ghr = new Gh3.Repository("scripts", gh);
ghr.fetch(function (err, res)
{
@reportbase
reportbase / gist:edc7959244d18128c3c9
Created June 15, 2015 19:28
Linear interpolate of image buffer
function data_a_interpolate(data, alpha, width, height, red, green, blue)
{
var m = 0;
for(var n = 0; n < width * height * 4; n += 4, m++)
{
data[n + 0] = Math.linear_interpolate(alpha, red, data[n + 0]);
data[n + 1] = Math.linear_interpolate(alpha, green, data[n + 1]);
data[n + 2] = Math.linear_interpolate(alpha, blue, data[n + 2]);
data[n + 3] = 0xff;
}
var reporequest = new XMLHttpRequest();
var repodef = http_promise("GET", "json", "https://api.github.com/repos/" + OWNER + "/" + REPO, reporequest, function(response)
{
def.repodef = response;
console.log(def.repodef);
});
def.repolst = new Array();
var reporequest = new XMLHttpRequest();