Skip to content

Instantly share code, notes, and snippets.

View reportbase's full-sized avatar

Tom Brinkman reportbase

View GitHub Profile
@reportbase
reportbase / fitted
Created March 22, 2015 21:01
create fitted rectangles
inline rectangle* uniform_fitted_rectangle::get(int cols, int rows, int width, int height, int margin)
{
if(width < 0 || height < 0)
return 0;
int size = cols * rows;
int n = 0;
int y = 0;
int iheight = height + margin;
int rwidth = width + margin;
@reportbase
reportbase / echo_csv
Created March 22, 2015 21:00
echo csv file
inline void echo_csv(const char*, const char* path, void* app_, node<message*>** errors)
{
/*
const char* line =
"AAC,20120426\r\n"
"BBB,20120425\r\n";
*/
int linesn;
char** lines = load_file_lines(path, linesn);
for(int n = 0; n < linesn; ++n)
@reportbase
reportbase / echo_bin_octal
Created March 22, 2015 20:59
echo binary file to octal
inline void echo_bin_octal(const char*, const char* path, void* app_, node<message*>** errors)
{
int size;
unsigned char* buffer = load_binary(path, &size, errors);
if(*errors)
{
push_message(errors, 0, 0, 1, __FILE__, __FUNCTION__, __LINE__, "bad path: %s", path);
return;
}
@reportbase
reportbase / echo_base64_encode
Created March 22, 2015 20:58
Encode binary file base64
inline char* base64_encode(const unsigned char* data, int input_length, int* output_length)
{
static char encoding_table[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
@reportbase
reportbase / pod.h
Created March 22, 2015 18:45
pod.h
template <typename type_t>
struct pod
{
type_t exec()()
{
type_t type;
memset(&type, 0, sizeof(type_t));
return type;
}
@reportbase
reportbase / echo.h
Created March 22, 2015 18:44
Echo using printf
struct echo
{
void exec()(const float* a, int size)
{
for(int n = 0; n < size; ++n)
printf("%15d%15.5f\n", n, a[n]);
}
void exec()(const float* a, const float* b, int size)
{
@reportbase
reportbase / Circular-canvas-loader.markdown
Created December 30, 2014 19:47
Circular canvas loader

Circular canvas loader

A canvas showing loading progress in a circle. Here it's faked and animated on requestAnimationFrame. But you get the idea.

A Pen by pimskie on CodePen.

License.

@reportbase
reportbase / html5-canvas-loader.markdown
Created December 30, 2014 19:40
html5 canvas loader

html5 canvas loader

Starting to play around with html5 canvas more I came across this loader by Jack Rugile and proceeded to try and make something similar. End result seems okay. Any tips would be welcome :)!

A Pen by Lennart Hase on CodePen.

License.

@reportbase
reportbase / Timer-Canvas-Animation.markdown
Created December 30, 2014 19:39
Timer Canvas Animation

Timer Canvas Animation

I want a cool and beautiful timer for my own website. So, i do this one with canvas. :)

A Pen by Jak1 on CodePen.

License.

@reportbase
reportbase / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console