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 / main.cpp
Created March 25, 2018 16:44
Recursive Descent Parser for arithmetic expressions
// g++ -o parser main.cpp parser.h parser.cpp -O3 -Wall -fpie
#include <iomanip>
#include <iostream>
#include <string>
#include <sstream>
#include "parser.h"
using namespace std;
@phoemur
phoemur / shunting_yard.cpp
Created March 24, 2018 03:18
Shunting_yard algorithm
/* while there are tokens to be read:
read a token.
if the token is a number, then push it to the output queue.
if the token is an operator, then:
while ((there is an operator at the top of the operator stack with
greater precedence) or (the operator at the top of the operator stack has
equal precedence and
the operator is left associative)) and
(the operator at the top of the stack is not a left bracket):
pop operators from the operator stack, onto the output queue.
@phoemur
phoemur / FFT.cpp
Last active August 23, 2023 02:10
Cooley–Tukey Fast Fourier Transform algorithm - Recursive Divide and Conquer implementation in C++
// g++ -o FFT FFT.cpp -Wall -O3
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <vector>
using namespace std;
@phoemur
phoemur / minesweeper.cpp
Last active November 8, 2017 01:17
Minesweeper comand line C++
#include <deque>
#include <iostream>
#include <iomanip>
#include <random>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
struct Cell { //represents one cell in the minefield
#include <iostream>
#include <iterator>
#include <random>
#include <set>
#include <sys/time.h>
#include <vector>
using namespace std;
static inline uint64_t startRDTSC (void) {
#ifndef SORTED_VECTOR_HPP
#define SORTED_VECTOR_HPP
#include <functional>
#include <memory>
#include <initializer_list>
#include <algorithm>
#include <iostream>
namespace homebrew {
@phoemur
phoemur / webshell.py
Created August 6, 2017 23:39
Basic webshell with Python + Flask and WebSockets (Flask-SocketIO)
#!/usr/bin/env python
import subprocess
from flask import Flask, render_template
from flask_socketio import SocketIO, send, emit
HTML = '''
<html>
<head>
<title>WEBSHELL</title>
#!/usr/bin/env python3
import re
import urllib.request
import urllib.parse
import http.cookiejar
import os
from lxml.html import fragment_fromstring
from collections import OrderedDict
#!/usr/bin/env python3
import re
import urllib.request
import urllib.parse
import http.cookiejar
from lxml.html import fragment_fromstring
from collections import OrderedDict
@phoemur
phoemur / keylogger.py
Created September 17, 2015 20:13
Keylogger
#!/usr/bin/env python3
import ctypes
import os
import sys
import tempfile
from ctypes.util import find_library
from time import sleep