Skip to content

Instantly share code, notes, and snippets.

View Naios's full-sized avatar

Denis Blank Naios

  • Germany
View GitHub Profile
language: cpp
compiler:
- gcc
- clang
git:
depth: 1
before_install:
@Naios
Naios / Archive.h
Created April 25, 2015 20:37
Archive of code pieces
//! Returns an optional created from the given value.
template <typename T>
inline typename std::enable_if<!std::is_rvalue_reference<T>::value, Optional<T>>::type
make_optional(typename std::decay<T>::type const& value)
{
return Optional<T>(value);
}
//! Returns an optional created from the given moved value.
template <typename T>
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 0fa500c..caa162f 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -23,6 +23,7 @@
#include "Errors.h"
#include "ByteConverter.h"
#include "Util.h"
+#include "Common.h"
struct Fluent
{
template <typename T>
using Callback = std::function<void(T)>;
template <typename T>
Fluent& doSomething(Callback<T> const& t)
{
return *this;
}
@Naios
Naios / functional_unwrap.hpp
Last active July 31, 2023 01:53
C++ functional argument unwrap traits. Extracts argument and return types of functions, std:.function and std::tuple's
/*
* Copyright (C) 2015 Naios <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@Naios
Naios / TaskSchedulerExamples.md
Last active September 4, 2019 12:08
Task Scheduler usage examples

TaskScheduler guide for TrinityCore Scripting

The TaskScheduler was introduced in commit TrinityCore/TrinityCore@da77a90 and TrinityCore/TrinityCore@151a0f5 as a better alternative to eventmap.

It is adapted to the current needs of scripting which means scheduling of event between a random range, schedulling with readable std::chrono constants, repeating of events and more.

See this script for a short usage example

Basic Usage

==7472== Helgrind, a thread error detector
==7472== Copyright (C) 2007-2013, and GNU GPL'd, by OpenWorks LLP et al.
==7472== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==7472== Command: build/continue_test
==7472== Parent PID: 7471
==7472==
==7472== ---Thread-Announcement------------------------------------------
==7472==
==7472== Thread #1 is the program's root thread
==7472==
@Naios
Naios / range.h
Created August 7, 2015 20:37
Using C++11 auto for syntax with ranges
#ifndef range_h__
#define range_h__
#include <iterator>
template<typename T>
class range_iterator
: public std::iterator<std::forward_iterator_tag, T>
{
@Naios
Naios / Main.java
Created August 24, 2015 21:01
Extract TC Authors from commits
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.util.Iterator;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import org.apache.felix.main.AutoProcessor;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;