Skip to content

Instantly share code, notes, and snippets.

Avi Tevet avitevet

Block or report user

Report or block avitevet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
avitevet / accurateOSXPerformanceMeasurements.cpp
Last active Jan 23, 2018
How to perform accurate performance measurements on OS X
View accurateOSXPerformanceMeasurements.cpp
#include <mach/mach_time.h>
#include <iostream>
// Shows how to perform accurate performance measurements on modern OS X in application-level code
// on x86 processors.
// Performance monitoring on Intel processors is a challenge because the behavior of the internal
// processor counters has changed over the years. Also, processor frequency used to be fixed,
// but with the introduction of SpeedStep technology the processor frequency may change at
avitevet / diet.cpp
Created Apr 6, 2017
Using linear programming/simplex method to solve the diet problem: given a set of foods with nutritional data, and a set of nutritional constraints, find the cheapest combination of foods that meets your nutritional needs.
View diet.cpp
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cassert>
using namespace std;
typedef double ElementType;
typedef vector<vector<ElementType>> matrix;
avitevet / accurateWindowsPerformanceMeasurement.cpp
Created Mar 10, 2017
How to perform accurate & high-resolution performance measurement in "recent" Windows on "recent" x86 processors
View accurateWindowsPerformanceMeasurement.cpp
#include <Windows.h>
#include <iostream>
// Shows how to perform accurate performance measurements on modern Windows in application-level code
// on x86 processors.
// Mostly from
// The QueryPerformanceCounter is an abstraction around the processor time-stamp counter, which
// starts at zero when the processor is reset and increments monotonically each cycle.
avitevet /
Last active Jul 28, 2019
A reference sheet for the terminology and formulas used in the Simplex Algorithm of linear programming problems

Simplex Algorithm Reference Sheet

The simplex algorithm is a method for maximizing or minimizing a linear equation given a set of linear constraints on the variables in the equation.


Linear equality
f(x1, x2, .., xn) = b
Linear inequality
avitevet /
Created Sep 24, 2013
general string left padding function in coffeescript
# val = the value to pad
# length = the length of the padded string
# padChar = the character to use for padding. Defaults to '0'
pad = (val, length, padChar = '0') ->
val += ''
numPads = length - val.length
if (numPads > 0) then new Array(numPads + 1).join(padChar) + val else val
You can’t perform that action at this time.