Skip to content

Instantly share code, notes, and snippets.

vector<AABB> getMergedAABBSLeft(vector<AABB> mSource)
{
vector<AABB> result;
while(!mSource.empty())
{
bool merged{false}; AABB a{mSource.back()}; mSource.pop_back();
for(auto& b : mSource)
if(a.getRight() == b.getRight())
vector<string> specials{"{", "}", "[", "]", "(", ")"};
vector<string> keywords{"if", "else"};
enum class TokenType{Symbol, Keyword, Special, Numeric};
bool isKeyword(const std::string& mValue) { return contains(keywords, mValue); }
bool isSpecial(const std::string& mValue) { return contains(specials, mValue); }
bool isNumeric(const std::string& mValue) { for(const auto& c : mValue) if(!isdigit(c)) return false; return true; }
struct Token
@vittorioromeo
vittorioromeo / gist:5792381
Last active December 18, 2015 13:48
Strange lambda bug (machine-dependent compiler bug?)
// Test 1 works
// Test 2 segfaults... on some machines.
// Compiled with -std=c++11, GCC 4.8.1, tested both on native Linux, Windows and Wine
#include <iostream>
#include <functional>
#include <vector>
using namespace std;
@vittorioromeo
vittorioromeo / Text.cpp
Created June 24, 2013 15:06
Optimizations to sf::Text - adding a "must update geometry" flag to avoid unnecessary recalculations
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
@vittorioromeo
vittorioromeo / backup-system.sh
Last active December 19, 2015 06:09
This script backups the whole filesystem. It stores the last 15 backup folders in a text file, '_LAST', and rotates the backups by deleting the fifteenth folder (and text line).
#!/bin/bash
# Set directories
BACKUPDIR="/media/veeBackup/_ARCHBACKUP/"
TEMPDIR="${BACKUPDIR}_TEMP/"
TEMPFILE="${TEMPDIR}tmpfile"
LASTENTRIESFILE="${BACKUPDIR}_LAST"
# Get all entries from LASTENTRIESFILE (one entry per line) and put them in the LASTENTRIES array
OLD_IFS=$IFS
@vittorioromeo
vittorioromeo / build-all.sh
Created July 2, 2013 18:42
Builds and installs both debug and release CMake configurations in all subfolders non-recursively
#!/bin/bash
echo "Password, please!"
sudo echo "Thanks!"
for dir in ./*; do
if [[ -d "$dir" ]]; then
(
cd "$dir"
mkdir "buildAll"
@vittorioromeo
vittorioromeo / GridMain.cpp
Created July 4, 2013 23:59
Philip Diffenderfer's grid spatial partitioning implementation
#include <cstdlib>
#include <cmath>
#include <iostream>
#ifdef _WIN32
#include "sys\time.h"
#include <windows.h>
#else
#include "sys/time.h"
#endif
@vittorioromeo
vittorioromeo / build-oh-rel.sh
Last active December 19, 2015 13:59
1-click build for Open Hexagon (both for Arch and Debian/Ubuntu) Open Hexagon Windows build helper (requires human intervention) Open Hexagon Release build helper
#!/bin/bash
# This bash script, called in a repository with submodules, builds and installs all submodules then the project itself
# RELEASE MODE, SKIPS RPATH
# Takes $1 destination directory parameter
if [ -z "${1}" ]; then
echo "This script the installation path as an argument!"
exit 1
fi
@vittorioromeo
vittorioromeo / Client.cpp
Created July 17, 2013 16:29
temp server/client
#include <iostream>
#include <algorithm>
#include <string>
#include <thread>
#include <functional>
#include <future>
#include <SSVUtils/SSVUtils.h>
#include <SFML/Network.hpp>
#include "Common.h"
@vittorioromeo
vittorioromeo / Tokenizer.h
Created July 18, 2013 20:54
Temp tokenizer
#ifndef SSVU_TOKENIZER
#define SSVU_TOKENIZER
#include <string>
#include <vector>
#include <unordered_map>
#include <functional>
#include "SSVUtils/Utils/UtilsContainers.h"
#include "SSVUtils/Log/Log.h"
#include "SSVUtils/Global/Typedefs.h"