Skip to content

Instantly share code, notes, and snippets.

View mlabbe's full-sized avatar

Michael Labbe mlabbe

View GitHub Profile
@mlabbe
mlabbe / abc.cpp
Last active August 29, 2015 14:02
delete[] undefined result
#include<cstdio>
using namespace std;
class Base
{
public:
virtual ~Base() {}
};
==30959== 12 bytes in 1 blocks are definitely lost in loss record 13 of 237
==30959== at 0x4C2B800: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30959== by 0x476ED6: Orion::DCS_UpdateComponents(Orion::ComponentManager&, Orion::update_stage_t) (DCS.cpp:660)
==30959== by 0x42E098: Unit::DCS::DCS_UpdateComponents() (Unit_DCS.h:589)
==30959== by 0x5F8BD8: Test::Suite::do_run(Test::Output*, bool) (suite.cpp:179)
==30959== by 0x5F8C9E: Test::Suite::do_run(Test::Output*, bool) (suite.cpp:199)
==30959== by 0x5F8D45: Test::Suite::run(Test::Output&, bool) (suite.cpp:89)
==30959== by 0x408C52: main (OrionTest.cpp:294)
@mlabbe
mlabbe / compiler_ext.c
Last active August 29, 2015 14:02
Compiler extensions made portable.
/*
Compiler extensions made portable
Usage:
In MSVC, attributes must be on declarations in addition to prototypes.
Use _ATTRIBUTES to conditionally declare them, depending on compiler.
// Prototype
EXT_warn_unused_result EXT_force_inline int SomeFunc( void );
@mlabbe
mlabbe / gist:d41260563c7a25f353ab
Created June 27, 2014 19:39
compilation mode improvements
;
; compilation-mode improvements
;
(defun compilation-custom-hook ()
(visual-line-mode 1))
(add-hook 'compilation-mode-hook 'compilation-custom-hook)
(defun sludge-recompile-quietly ()
"Re-compile without changing the window configuration."
(interactive)
@mlabbe
mlabbe / stricmp
Created July 26, 2014 05:51
Comparing strings
int Orion::Stricmp( const char *s1, const char *s2 )
{
const char *p1 = s1;
const char *p2 = s2;
int result = 0;
if ( p1 == p2 )
return result;
while (!result)
{
void ImgPremultiply( void )
{
Assert( surface[0].GetNumChannels() == 4 );
Uint8 *channels = surface[0].GetChannels();
for ( Uint32 i = 0; i < surface[0].GetPixelCount(); ++i )
{
Uint8 *p = &(channels[i*4]);
p[0] = Uint8(p[0] * (p[3] / 255.0f));
p[1] = Uint8(p[1] * (p[3] / 255.0f));
Uint32 mask = 0;
switch ( numChannels )
{
case 1:
mask = 0xFF000000;
break;
case 2:
mask = 0xFFFF0000;
break;
case 3:
@mlabbe
mlabbe / testopendialogmultiple.c
Last active August 29, 2015 14:10
API usage example of multiple UTF-8 Paths returned
#include <nfd.h>
#include <stdio.h>
#include <stdlib.h>
/* this test should compile on all supported platforms */
int main( void )
{
nfdchar_t *outPath = NULL;
@mlabbe
mlabbe / claypot app.py
Created December 19, 2014 20:06
Claypot Event Query API
@claypot_app.get('/event/<product_id:int>/<event_names>')
@claypot_app.get('/event/<product_id:int>/<event_names>/start_date/<start_date>')
@claypot_app.get('/event/<product_id:int>/<event_names>/date_range/<start_date>/<end_date>')
def get_event(product_id, event_names, start_date=None, end_date=None):
"""
break down the values for every key for a list of events
sample usage:
http://localhost/claypot/event/1/hwstats,event2,empty_event/start_date/2014-01-01
@mlabbe
mlabbe / ofxLightFactory
Created January 5, 2015 00:30
My DMX lighting API
#include "ofxLightFactory.h"
#include "lighthardware.h"
void lightApp::setup() {
count = 0;
ofSetFrameRate(40);
dmxController.universe.connect(0);