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 / 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
@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 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 / 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 / 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
/* when trying to console.log in Angular */
JSON.stringify($scope, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
@sheva29
sheva29 / RegEx.txt
Last active June 6, 2017 17:12
RegEx
/*
Custom Regular Expressions
To test Regex go here: http://www.regextester.com/
*/
/* 1. Looking for specific Regex with negative look up*/
^((?!For example: Make a left at the blue sign and park by the red door).)*$
/* 2. Setting a maximun Character count*/
^.{1,70}$

Keybase proof

I hereby claim:

  • I am sheva29 on github.
  • I am sheva29 (https://keybase.io/sheva29) on keybase.
  • I have a public key ASAb6X9ExGvIkoMJlXB8Vj_wkfQAfAdK0aCPPj0hR-YQFAo

To claim this, I am signing this object:

@sheva29
sheva29 / insert_entry.sql
Created April 21, 2017 20:24
INSERT SQL
/****** Script for SelectTopNRows command from SSMS ******/
SET IDENTITY_INSERT [WindstreamPLUT].[dbo].[ProductDependent] ON
INSERT INTO [WindstreamPLUT].[dbo].[ProductDependent] (ProductDependentID, ParentProductID, DependentProductID, RelationshipCd, DefaultFlg, CreateUTCDt, UpdateUTCDt, ParentProductQuantity)
VALUES ('84214', '20442', '20587', 'M', '1', '2017-04-21 19:40:25.237', '2017-04-21 19:41:25.237', NULL)
@sheva29
sheva29 / ConvertingObj.cs
Created July 5, 2017 21:20
Converting obj to same type
private static T ConvertType<T>(object instance)
{
if (instance == null)
{
throw new ArgumentNullException("instance");
}
var typeSource = instance.GetType();
var typeDestination = typeof(T);