Skip to content

Instantly share code, notes, and snippets.

//sharedmemory.h
#ifndef SHAREDMEMORY_H
#define SHAREDMEMORY_H
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h> /* For mode constants */
#include <unistd.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#define BAUDRATE B9600
#define MODEMDEVICE "/dev/ttyAMA0"
@saleph
saleph / printfloat.c
Last active December 15, 2016 17:46
A function printing float to char* buffer without using %f. Excellent for arduino projects purpose. Fully SIGSEGV-prone. Enjoy!
#include <stdio.h>
/// Prints float to buffer without using %f (for microcontrollers purpose)
///
/// Usage:
/// char buffer[20];
/// printFloatToBuffer(buffer, 20, -3.1415, 3);
/// printf("%s", buffer);
///
void printFloatToBuffer(char *buffer, size_t bufferSize, float val, unsigned int precision) {
@saleph
saleph / CMakeLists.txt
Created October 14, 2016 09:33
cmake for boost tests
project(simple_tests)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_definitions(-DBOOST_TEST_DYN_LINK)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
@saleph
saleph / spamscript.py
Created October 29, 2015 21:02
Simple spamscript integrated with gmail
import smtplib
fromaddr = ''
toaddrs = ''
msg = "\r\n".join([
"From: %s" % fromaddr,
"To: %s" % toaddrs,
"Subject: THIS PYTHON SHIT IS WORKING!!!",
"",
])
@saleph
saleph / tetris.py
Created September 5, 2015 20:38
[qt5] tetris game - in one file
import sys, random
from PyQt5.QtWidgets import (QMainWindow, QFrame,
QDesktopWidget, QApplication)
from PyQt5.QtCore import Qt, QBasicTimer, pyqtSignal
from PyQt5.QtGui import QPainter, QColor
class Tetris(QMainWindow):
def __init__(self):
super().__init__()
@saleph
saleph / combo_box.py
Created September 5, 2015 12:13
[qt5] combo box
import sys
from PyQt5.QtWidgets import (QWidget, QLabel,
QComboBox, QApplication)
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
@saleph
saleph / splitter.py
Created September 5, 2015 11:51
[qt5] splitters
import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QFrame,
QSplitter, QApplication)
from PyQt5.QtCore import Qt
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
@saleph
saleph / calendar_widget.py
Created September 5, 2015 11:37
[qt5] callendar widget
import sys
from PyQt5.QtWidgets import (QWidget, QCalendarWidget,
QLabel, QApplication)
from PyQt5.QtCore import QDate
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
@saleph
saleph / progress_bar.py
Created September 5, 2015 08:53
[qt5] progress bar - written with camelCase
import sys
from PyQt5.QtWidgets import (QWidget, QProgressBar,
QPushButton, QApplication)
from PyQt5.QtCore import QBasicTimer
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()