Skip to content

Instantly share code, notes, and snippets.

Davide Pasca dpasca

Block or report user

Report or block dpasca

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View json_deserial_example.cpp
//==================================================================
void Deserialize( RJSReader &r, BTT_Backtest::Params::WalletDef &v )
{
DESERIALIZE_MEMBER( r, v, currency );
DESERIALIZE_MEMBER( r, v, balance );
}
//==================================================================
void Deserialize( RJSReader &r, BTT_Backtest::Params &v )
{
View BTT_Agent::checkShouldBuyLineFit.cpp
//==================================================================
// 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
View FM_LiftDrag.cpp
//==================================================================
/// 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"
View DNET_Base.cpp
//==================================================================
/// 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 Sep 26, 2016
bilinear texture sample with clamping
View SampleClamp2D.cpp
//==================================================================
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
View event_sample.cpp
// 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;
}
View DArray.h
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 Apr 8, 2014
indicized sphere from cylinder
View gist:10142521
//--------------------------
// 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 Dec 20, 2015
My entry for the IndieVault Code Contest 01 ( http://www.indievault.it/forum/showthread.php?tid=9536 )
View CMakeLists.txt
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
View CodeStyle.cpp
// "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
You can’t perform that action at this time.