Skip to content

Instantly share code, notes, and snippets.

Avatar

ssynx StefanoBelli

  • Rome, Italy
View GitHub Profile
View install-latest-teams.sh
#!/bin/bash
DL="https://teams.microsoft.com/downloads/desktopurl?env=production&plat=linux&arch=x64&download=true&linuxArchiveType=deb"
BUILDDIR=/tmp/teams-build
PRIV="sudo"
if ! which wget 2>/dev/null >>/dev/null; then
echo "unable to find wget"
exit 1
fi
@StefanoBelli
StefanoBelli / Makefile
Last active Feb 19, 2020
Makefile C template
View Makefile
SHELL = /bin/bash
CC = gcc
OBJECT_FLAG = -c
CFLAGS = -O2 -pedantic -std=c99 -Wall -Wextra -Wshadow -W
LIBS = -lexample
OBJS = example.o
OUT = example
SUPPRESS_OUTPUT = > /dev/null 2>&1
all:$(OBJS)
@StefanoBelli
StefanoBelli / sane_example.c
Created Aug 26, 2019
SANE API usage example
View sane_example.c
// SANE API usage example
// link against libsane
// --> http://www.sane-project.org/html/doc012.html
#include <sane/sane.h>
#include <stdio.h>
int main() {
//
// Initialize SANE
//
@StefanoBelli
StefanoBelli / cpuexcp.h
Created Aug 19, 2019
Dedicato a vbextreme... come farei senza di lui
View cpuexcp.h
#ifndef HANDLE_SEGV_H
#define HANDLE_SEGV_H
#include <setjmp.h>
#include <signal.h>
#ifdef __GNUC_MINOR__
#define constructor __attribute__((__constructor__))
#else
#error vbextreme utilizza solo GCC
View ClearConsole.c
#include <Windows.h>
void ClearConsole(HANDLE console) {
const COORD origin = { 0,0 };
DWORD writtenBytes;
DWORD consoleSize;
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(console, &info);
@StefanoBelli
StefanoBelli / smalloc.S
Created Jul 6, 2019
Simple libc-independent malloc implementation (originally written for sysh) (look at the comment section
View smalloc.S
#
# smalloc.S
#
# Simple Malloc implementation for sysh, libc-independent
#
# IF ARCH IS x86_64 THEN
# STRUCT (block_header) : {
# DATA_SIZE off 0
# _FREE_BLK off 8
View showstats.c
//gcc showstats.c -lwiringPi -lwiringPiDev
#define ROWS 2
#define COLS 16
#define RS 1
#define EN 4
#define D7 7
#define D6 0
#define D5 2
#define D4 3
@StefanoBelli
StefanoBelli / x86_fast_string.cpp
Last active Jan 2, 2019
Using MSVC, Clang and GCC x86 intrinsics to use x86's SSE4.2 ISA to implement some string manip functions
View x86_fast_string.cpp
// x86_fast_string.cpp
#include <nmmintrin.h>
#include <immintrin.h>
#include <cstdint>
#if defined(_MSC_VER)
#define x86_fetch_eflags(mem_dst_32) \
__asm { \
__asm pushfd \
@StefanoBelli
StefanoBelli / num.h
Last active Apr 26, 2021
More than simple math (math utils for C++)
View num.h
#ifndef NUMERIC_H
#define NUMERIC_H
#include <initializer_list>
#include <type_traits>
#include <sstream>
#include <string>
#include <exception>
#include <vector>
#include <array>
View mallog.c
// mallog.c
// wraps C library dynamic memory managment functions:
// * malloc
// * calloc
// * realloc
// * free
// on each call, it logs:
// [sym]:[addr]:[size-in-bytes]
// libdl must be linked to resolve malloc in libc
// LD_PRELOAD allows you to tell the dynamic linker to resolve