Skip to content

Instantly share code, notes, and snippets.

inline void * operator new(std::size_t n)
{
return malloc(n);
}
inline void operator delete(void * p) noexcept
{
free(p);
}
inline void *operator new[](std::size_t s)
@vittorioromeo
vittorioromeo / sortedvec.hpp
Last active August 29, 2015 14:07
Sorted vector basic impl
template<typename TDerived> class VecBase
{
private:
inline auto& getTD() noexcept { return reinterpret_cast<TDerived&>(*this); }
inline const auto& getTD() const noexcept { return reinterpret_cast<const TDerived&>(*this); }
public:
template<typename T> inline bool has(const T& mValue) const noexcept { return getTD().is(getTD().lookup(mValue), mValue); }
inline auto& getData() noexcept { return getTD().data; }
#!/bin/bash
function finish
{
xrandr --output HDMI-0 --off
xrandr --output DVI-I-0 --off
xrandr --output HDMI-0 --primary --mode 1920x1080 --pos 0x0
xrandr --output DVI-I-0 --mode 1680x1050 --pos -1920x0
}
#define SSVU_IMPL_SINK_MN(mIT) SSVPP_TPL_ELEM(mIT, 0)
#define SSVU_IMPL_SINK_PN(mIT) SSVPP_TPL_ELEM(mIT, 1)
#define SSVU_IMPL_SINK_P_CR(mIT) const decltype(SSVU_IMPL_SINK_MN(mIT))& SSVU_IMPL_SINK_PN(mIT)
#define SSVU_IMPL_SINK_P_RV(mIT) decltype(SSVU_IMPL_SINK_MN(mIT))&& SSVU_IMPL_SINK_PN(mIT)
#define SSVU_IMPL_SINK_P_INIT(mIT) SSVU_IMPL_SINK_MN(mIT){SSVU_IMPL_SINK_PN(mIT)}
#define SSVU_DEFINE_SINK_CTOR_1(mClassName, mCode, m0) \
inline mClassName(SSVU_IMPL_SINK_P_CR(m0)) : SSVU_IMPL_SINK_P_INIT(m0) mCode \
inline mClassName(SSVU_IMPL_SINK_P_RV(m0)) : SSVU_IMPL_SINK_P_INIT(m0) mCode
@vittorioromeo
vittorioromeo / touhou.sh
Created May 20, 2014 09:13
running touhou on asus laptop
#!/bin/bash
function finish
{
xmodmap -e 'keycode 54=c'
}
trap finish EXIT
xmodmap -e 'keycode 54=x'
export WINEDEBUG=-all
WINEDEBUG=-all optirun wine "$@"
; MACRO: linux print implementation
%macro MC_linuxPrintImpl 3
mov ebx, %1 ; | <- print target (1=stdout)
mov eax, 4 ; Print 100 bytes starting from str
mov ecx, %2 ; | <- source buffer
mov edx, %3 ; | <- number of characters to print
int 80h ; \___
%endmacro
; MACRO: read from terminal
#include <SSVUtils/SSVUtils.hpp>
using Idx = std::size_t;
using Ctr = int;
template<typename> class Manager;
template<typename> class Handle;
template<typename T> class Atom
{
#include <SSVUtils/SSVUtils.hpp>
using Idx = std::size_t;
using Ctr = int;
struct Manager;
class Handle;
struct Impl
{
@vittorioromeo
vittorioromeo / test.asm
Created May 5, 2014 09:01
x86 print/write tests
section .data
str: db 100
section .bss
section .text
global _start
_start:
#include <SSVUtils/SSVUtils.hpp>
namespace Eng
{
template<typename TTokenType, typename TTokenDataType, typename TASTType> struct LangSpec
{
using TokenType = TTokenType;
using TokenDataType = TTokenDataType;
using ASTType = TASTType;
};