Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
c0ldlimit / example.c
Created February 13, 2015 01:21
#lecture6
#include <stdio.h>
typedef struct X {
int a, b;
} X;
int main() {
X x = { 1, 2};
X x2;
x2 = x; // data is copied
@c0ldlimit
c0ldlimit / gist:156445d94f47b52b14af
Created February 10, 2015 14:33
#excel counta ignore blank formulas
=COUNTIF(a2:a15,">""")
int f( object a) {
int z = 5;
return z; // RVO
return std::move(z);
}
int f2( object& a) {
int z = 5;
return z; // RVO
return std::move(z);
@c0ldlimit
c0ldlimit / animal.cpp
Created January 30, 2015 00:33
#lecture4 cpp
class State; // forward declare a class - it exists but not tell you what's in it
// must declare it so that we can use it in Node but State uses Node so can't put them both first
class Node {
public:
Node(State *s) : state(s) {}
void process();
State *state; // always need to work with pointers or references to objects with members -
//could be a question state or an answer state - don't know how big the state object will be -
@c0ldlimit
c0ldlimit / Grading.cpp
Last active August 29, 2015 14:13
#lecture2 cpp
#include "Grading.h"
#include<numeric>
using namespace mpcs51044;
using namespace std; // when you're not in a header you are no imposing your choices on anyone else
// it's okay to use this here
double Student_info::grade() const
{
double avg = accumulate(homework.begin(), homework.end(), 0.0) / homework.size();
@c0ldlimit
c0ldlimit / gist:634ea60bc8d79ac6340a
Created January 2, 2015 18:07
#bloomberg refresh formulas
' http://stackoverflow.com/questions/12856979/how-to-refresh-load-rtd-bloomberg-function-bdh-in-excel-in-vba
Application.run "RefreshAllWorkbooks"
Application.run "RefreshAllStaticData"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
// my CPU has 32K of L1 cache
#define L1_CACHE_CAPACITY (32768 / sizeof(int))
int array[L1_CACHE_CAPACITY][L1_CACHE_CAPACITY];
struct timespec time_diff(struct timespec start, struct timespec end) {
@c0ldlimit
c0ldlimit / gist:a5094352e1d99961957d
Created November 3, 2014 18:48
#linear #algebra notes
When a matrix can be inverted:
- matrix is a square matrix
- linearly independent columns
- the span of the basis is the basis R^n
if C is invertible then the span of B = R^n
span of B is R^n then C is invertible
@c0ldlimit
c0ldlimit / gist:43d30e56ac050b9e9e48
Created October 21, 2014 18:31
#python #virtualenv #windows
http://stackoverflow.com/questions/6114115/windows-virtualenv-pip-numpy-problems-when-installing-numpy
#include<stdio.h>
int main(int argc, char * argv[]) {
float f = 19.86;
int x, k;
for (k=0; k < 32; ++k) {
x = *(int*)&f >> (k);