Skip to content

Instantly share code, notes, and snippets.

View Yggdrasill501's full-sized avatar
🍇
Focusing

Filip Žitný Yggdrasill501

🍇
Focusing
View GitHub Profile
@Yggdrasill501
Yggdrasill501 / socket.c
Created February 3, 2024 20:47
Simplest web socket for creating web-server in C
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
int main() {
int server_fd, new_socket;
struct sockaddr_in address;
int addrlen = sizeof(address);
char buffer[1024] = {0};
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define int long long // work with 64bit target
int token;
int *text, *old_text, *stack;
char *data;
zig-cache/
zig-out/
/release/
/debug/
/build/
/build-*/
/docgen_tmp/
.DS_Store
@Yggdrasill501
Yggdrasill501 / main.py
Created November 19, 2024 13:35
Fast search and replace in dir
import os
import re
def replace_word_in_file(file_path, word_to_search, replacement_word):
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
# Regular expression to match words within string literals
# This handles both single and double quotes
pattern = re.compile(r'(["\'])(.*?)(\b' + re.escape(word_to_search) + r'\b)(.*?)\1')
"""Alternative to s3fs-fuse-awscred-lib that handles credential refreshing
using a background thread and the existing credentials service.
This implementation:
- Periodically refreshes credentials without restarting s3fs
- Uses existing credentials service
- Handles role assumption
- Provides proper error handling
- Supports debug logging
"""