Skip to content

Instantly share code, notes, and snippets.

RklAlx

Block or report user

Report or block RklAlx

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 little_big_endian.txt
// https://helloacm.com/how-to-find-out-whether-a-machine-is-big-endian-or-little-endian-in-cc/
#include <stdio.h>
 
#define BIG_ENDIAN 0
#define LITTLE_ENDIAN 1
 
int TestByteOrder() {
        short int word = 0x0001;
        char *b = (char *)&word;
        return (b[0] ? LITTLE_ENDIAN : BIG_ENDIAN);
@RklAlx
RklAlx / liststoredprocs.sql
Created Feb 18, 2014
List Stored Procedures
View liststoredprocs.sql
SELECT proname, prosrc
FROM pg_catalog.pg_namespace n
JOIN pg_catalog.pg_proc p
ON pronamespace = n.oid
WHERE nspname = 'public';
@RklAlx
RklAlx / showstoredproc.sql
Created Feb 18, 2014
Showing a stored procedure
View showstoredproc.sql
SELECT prosrc FROM pg_proc WHERE proname = <function name>;
View map.cpp
#include <map>
#include <string>
using std::map;
using std::string;
class CTeste
{
public:
CTeste(){}
@RklAlx
RklAlx / strtrim.h
Created Oct 16, 2013
std::string trim
View strtrim.h
static inline std::string &ltrim(std::string &s){
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
}
static inline std::string &rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
}
@RklAlx
RklAlx / Sync.cpp
Created Sep 27, 2013
Critical Section for Linux
View Sync.cpp
// ---
// - Creating critical section variable -
// ---
pthread_mutex_t m;
// ---
// - Initializing -
//--
@RklAlx
RklAlx / Compare.cpp
Created Sep 27, 2013
InterlockedCompare
View Compare.cpp
/*
Syntax:
LONG __cdecl InterlockedCompareExchange(__inout LONG volatile *Destination,
__in LONG Exchange,
__in LONG Comparand
);
Returns the initial value of 'Destination'.
Note:
View CThreadObj.cpp
bool CMyObj::StartThread()
{
m_Running = true;
m_hThreadHandle = CreateThread(NULL,0,ThreadFunction,this,0,&this->m_ThreadID);
if(m_hThreadHandle == nullptr)
m_Running = false;
return m_Running
}
@RklAlx
RklAlx / Sync.cpp
Created Sep 27, 2013
Critical Section
View Sync.cpp
#include "Sync.h"
Sync::Sync()
{
InitializeCriticalSection(&m_cs);
}
Sync::~Sync()
{
DeleteCriticalSection(&m_cs);
@RklAlx
RklAlx / Max.cpp
Created Sep 27, 2013
std::for_each
View Max.cpp
//MAX using Lambda
std::vector<int> m_MsgTypeMaximumSize;
m_MsgTypeMaximumSize.push_back(7);
m_MsgTypeMaximumSize.push_back(5);
m_MsgTypeMaximumSize.push_back(20);
m_MsgTypeMaximumSize.push_back(1);
m_MsgTypeMaximumSize.push_back(3);
int max = 0;
You can’t perform that action at this time.