Skip to content

Instantly share code, notes, and snippets.

View welll's full-sized avatar
🏠
Working from home

Wellington Soares welll

🏠
Working from home
View GitHub Profile
http://stackoverflow.com/questions/2898316/using-a-member-function-pointer-within-a-class
//char *buffer = new char[bufferSize];
std::string buffer;
buffer.resize(bufferSize);
@welll
welll / gist:0fc2a1285d2b196f9481
Last active January 20, 2016 16:56
C++ - namespace
using namespace foo; //generic, the same behaviour in Java, include com.foo.*
using bar;// specific, the same behaviour in Java, include com.package.bar;
@welll
welll / const.cpp
Created December 14, 2014 01:39
C++ - Const
void Foo( int * ptr,
int const * ptrToConst,
int * const constPtr,
int const * const constPtrToConst )
{
*ptr = 0; // OK: modifies the "pointee" data
ptr = NULL; // OK: modifies the pointer
*ptrToConst = 0; // Error! Cannot modify the "pointee" data
ptrToConst = NULL; // OK: modifies the pointer
@welll
welll / throttle.js
Created December 13, 2014 21:52
Javascript - Throttle Function
function throttle( fn, time ) {
var t = 0;
return function() {
var args = arguments, ctx = this;
clearTimeout(t);
t = setTimeout( function() {
fn.apply( ctx, args );
}, time );
};
@welll
welll / gist:e8f4e2bcce66332663a2
Last active August 29, 2015 14:11
Using typedef to function
typedef int myinterger;
typedef int (*fn_adder)(int, long);
int sum(int a, long b){
return a+b;
}
@welll
welll / gist:7f7fa578d0539ed5c275
Last active August 29, 2015 14:11
NodeJS - Function to Replace a Text Block
/*
* This function will replace the content inside
* the commentary "setupVars"
*
* Param:
* content: the input string, e.g, a entire HTML file
* data: snippet to be included
*
* <html>
* <body>