Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.
This file contains 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
trait Animal { | |
fn number_of_legs(&self) -> i32; | |
fn speak(&self) -> String; | |
fn eat(&mut self); | |
} | |
struct Cat { |
This file contains 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 numpy as np | |
import pyarrow as pa | |
import pyarrow.feather as pf | |
import pandas as pd | |
dtypes = ['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8', 'f4', 'f8'] | |
strings = ['a', 'bc', 'de', 'efgh', 'five'] | |
cols = {d: np.ones(dtype=d, shape=(20)) for d in dtypes} |
This file contains 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
////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Example Exif thumbnail extractor. | |
// | |
#include <iostream> | |
#include <fstream> | |
#include <vector> | |
This file contains 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
//////////////////////////////////////////////////////////////////////////////// | |
// | |
// Example of converting stb_image to a libjpeg-style background process. | |
// This enables you to stream JPEG files from the internet and interleave | |
// decoding time without frameout on the main thread. | |
// | |
// The example uses three parts of the C++11 threads API. | |
// 1) std::async This is used to run the loader in its own thread. | |
// 2) std::mutex This is used to protect the members of the class from race | |
// conditions. |
This file contains 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
#define GL_GLEXT_PROTOTYPES 1 | |
#include <SDL2/SDL.h> | |
#include <SDL2/SDL_opengles2.h> | |
int main() { | |
auto window = SDL_CreateWindow( | |
"triangle", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, | |
512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | |
); |
This file contains 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
#include <stdio.h> | |
#include <libexif/exif-loader.h> | |
// Note: no error handling and no cleanup for clarity. | |
int main() | |
{ | |
ExifLoader *loader = exif_loader_new(); | |
exif_loader_write_file(loader, "IMG_20170422_132409.jpg"); | |
ExifData *ed = exif_loader_get_data(loader); | |
ed = exif_loader_get_data(loader); |
This file contains 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 time | |
import sdl2 | |
import openvr | |
import numpy | |
from OpenGL.GL import * | |
from OpenGL.GL.shaders import compileShader, compileProgram | |
from openvr.glframework import shader_string | |
from sdl2 import * |
This file contains 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
<html> | |
<head> | |
<script> | |
function main() { | |
var canvas = document.getElementById("myGLCanvas"); | |
try { | |
gl = canvas.getContext("webgl"); | |
} catch(e) { | |
console.log(e); | |
} |