Skip to content

Instantly share code, notes, and snippets.

View marcelofern's full-sized avatar
🏠
Working from home

Marcelo marcelofern

🏠
Working from home
View GitHub Profile
@marcelofern
marcelofern / json_filtering_vs_text_casting.py
Created December 6, 2024 03:52
Json filtering vs text casting
import time
import re
import random
import psycopg2
# Change these before running locally.
DB_NAME = "json_test"
USER = "marcelo.fernandes"
PASSWORD = ""
HOST = "localhost"
@marcelofern
marcelofern / benchmark.py
Created December 2, 2024 03:56
composite index vs denormalised table
import time
import re
import random
import psycopg2
# Change these before running locally.
DB_NAME = "composed_idx"
USER = "marcelo.fernandes"
PASSWORD = ""
HOST = "localhost"
@marcelofern
marcelofern / converter.c
Created August 26, 2024 09:39
Website converter (.md -> .html)
/* converter.c
*
* This code converts `.md` files into `.html` files.
*
* The main use is to write a static website in `.md` files, and then run this
* program to convert it to `.html`
*
* The program relies on the following variables:
*
* - INPUT_FOLDER: full path of the website with `.md` files.
@marcelofern
marcelofern / build_python_version.bash
Last active August 5, 2024 03:54
Build python version
wget https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tgz
tar -xzf Python-3.11.5.tgz && cd Python-3.11.5
./configure --prefix=$HOME/localpython/3.11.5 && make && make install
./python -m venv env_3115
source env3115/bin/activate
@marcelofern
marcelofern / map.c
Created December 8, 2023 09:55
map.c
#include "array.c"
#include <stddef.h>
#include <stdint.h>
// Must be a prime number.
#define MAP_SIZE 1009
// Another prime number, but less than MAP_SIZE.
#define MAP_PRIME 31
typedef struct map_item {
@marcelofern
marcelofern / scrapper.js
Created June 3, 2023 21:54
Nova ro market scrapper
const BASE_URL = 'https://www.novaragnarok.com/?module=vending&action=item&id=';
let table = $("table#itemtable").DataTable();
let data = table.rows().data();
let ITEMS = {};
for (let i = 0; i < data.length; i++) {
let item_id = data[i][1];
let quantity = data[i][4];
@marcelofern
marcelofern / cl_reader.c
Created May 30, 2021 05:05
Command line output reader
#define _POSIX_C_SOURCE 2 // to allow popen and pclose.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct cl_reading {
char **output;
int malloc_error;
int n_lines;
int pclose_error;
@marcelofern
marcelofern / useful_postgres_queries.sql
Created July 24, 2019 01:37
Useful postgres queries
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@marcelofern
marcelofern / arch-linux.md
Last active February 6, 2019 03:24
Arch Linux installation

Marlu - Archlinux Environment

This is just a repo to save my whole OS environment configuration. Feel free to use it if you want, there's nothing super fancy about it, if you follow through the installation process you should be able to have the very same environment as me.

Requirements:

OS: Arch linux 2019.01.01

RAM (Recommended): 4GB