Skip to content

Instantly share code, notes, and snippets.

View mandyedi's full-sized avatar
🙂

Eduard Mandy mandyedi

🙂
View GitHub Profile
@mandyedi
mandyedi / gist:33b700ff4d01d60d1b3a
Last active August 29, 2015 14:10
c++: macro: debug log
#include <iostream>
#define DEBUG 1
void PrintInfo( const char *str )
{
std::cout << str << std::endl;
}
#if DEBUG
@mandyedi
mandyedi / gist:75680876bb6a7865188d
Created December 6, 2014 22:27
C++: std::vector: remove multiple element
std::vector<Enemy*>::iterator itEnemy;
for ( itEnemy = v.begin(); itEnemy != v.end(); )
{
if ( (*itEnemy)->GetLife() <= 0 )
{
delete *itEnemy;
itEnemy = v.erase( itEnemy );
}
else
{
@mandyedi
mandyedi / gist:48f1a720e3d0e5e25ef8
Created January 12, 2015 22:38
c++: macro: msvc: print function name, declaration etc.
void testFunction( int &x )
{
std::cout << __FUNCTION__ << std::endl;
std::cout << __FUNCDNAME__ << std::endl;
std::cout << __FUNCSIG__ << std::endl;
x += 3;
}
@mandyedi
mandyedi / gist:f6d860dfc9c43fee3809
Created January 12, 2015 22:42
c++: template: 2d array
// http://stackoverflow.com/questions/8767166/passing-2d-array-to-function/17569578#17569578
#include <iostream>
template <size_t rows, size_t cols>
void process_2d_array_template( int( &array )[rows][cols] )
{
for ( size_t i = 0; i < rows; ++i )
{
std::cout << i << ": ";
@mandyedi
mandyedi / detect_memory_leak.h
Created December 12, 2015 10:09
c++ memory leak (not thread safe)
// http://www.flipcode.com/archives/How_To_Find_Memory_Leaks.shtml
// http://en.cppreference.com/w/cpp/memory/new/operator_new
// http://en.cppreference.com/w/cpp/memory/new/operator_delete
#ifndef DETECT_MEMORY_LEAK_H
#define DETECT_MEMORY_LEAK_H
#include <cstdlib>
#include <cstring>
#include <iostream>
@mandyedi
mandyedi / redirect-io.cpp
Created June 6, 2017 22:09
Redirect cin and cout to file.
// https://stackoverflow.com/questions/10150468/how-to-redirect-cin-and-cout-to-files
#include <iostream>
#include <fstream>
#include <string>
void f()
{
std::string line;
while(std::getline(std::cin, line)) //input from the file in.txt
@mandyedi
mandyedi / blender_exporter.py
Created February 25, 2019 20:16
Not so feature rich blender exporter (to a custom binary file format). #python #blender #model
"""
Exports a blender model into my binary model format.
Python: 3.2
Blender: 263
Author: Eduárd Mándy
"""
"""
MBM FILE SRUCTURE
@mandyedi
mandyedi / pathfinder.py
Created May 10, 2020 21:29
python pathfinder A*
# Sample code from https://www.redblobgames.com/pathfinding/a-star/
# Copyright 2014 Red Blob Games <redblobgames@gmail.com>
#
# Feel free to use this code in your own projects, including commercial projects
# License: Apache v2.0 <http://www.apache.org/licenses/LICENSE-2.0.html>
class SimpleGraph:
def __init__(self):
self.edges = {}
@mandyedi
mandyedi / msys2-mingw64.md
Last active June 10, 2020 10:01
MSYS2 and MingGW64 installation on Windows 10
@mandyedi
mandyedi / removecomments.py
Created June 25, 2020 12:55
python comment remove
'''
The script is intended to remove comment line in soruce files.
The script checks all the files (recursively) in the same folder where it is run.
To change conditions see toBeRemoved(line) function.
'''
import os
def toBeRemoved(line):
if line[:4] == "/***":