Skip to content

Instantly share code, notes, and snippets.

View sqn175's full-sized avatar
🎯
Focusing

Qin Shi sqn175

🎯
Focusing
  • Tsinghua University
  • Beijing, China
View GitHub Profile
@sqn175
sqn175 / crc16.cpp
Last active February 25, 2022 01:38
Compute CRC16 using table
static const uint16_t crctable[256] =
{
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
0x0919, 0x1890, 0x2A0B, 0x3B82, 0x4F3D, 0x5EB4, 0x6C2F, 0x7DA6,
0x8551, 0x94D8, 0xA643, 0xB7CA, 0xC375, 0xD2FC, 0xE067, 0xF1EE,
0x1232, 0x03BB, 0x3120, 0x20A9, 0x5416, 0x459F, 0x7704, 0x668D,
0x9E7A, 0x8FF3, 0xBD68, 0xACE1, 0xD85E, 0xC9D7, 0xFB4C, 0xEAC5,
0x1B2B, 0x0AA2, 0x3839, 0x29B0, 0x5D0F, 0x4C86, 0x7E1D, 0x6F94,
0x9763, 0x86EA, 0xB471, 0xA5F8, 0xD147, 0xC0CE, 0xF255, 0xE3DC,
@sqn175
sqn175 / singleton.cpp
Created July 22, 2021 09:26
c++ singleton
#include<iostream>
template<typename T>
class Singleton
{
public:
static T& getInstance() {
static T t;
return t;
}
@sqn175
sqn175 / main.cpp
Created June 1, 2021 09:39
C API register C++ class member function
#include <string>
#include <iostream>
// In client side
using CallbackFnPtr = void (*)(const std::string, void *);
CallbackFnPtr c_fn;
void* c_fn_context;
void c_run_callback()
@sqn175
sqn175 / launch.json
Last active January 4, 2021 02:48
vscode configuration files for cmake build and debug
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
@sqn175
sqn175 / SpinCalc.m
Created June 29, 2019 07:42
Function for the conversion of one rotation representation type to the desired one. Author: John Fuller
function OUTPUT=SpinCalc(CONVERSION,INPUT,tol,ichk)
%Function for the conversion of one rotation input type to desired output.
%Supported conversion input/output types are as follows:
% 1: Q Rotation Quaternions
% 2: EV Euler Vector and rotation angle (degrees)
% 3: DCM Orthogonal DCM Rotation Matrix
% 4: EA### Euler angles (12 possible sets) (degrees)
%
%Author: John Fuller
%National Institute of Aerospace
@sqn175
sqn175 / net.js
Created March 25, 2019 12:30 — forked from sid24rane/net.js
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
var net = require('net');
// creates the server
var server = net.createServer();
//emitted when server closes ...not emitted until all connections closes.
server.on('close',function(){
console.log('Server closed !');
});
@sqn175
sqn175 / Eigen Cheat sheet
Last active December 17, 2020 09:37 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@sqn175
sqn175 / create_mat.cc
Created May 29, 2018 02:29
Creating matrix in different ways
// Stolen from http://opencvexamples.blogspot.jp/2013/09/creating-matrix-in-different-ways.html?m=1
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"
using namespace cv;
using namespace std;
int main( )
#include <iostream>
#include <vector>
using namespace std;
class Base{
public:
virtual int n(){return n_;}
virtual ~Base(){}
int n_=0;
https://github.com/Microsoft/MIEngine/blob/master/src/AndroidDebugLauncher/Microsoft.Android.natvis
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<!-- gnu stl -->
<Type Name="std::initializer_list&lt;*&gt;">
<DisplayString>{{ size={_M_len} }}</DisplayString>
<Expand>