Skip to content

Instantly share code, notes, and snippets.

View sharedmemory.cpp
//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 */
View uartwolf.c
#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 Dec 15, 2016
A function printing float to char* buffer without using %f. Excellent for arduino projects purpose. Fully SIGSEGV-prone. Enjoy!
View printfloat.c
#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 Oct 14, 2016
cmake for boost tests
View CMakeLists.txt
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 Oct 29, 2015
Simple spamscript integrated with gmail
View spamscript.py
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 Sep 5, 2015
[qt5] tetris game - in one file
View tetris.py
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__()
View combo_box.py
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 Sep 5, 2015
[qt5] splitters
View splitter.py
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 Sep 5, 2015
[qt5] callendar widget
View calendar_widget.py
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 Sep 5, 2015
[qt5] progress bar - written with camelCase
View progress_bar.py
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()