Skip to content

Instantly share code, notes, and snippets.

# arr = [1, 2, 3, 4, 5]
arr = np.arange(5)
# [1, 2, 3]
arr[[0, 1, 2]]
# [1, 3, 5]
arr[[True, False, True, False, True]]
# [4, 5]
View color_test.c
#include <stdio.h>
/* reference: */
#define GRAY "\e[90m"
#define RED "\e[91m"
#define GREEN "\e[92m"
#define DEFAULT "\e[39m"
const int num_colors = 3;
const char *colors[] = {GRAY, RED, GREEN};
tim37021 / bmploader.cpp
Created Jul 11, 2016
Mini C BMP Loader
View bmploader.cpp
// mini bmp loader written by HSU YOU-LUN
unsigned char *load_bmp(const char *bmp, unsigned int *width, unsigned int *height, unsigned short int *bits)
unsigned char *result=nullptr;
FILE *fp = fopen(bmp, "rb");
return nullptr;
char type[2];
unsigned int size, offset;
// check for magic signature
View Sudoku.c
#include <stdio.h>
#define ROWS 9
#define COLS 9
#define SQ 3
#define MAX (SQ*SQ)
static void read_question(FILE *fp);
static int find_blank(int *, int *);
static int solve(int, int);
tim37021 / gist:cdf47151d4064f572bc5
Created May 30, 2015
Light culling geometry shader
View gist:cdf47151d4064f572bc5
#version 330
layout(points) in;
layout(triangle_strip, max_vertices=6) out;
in vec3 vColor[1];
out vec3 lightPos;
out vec3 lightColor;
uniform mat4 view;
// e: near
// a: aspect: height/width;
uniform float e=0.1, a=1.0;
tim37021 / gs.glsl
Last active Dec 27, 2018
Geometry shader for switching between flat and smooth shading
View gs.glsl
#version 330
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out
uniform int enableSmooth=1;
in vec3 vNorm[3];
in vec3 vWorldPos[3];
in vec2 vTexCoord[3];
You can’t perform that action at this time.