Skip to content

Instantly share code, notes, and snippets.

View phoemur's full-sized avatar

phoemur phoemur

  • Avaré-SP, Brazil
View GitHub Profile
@phoemur
phoemur / quicksort.asm
Created July 23, 2023 01:22
Quicksort example in x86_64 Assembly - Linux
; Quicksort example in x86_64 Assembly - Linux
; Assembler: NASM
; Fernando B. Giannasi - jul/2023
section .data
DATA dq 1, 9, 2, 8, 3, 7, 4, 6, 5, 0, 70, 69, 68, 67, 66, 65, 1, 9, 2, 8, 3, 7, 4, 6, 5, 0, 70, 69, 68, 67, 66, 65, 1, 9, 2, 8, 3, 7, 4, 6, 5, 0, 70, 69, 68, 67, 66, 65
DATA_LEN equ $ - DATA
section .bss
@phoemur
phoemur / cat.asm
Created July 9, 2023 21:51
Simple program emulating UNIX cat
; Simple program emulating UNIX cat
;
; Assembler: YASM
;
; Fernando Giannasi
; July 09, 2023
section .data
SYS_EXIT equ 60
@phoemur
phoemur / printargs.asm
Created July 9, 2023 16:57
asm to print command line arguments
section .data
EXIT_SUCCESS equ 0 ; successful operation
SYS_exit equ 60 ; call code for terminate
linefeed db 10
stringRes db "Number of arguments: "
section .text
global _start
@phoemur
phoemur / Aho.hpp
Created December 12, 2018 23:31
Aho-Corasick algorithm in C++
#ifndef AHO_CORASICK_HEADER
#define AHO_CORASICK_HEADER
#include <queue>
#include <unordered_map>
#include <vector>
#include <iostream>
// Reference https://www.toptal.com/algorithms/aho-corasick-algorithm
/*16
1 4
2 4
3 4
4 5
5 6
6 7
7 8
7 9
6 10
@phoemur
phoemur / CMakeLists.txt
Created May 13, 2018 20:15 — forked from Univan-Ahn/CMakeLists.txt
Moving from QMake to CMake for Qt5 projects
cmake_minimum_required(VERSION 2.8.11)
project(Qt5App)
#
# Qt5 support
#
# general overview:
# * [Modern CMake with Qt and Boost](http://www.kdab.com/modern-cmake-with-qt-and-boost/)
# * [Using CMake with Qt 5](http://www.kdab.com/using-cmake-with-qt-5/)
@phoemur
phoemur / dynbitset.hpp
Created April 27, 2018 01:27
Dynamic Bitset in C++ implemented as a std::vector<bool>
#ifndef DYNAMIC_BITSET_HEADER
#define DYNAMIC_BITSET_HEADER
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <stdexcept>
#include <string>
#include <sstream>
@phoemur
phoemur / tictactoe.cpp
Created April 11, 2018 22:34
Exemplo para o VOL. Compilar com: g++ -o tictactoe tictactoe.cpp
#include <algorithm>
#include <array>
#include <iostream>
#include <string>
#include <utility>
//print instructions
void instructions(const std::array<std::array<char, 3> ,3>& board)
{
std::cout << "Choose a cell numbered from 1 to 9 as below\n and play\n\n";
@phoemur
phoemur / avltree.hpp
Last active November 30, 2023 02:46
AVL Tree implemented in modern C++ (C++14), using smart_pointers for memory management, move semantics and variadic number of elements for insert and remove
// based on https://users.cs.fiu.edu/~weiss/dsaa_c++4/code/AvlTree.h
#ifndef AVL_TREE_HEADER_MAIN
#define AVL_TREE_HEADER_MAIN
#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <memory>
@phoemur
phoemur / binary_heap.hpp
Created April 3, 2018 18:42
Binary Heap implemented using C++ STL algorithms for heaps
#ifndef BINARY_HEAP_HPP
#define BINARY_HEAP_HPP
#include <algorithm>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <stack>
#include <type_traits>
#include <vector>