Skip to content

Instantly share code, notes, and snippets.

View ScatteredRay's full-sized avatar

Indy Ray ScatteredRay

  • San Francisco, Ca
View GitHub Profile

Include Guards

#ifndef HEADER_H
#define HEADER_H
//...
#endif //HEADER_H

is preferred to

@ScatteredRay
ScatteredRay / gist:0f1778aacfef0e75dcbd
Last active August 29, 2015 14:14
Static member existance check
template<typename T>
struct Has_My_Static {
typedef char yes[1];
typedef char no[2];
template<void*> struct exist_check;
template<typename U, U> struct type_check; // Use this for type checking.
#ifdef _MSC_VER
template<typename C> static yes& chk(C*, exist_check<(void*)&C::MyStatic>*);
#else
template<typename C> static yes& chk(C*, typeof(&C::MyStatic));
template <typename t>
void DeleteAllIn(t& iteratable)
{
for(t::iterator it = iteratable.begin(); it != iteratable.end(); it++)
delete *it;
}
Creating qmake. Please wait...
g++ -c -o project.o -pipe -DQMAKE_OPENSOURCE_EDITION -g -fconstant-cfstrings -I. -Igenerators -Igenerators/unix -Igenerators/win32 -Igenerators/mac -Igenerators/symbian -I/Users/Indy/dev/qt/qt/include -I/Users/Indy/dev/qt/qt/include/QtCore -I/Users/Indy/dev/qt/qt/src/corelib/global -I/Users/Indy/dev/qt/qt/src/corelib/xml -DQT_NO_PCRE -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_STL -DQT_NO_COMPRESS -I/Users/Indy/dev/qt/qt/mkspecs/macx-g++ -DHAVE_QCONFIG_CPP -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT project.cpp
In file included from /Users/Indy/dev/qt/qt/include/QtCore/qdatastream.h:1,
from /Users/Indy/dev/qt/qt/include/QtCore/../../src/corelib/tools/qstringlist.h:46,
from /Users/Indy/dev/qt/qt/include/QtCore/qstringlist.h:1,
from project.h:45,
from project.cpp:42:
/Users/Indy/dev/qt/qt/include/QtCore/../../src/corelib/io/qdatastream.h:45:35: erro
class BrowserWindow : public QMainWindow {
Q_OBJECT
private:
class AsyncServerQuery* Query;
...
public slots:
void ServerInfoReceived(struct SteamServerInfo Info);
};
BrowserWindow::BrowserWindow(QWidget *parent) :
GLuint CreateShaderProgram(shader_id shader)
{
GLuint vshader = CreateShader(GetVShaderFile(shader), GL_VERTEX_SHADER);
if(!vshader) goto error;
GLuint pshader = CreateShader(GetVShaderFile(shader), GL_FRAGMENT_SHADER);
if(!pshader) goto error_pshader;
GLuint program = glCreateProgram();
(def L '())
(defn add-item [i]
(def L (cons i L))
(add-item 1)
(add-item 2)
....
@ScatteredRay
ScatteredRay / gist:816134
Created February 8, 2011 08:54
clojure macro
(def L '())
(defn add-fun [i]
(def L (cons i L))
(defn fn1 [] ...)
(add-item fn1)
(defn fn2 [] ...)
(add-item fn2)
@ScatteredRay
ScatteredRay / gist:2439988
Created April 21, 2012 22:26
package.loaders
int lua_load_module(lua_State* lua)
{
const char* lua_file = lua_tostring(lua, -1);
lua_pop(lua, 1);
luaL_loadfile(lua, lua_file);
return 1;
}
int lua_find_module(lua_State* lua)
{
@ScatteredRay
ScatteredRay / cmakelists.txt
Created August 29, 2012 23:34
Two project CMake
SET (this_target PROJECT1)
PROJECT(${this_target})
...
ADD_EXECUTABLE(#{this_target} ...)
SET (this_target PROJECT2)
PROJECT(${this_target})