Skip to content

Instantly share code, notes, and snippets.

View sheva29's full-sized avatar

Mauricio Sanchez Duque sheva29

  • Google
  • United States
View GitHub Profile
@sheva29
sheva29 / Local Python Server
Created May 23, 2015 21:56
Simple & Quick Python server
// in terminal in the desired folder location run...
python -m SimpleHTTPServer 8000
// in the browser go to the port number the server was started
http://localhost:8000
@sheva29
sheva29 / extending sorting to pair<> containers in c++
Created April 21, 2015 17:01
Comparing pairs and sorting them in ascending order
//This template allows to compare pairs, and return them in ascending order.
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
Pred p;
return p(right.second, left.second);
}
};
//Implementation example
@sheva29
sheva29 / oF HTTP request
Last active December 7, 2015 07:40
oF GET/POST request
//GET request
//--------------------------------------------------------------
void ofApp::getRequestToURL(){
//This is what we will be posting to the
string getRequest = "http://localhost:8000/api/recommendations/?ids=";
//we pass the IDs to our string for the GET post
for ( int i = 0; i < suggestedProducts.size(); i++){
@sheva29
sheva29 / Chrome Command - all access
Last active December 30, 2015 20:59
Opening Chrome from Terminal with no restrictions
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files
@sheva29
sheva29 / oF - variable from ofApp.h into other classes
Last active December 30, 2015 00:39
oF - Including a variable form the main scope in a particular class
//testApp reference from another class:
//from a .cpp file, for example, "particle.cpp" you can do two things:
//a) include "testApp.h" (so you know what's inside the testApp)
//b) cast the ofGetAppPtr as a testApp ptr
//This is will be the .cpp of the class particle