Skip to content

Instantly share code, notes, and snippets.

@Rolias
Rolias / mocha-init.js
Created November 1, 2021 20:31
Experiment with Sharing Code Snippets
const chai = require(`chai`)
const sinon = require(`ts-sinon`).default
const sinonChai = require(`sinon-chai`)
const sinonAsPromised = require(`chai-as-promised`)
const chaiSubset = require(`chai-subset`)
chai.use(sinonChai)
chai.use(sinonAsPromised)
chai.use(chaiSubset)
@Rolias
Rolias / map-replace-for.ts
Created January 30, 2021 23:56
Examples for medium article on using array .map() instead of a standard for loop
import * as faker from 'faker'
const MAX_COUNT = 10
const RADIX = 10
interface IdName {
id: string
name: string
}
function getFakeDataViaIndex(index: number): IdName {

Keybase proof

I hereby claim:

  • I am Rolias on github.
  • I am rolias (https://keybase.io/rolias) on keybase.
  • I have a public key whose fingerprint is 727F A530 39B8 CA5E F380 705E B589 108C D5DD D2AB

To claim this, I am signing this object:

@Rolias
Rolias / PropertyHelper.h
Last active September 27, 2023 21:58
Qt Auto Property Macros
#pragma once
#include <QObject>
//See Gist Comment for description, usage, warnings and license information
#define AUTO_PROPERTY(TYPE, NAME) \
Q_PROPERTY(TYPE NAME READ NAME WRITE NAME NOTIFY NAME ## Changed ) \
public: \
TYPE NAME() const { return a_ ## NAME ; } \
void NAME(TYPE value) { \
if (a_ ## NAME == value) return; \
a_ ## NAME = value; \
@Rolias
Rolias / Task Sharing
Last active November 18, 2016 13:12
An example of one way to safely share a buffer between two tasks using the NetBurner version of uCOS.
//In the TCP Task
void TcpServer::ProcessMessage(int num_bytes_read)
{
//There will always be room for the terminator because we only read a max of 1 less than full size
_rxBuffer[num_bytes_read++] = '\0';
if (_debuggingTcp) cout << "tcp:Read bytes:" << num_bytes_read << " string read = " << _rxBuffer << endl;
_messageWaiting = true; //Set this first and process pending on mbox MUST call SetMessageProcessed();
BYTE err_code = OSMboxPost(&_mailbox, static_cast<void*> (_rxBuffer)); //Put a message in the Mailbox.
if ((err_code != OS_NO_ERR) && _debuggingTcp) cout << "OSMboxPost error in tcpServer " << endl;
@Rolias
Rolias / Read.cpp
Last active December 15, 2015 14:29
Simple sample of using ReadWithTimeout on the NetBurner to read X bytes without any additional delays.
void Read(int port, int messageLength, int timeoutTicks)
{
const int MAX_DATA = 1024;
if (messageLength > MAX_DATA)
{
cout << "This demo only supports lengths up to" << MAX_DATA<<'\n';
return;
}
char read_buffer[MAX_DATA];
int read_status = 0;
@Rolias
Rolias / templates.xml
Created March 4, 2013 00:04
Export of my Eclipse C++ templates (warts and all) as an xml file. Paste into an .xml file and then use Window->Preferences->C/C++->Editor->Templates and then select the Import... button and pick the file where you stored this data.
<?xml version="1.0" encoding="UTF-8"?>
-<templates><template name=",,e" enabled="true" description="<< endl;" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true"><< endl;</template><template name="Action" enabled="true" description="Typedef for pointer to member function of any class that returns void and takes no parameters" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">typedef std::tr1::function<void ()> Action; //Need to include <functional> to use this. Create an action like this //Action the_action = std::tr1::bind(&SomeClass::MemberWithMatchSig, this); //Using this binds to current class, otherwise use ptr to class to invoke upon.</template><template name="alian" enabled="true" description="alias a namespace" deleted="false" context="org.eclipse.cdt.ui.text.templates.c" autoinsert="true">namespace ${Alias} = ${FullNamespaceName};</template><template name="assign" enabled="true" description="Assginment Operator" deleted="false" context="org.e
@Rolias
Rolias / project.lnt
Last active December 12, 2015 12:39
A few project.lnt settings that vastly reduced the number of false positives I was getting from the Boost library. Other than +linebuf, the errors were a result of using BOOST_FOREACH. If you don't use that you may not need the -esym settings.
//BOOST
+linebuf
-etemplate(1054, 831,1013, 1015, 1039,1040,1054, 1070)
-emacro(64,BOOST_FOREACH)
-emacro(1703,BOOST_FOREACH)
-emacro(1025,BOOST_FOREACH)
@Rolias
Rolias / gcc-include-path.lnt
Last active December 12, 2015 12:39
Include directories for Gimpel's PC-Lint when running against the GCC 4.2.1 compiler for NetBurner development.
--i"c:\nburn\gcc-m68k\bin\../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include/c++/4.2.1"
--i"c:\nburn\gcc-m68k\bin\../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include/c++/4.2.1/m68k-elf"
--i"c:\nburn\gcc-m68k\bin\../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include/c++/4.2.1/backward"
--i"c:\nburn\gcc-m68k\bin\../lib/gcc/m68k-elf/4.2.1/include"
--i"c:\nburn\gcc-m68k\bin\../lib/gcc/m68k-elf/4.2.1/include-fixed"
--i"c:\nburn\gcc-m68k\bin\../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include"
--i"c:/nburn/gcc-m68k/lib/gcc/../../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include/c++/4.2.1"
--i"c:/nburn/gcc-m68k/lib/gcc/../../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include/c++/4.2.1/m68k-elf"
--i"c:/nburn/gcc-m68k/lib/gcc/../../lib/gcc/m68k-elf/4.2.1/../../../../m68k-elf/include/c++/4.2.1/backward"
--i"c:/nburn/gcc-m68k/lib/gcc/../../lib/gcc/m68k-elf/4.2.1/include"
@Rolias
Rolias / lint_cppmac.h
Created February 12, 2013 20:52
C++ .h file for Gimpel's PC-Lint when running against the GCC 4.2.1 compiler for NetBurner development. Included from co-gcc.h which is used by the co-gcc.lnt file.
#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __DEC64_DEN__ 0.000000000000001E-383DD
#define __CHAR_BIT__ 8
#define __mcf_cpu_5206 1
#define __WCHAR_MAX__ 2147483647
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __FLT_EVAL_METHOD__ 0
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0