Skip to content

Instantly share code, notes, and snippets.

//==================================================================
// curTimeUS: current time in micro-seconds
// idxB : index of the currency we're looking to buy (for BTC/USD: 0=BTC, 1=USD)
bool BTT_Agent::checkShouldBuyLineFit( TimeUS curTimeUS, const size_t idxB ) const
{
c_auto &tdis = mBTTask.GetCurTDIStream();
c_auto &entries = tdis.GetCurBatch().mTDEntries;
c_auto timeMaxS = TimeUSToSecs( curTimeUS );
c_auto timeMinS = timeMaxS - 60.0 * 60.0 * 12; // from previous N seconds
//==================================================================
/// FM_LiftDrag.cpp
///
/// Created by Davide Pasca - 2017/6/12
/// See the file "license.txt" that comes with this project for
/// copyright info.
//==================================================================
#include "stdafx.h"
#include "FM_Utils.h"
//==================================================================
/// DNET_Base.cpp
///
/// Created by Davide Pasca - 2009/8/2
/// See the file "license.txt" that comes with this project for
/// copyright info.
//==================================================================
#if defined(WIN32)
# include <WinSock2.h>
@dpasca
dpasca / SampleClamp2D.cpp
Created September 26, 2016 16:25
bilinear texture sample with clamping
//==================================================================
template <typename _T>
inline _T SampleClamp2D(
const DVec<_T> &samp,
int sampW,
int sampH,
float u,
float v )
{
u = std::max( u, _T(0) ); // only clamp to min.. max comes below
@dpasca
dpasca / event_sample.cpp
Created August 17, 2015 08:26
Event recording
// sure cost
void GameMain::UIInputTouchBegan( void *id, float x, float y )
{
DASSERT( !mEventLock ); mEventLock = true;
mEventData.WriteValue<u_int>( EVT_TOUCH_BEGAN );
mEventData.WriteValue<void *>( id );
mEventData.WriteValue<float>( x );
mEventData.WriteValue<float>( y );
mEventLock = false;
}
@dpasca
dpasca / DArray.h
Last active August 29, 2015 14:20
template <class _T, size_t _SIZE>
class DArray
{
U32 mBuff[ (sizeof(_T) * _SIZE + 3) / 4 ];
size_t mSize = 0;
#if defined(_DEBUG) || defined(DEBUG)
_T *mpDbgPtr = (_T *)mBuff;
#endif
public:
@dpasca
dpasca / gist:10142521
Created April 8, 2014 15:26
indicized sphere from cylinder
//--------------------------
// setup geometry
const static u_int NDIV_PHI = 20;
const static u_int NDIV_THE = 20;
mPosBase.reserve( NDIV_PHI * NDIV_THE );
auto &geom = *moBaseMesh->mpGeom;
geom.mNor.reserve( mPosBase.size() );
@dpasca
dpasca / CMakeLists.txt
Last active December 20, 2015 00:58
My entry for the IndieVault Code Contest 01 ( http://www.indievault.it/forum/showthread.php?tid=9536 )
cmake_minimum_required (VERSION 2.6)
project (ivcc01_thecrib)
if(MSVC) #((((((((((((((((
set(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /DWIN32 /MD /Ox /Ot /Oi /GL /Ob2 /Oy /arch:SSE2")
set(CMAKE_CXX_FLAGS_RELEASE "/DNDEBUG /DWIN32 /MD /Ox /Ot /Oi /GL /Ob2 /Oy /arch:SSE2")
set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /DWIN32 /Zi /MDd /Od /arch:SSE2")
set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /DWIN32 /Zi /MDd /Od /arch:SSE2")
add_definitions( "/D_CRT_SECURE_NO_WARNINGS /wd4996 /nologo" ) # disable annoying secure CRT warnings
// "const auto" is just too common not to have an alias
#define c_auto const auto
class Type; // forward declaration if possible
//==================================================================
class ClassName
{
size_t mMember = 0; // 'm' prefix for member variable
U8 *mpPointer {}; // 'mp' prefix for member pointer
namespace DGLUT
{
//==================================================================
void CheckGLErr( const char *pFileName, int line )
{
GLenum err = glGetError();
while (err != GL_NO_ERROR)
{
const char *pErr = NULL;