Skip to content

Instantly share code, notes, and snippets.

View jpcofr's full-sized avatar

Juan Pablo Contreras Franco jpcofr

  • Gothenburg, Sweden
View GitHub Profile
@jpcofr
jpcofr / CMakeLists.txt
Last active April 10, 2023 09:38
Build config for raylib & raylib_cpp in macOS 13.3
# Description: Build configuration for the "raylib [core] example - World to screen"
# using raylib and raylib_cpp from their repositories.
# (https://www.raylib.com/examples/core/loader.html?name=core_world_screen)
# Compatibility: macOS 13.3
# Dependencies: raylib 4.5.0, raylib_cpp v4.5.0
cmake_minimum_required(VERSION 3.25)
project(a_project)
set(CMAKE_BUILD_TYPE Debug)
@jpcofr
jpcofr / CMakeLists.txt
Created April 10, 2023 09:36
Build config for SFML in macOS 13.3
# Description: Build configuration for the "SFML example - Basic window and event handling"
# using SFML from its repository.
# Compatibility: macOS 13.3
# Dependencies: SFML (master branch)
cmake_minimum_required(VERSION 3.25)
project(a_window)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
@jpcofr
jpcofr / CMakeLists.txt
Created May 15, 2023 14:57
CMake configuration for 'challenge_project' with googletest unit testing and benchmarking
# Description: Build configuration for the "challenge_project", including unit tests with Google's googletest and performance
# benchmarks with Google's benchmark library. The executables generated are "my_test" for testing and "my_bench"
# for benchmarking.
# Compatibility: Requires CMake version 3.25 and a C++17 compatible compiler.
# Dependencies: Google's googletest (v1.13.0) and Google's benchmark (v1.7.1) libraries, pthread library.
cmake_minimum_required(VERSION 3.25)
set(CMAKE_CXX_STANDARD 17)
project(challenge_project)
@jpcofr
jpcofr / spaces_to_underscores.py
Created June 2, 2023 11:58
Replace Spaces with Underscores in File Names
#!/usr/bin/env python3
import os
import sys
# Check if the file name is provided as an argument
if len(sys.argv) < 2:
print("Error: No file name provided.")
sys.exit(1)
@jpcofr
jpcofr / CMakeLists.txt
Created August 11, 2023 06:37
Build config for a very simple C/C++ project with tests and benchmark support
# Description: Build configuration for a simple project ready for benchmarking and testing.
# New source files can be added on demand as the build system recurses the repository.
# Compatibility: macOS 13.3
# Dependencies: gtest, Google Benchmark
cmake_minimum_required(VERSION 3.25)
set(CMAKE_CXX_STANDARD 17)
project(challenge_project)
set(CMAKE_BUILD_TYPE Debug)
@jpcofr
jpcofr / temp.py
Last active April 22, 2024 12:50
temporal
kubectl get pods --field-selector=status.phase!=Running,status.phase!=Succeeded -o custom-columns=NAME:.metadata.name,STATUS:.status.phase
#!/bin/bash
for i in {1..2300}
do
touch "file_${i}.txt"
done
@jpcofr
jpcofr / .gitignore
Last active October 2, 2023 15:06
Minimal C++/gtest cmake project
build
.vscode
@jpcofr
jpcofr / CMakeLists.txt
Created October 1, 2023 09:31
Demonstrating Comparison Usage with std::sort using Google Test
cmake_minimum_required(VERSION 3.25)
set(CMAKE_CXX_STANDARD 11)
project(c_cpp_snippet)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Find ccache
@jpcofr
jpcofr / chunked_http_server.py
Created October 15, 2023 07:57
This script serves a JSON payload in multiple chunks, demonstrating HTTP/1.1 chunked transfer encoding.
"""
This script implements a basic HTTP server that listens on port 8080 and responds to
incoming HTTP requests with chunked transfer encoding as per the HTTP/1.1 standard.
Upon receiving a request, the server sends a JSON payload as the response, broken
down into a specified number of chunks to demonstrate the chunked transfer
encoding mechanism.
"""
# HTTP 1 - Server
import socket
@jpcofr
jpcofr / extract_http_packets_as_hex.py
Created October 15, 2023 16:37
Extracts HTTP packet details from a pcap file and writes them alongside hexadecimal content to an output file
"""
This script extracts HTTP packet details from a pcap file, formats them
with their respective HTTP verb, URI, and status code, and writes the
hexadecimal content of each packet along with a descriptive header
to a specified output file.
"""
import subprocess
import sys
from scapy.all import *