Skip to content

Instantly share code, notes, and snippets.

View sinbrive's full-sized avatar

sinbrive sinbrive

View GitHub Profile
@sinbrive
sinbrive / fsm-cpp.cpp
Last active December 29, 2022 15:44
States machine Abstract Class Static Access
#include <iostream>
#include "State.h"
using namespace std;
class State {
private:
static State *currentState;
@sinbrive
sinbrive / value_reference.cpp
Last active December 29, 2022 15:38
C++ Value Reference Pointer
#include <iostream>
using namespace std;
void byvalue(int a){
a++;
}
void byreference(int& a){
a++;
byte tmp1, tmp0;
tmp0=charToByte(trame[i+2]);
tmp1=charToByte(trame[i+1]);
byte myCRC = tmp1 * 16 + tmp0; // OU tmp1 << 4 | tmp0;
char CRC = calculChecksumGPS(trame);
if (myCRC== (byte)CRC)
@sinbrive
sinbrive / td2.py
Last active October 2, 2020 05:57
Pseudo code td2
Dec2bin
Tant que le nombre est non nul:
Si le bit 0 est à 1:
Ajouter '1' à resultat
Sinon:
Ajouter '0' à resultat
declaler de 1 bità droite
Afficher resultat
Bin2dec
@sinbrive
sinbrive / td2-ter.cpp
Created October 1, 2020 20:18
Td2 ter
#include <iostream>
#include <cmath>
//#include <string>
using namespace std;
char hexa [] = {'0','1','2','3','4','5','6', \
'7','8','9','A','B','C','D','E','F'};
unsigned char poids[] = {1,2,4,8,16,32,64,128};
#include <iostream>
using namespace std;
void convertirDec();
void convertirBin();
void convertirHex();
int char2int (char);
char hexa_A [] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
#include "fsm.h"
Traffic traffic(2, 4, 5, 8, 10, 12); // no constraint about the digital outputs
void setup() {
Serial.begin(9600);
}
String str = "";
/*********************************************************************
sinbrive april 2020
File Decription: Finite State Machine general framework
*********************************************************************/
#include <iostream>
#include <vector>
using namespace std;
class transition {
@sinbrive
sinbrive / split_strok_class.cpp
Last active April 26, 2020 11:19
Gist créé sur Android
#include <iostream>
#include <string.h>
class splitter {
private:
char *_del;
char *_str; //=new char[20];
bool _first;
char *_tok;
@sinbrive
sinbrive / python_simple_webserver.py
Created April 23, 2020 09:51 — forked from bgulla/python_simple_webserver.py
Python Webserver that serves up a flat HTML file.
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from time import gmtime, strftime
import sys,random,socket
PORT_NUMBER = 8000
HOSTNAME = socket.gethostname()
if len(sys.argv) > 1: