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 / 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 / README.md
Created March 6, 2024 19:40
Simple Flask web server

Project Setup and Server Execution

To set up the project and run the server, follow these steps:

  1. Python Environment Setup:

    • Ensure Python is installed on your system. You can download and install Python from the official website if needed.
  2. Install Required Libraries:

    • Install Flask, the web framework used for creating the HTTP server:
@jpcofr
jpcofr / lazy.md
Last active February 17, 2024 10:34
Task Description Command GNU coreutils/POSIX utils/Unix utils
Create tcsh Alias for readlink alias toclip 'readlink -f \!:1 | to_clipboard' alias, readlink, to_clipboard
Improving alias for copying a path to the clipboard
@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 *
@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 / .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 / 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 / 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 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)