Skip to content

Instantly share code, notes, and snippets.

View karimnaaji's full-sized avatar

Karim Naaji karimnaaji

View GitHub Profile
@karimnaaji
karimnaaji / valgrind.md
Last active March 12, 2024 09:28
Valgrind steps to get cache misses
@karimnaaji
karimnaaji / GoogleFonts.txt
Created January 9, 2017 17:33
Google fonts list (TTF)
{
"kind": "webfonts#webfontList",
"items": [
{
"kind": "webfonts#webfont",
"family": "ABeeZee",
"category": "sans-serif",
"variants": [
"regular",
"italic"
@karimnaaji
karimnaaji / reserve_vs_resize.cpp
Last active September 8, 2016 21:40
reserve_vs_resize.cpp
#include <time.h>
#include <stdio.h>
#include <vector>
struct A {
int mem[100];
};
int n = 1000000;
@karimnaaji
karimnaaji / teapot.h
Created March 15, 2016 21:49
Teapot in a single header file (normal,uvs,tangent)
This file has been truncated, but you can view the full file.
#pragma once
/**
\file minimalOpenGL/teapot.h
\author Morgan McGuire, http://graphics.cs.williams.edu
Geometric data for the Utah teapot.
Distributed with the G3D Innovation Engine http://g3d.cs.williams.edu
*/
namespace Teapot {
@karimnaaji
karimnaaji / const_string_vs_value_string.cpp
Created March 11, 2016 21:23
string move vs string copy
#include <iostream>
#include <ctime>
#include <string>
void function_a(const std::string& str) {
return;
}
void function_b(std::string str) {
return;
@karimnaaji
karimnaaji / plot.frag
Created July 24, 2015 21:30
plot glsl
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
@karimnaaji
karimnaaji / track.cpp
Created June 16, 2015 22:34
track c++ allocations
global operator new
global operator new []
global operator delete
global operator delete []
#undef new
void *operator new (size_t size, char *file, int line, char *function);
// [...]
#define new new (__FILE__, __LINE__, __FUNCTION__)
@karimnaaji
karimnaaji / bcurve.cpp
Last active August 29, 2015 14:22
cubic bezier curve
#include <iostream>
#include <string>
#include <cmath>
void bCurveP4Derivative(float t, float p0x, float p0y, float p1x, float p1y, float p2x, float p2y, float p3x, float p3y, float* x, float* y) {
// derivate of cubic b-curve is a quadratic b-curve
float it = 1 - t;
float f0 = 3 * powf(it, 2.f);
float f1 = 6 * t * (it);
float f2 = 3 * powf(t, 2.f);
@karimnaaji
karimnaaji / sharedVSraw.cpp
Last active August 29, 2015 14:21
auto pointers bench
#include <iostream>
#include <ctime>
#include <climits>
#include <memory>
int main() {
struct big_struct {
long long array[10];
};