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 "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(); |
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
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 - |
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
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); |
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
=COUNTIF(a2:a15,">""") |
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> | |
typedef struct X { | |
int a, b; | |
} X; | |
int main() { | |
X x = { 1, 2}; | |
X x2; | |
x2 = x; // data is copied |
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
void | |
Stack::push(int val) | |
{ | |
StackHead expected = head.load(); | |
StackItem *newItem = new StackItem(val); | |
StackHead newHead; | |
newHead.link = newItem; | |
do { | |
newItem->next = expected.link; | |
newHead.count = expected.count + 1; |
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
cannot find vcvarsall.bat when trying to build Python libraries. Python 2.7 is built with the Visual Studio 2008 compiler and so extension modules must be build with the same compiler. So install VS C++ 2008 Express which will set the VS90COMNTOOLS environment variable. | |
http://go.microsoft.com/?linkid=7729279 - by default this version will only give you a 32-bit compiler - so it will only work for installing into a 32-bit Python. | |
http://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat | |
http://stackoverflow.com/a/18045219 | |
Update for x64 Compilers: By default this will only give you a 32-bit compiler. I learned (from here and here) that you can download specifically the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 which gives you a x64 compiler for VC++ 2008 (VC++ 9.0) if you need it. Just when you are installed it, you can uncheck everything except Developer Tools >> Visual C++ Compilers which will keep you from installing all the extra SDK tools that you may not need. |
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
sudo apt-get install nodejs | |
sudo apt-get install npm | |
sudo ln -s /usr/bin/nodejs /usr/bin/node | |
npm -g install phantomjs | |
pip install selenium |
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
sudo apt-get update | |
sudo apt-get install build-essential cmake | |
sudo apt-get install python-dev | |
#install vundle https://github.com/gmarik/Vundle.vim#about | |
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim | |
#modify .virmc to use Vundle per https://github.com/gmarik/Vundle.vim#about | |
#Add a line like 'Plugin "Valloric/YouCompleteMe"' in bet | |
# run :PluginInstall to install all the specified plugins from VIM |
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<iostream> | |
// primary template | |
template<int i> | |
struct Fib { | |
static int const value = Fib<i-1>::value + Fib<i-2>::value; | |
}; | |
// specializations to stop recursion | |
// specialization is indicated |