Skip to content

Instantly share code, notes, and snippets.

Avatar

ssynx StefanoBelli

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 / 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 \
View ini.cpp
#include <sstream>
#include "ini.h"
namespace ini_utils = ssynx::ini::utils;
void ssynx::ini::utils::comment_eraser(std::string &line) {
std::string::size_type commentBegin = line.find('#');
if (commentBegin != std::string::npos)
line = line.substr(0, commentBegin);
}
View exhausted.cpp
//I don't like intel syntax..
//lemme see
#include <cstdint>
//i like stdcall...
//shit I am wasted
// I like using stdcall, so we used that calling convention
// (we don't have to worry about cleaning the stack and we just push arguments on the stack
// Returns: base ^ exp
std::uint32_t __stdcall pow_unsigned(std::uint32_t base, std::uint32_t exp) {
View print.h
#ifndef PRINT_H
#define PRINT_H
#include <iostream>
#include <utility>
template<typename Ty>
void print(Ty&& p) { std::cout << std::forward<Ty>(p); }
template <typename First, typename ...Many>
View statx.h
#ifndef STATX_DEFINED_H
#define STATX_DEFINED_H
#include <unistd.h>
#include <linux/stat.h>
#include <sys/syscall.h>
#define statx(dirfd, pathname, flags, mask, buf) \
syscall(SYS_statx, dirfd, pathname, flags, mask, buf)
You can’t perform that action at this time.