Skip to content

Instantly share code, notes, and snippets.

View mdrokz's full-sized avatar
🎯
Focusing

mdrokz mdrokz

🎯
Focusing
View GitHub Profile
@mdrokz
mdrokz / copy.sh
Created January 11, 2025 10:53
Copy files from one directory and output to another in bash
find ./src/lib/components/Icons/ -type f -not -name "index.ts" -exec sh -c 'cat "$0" > "./static/icons/$(basename "$0".svg)"' {} \;
@mdrokz
mdrokz / crud.ts
Created November 5, 2024 07:34
Generic API client for CRUD operations
import { v4 as uuidv4 } from 'uuid';
type METHODS = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
const baseUrl = "http://localhost:3000";
export async function baseFetch<T = Record<string, string>>(method: METHODS, path?: string, body?: T, url: string = baseUrl) {
return fetch(url + path, {
method,
headers: {
@mdrokz
mdrokz / Dockerfile
Created December 28, 2023 11:41
Custom dockerfile to install extension from pgxn network into postgres
FROM postgres:latest
# FROM debian:latest
# libpq-dev make gcc postgresql postgresql-dev-all
RUN apt-get update && \
apt-get install -y \
python3 \
pipx \
make \
@mdrokz
mdrokz / clone_repos_by_org.sh
Created August 24, 2023 17:40
Bash script to clone all the repos by organization by using the gh graphql API
#!/bin/bash
clone_repos_by_org() {
local orgName="$1"
local numRepos="$2"
local name=$(getReposByOrg "$orgName" "$numRepos" | jq "{nodes: .data.organization.repositories.nodes}")
cd ./repos
@mdrokz
mdrokz / clinfo.txt
Created August 18, 2023 10:02
OPENCL system information
Number of platforms 3
Platform Name Clover
Platform Vendor Mesa
Platform Version OpenCL 1.1 Mesa 23.1.5
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd
Platform Extensions function suffix MESA
Platform Name AMD Accelerated Parallel Processing
Platform Vendor Advanced Micro Devices, Inc.
@mdrokz
mdrokz / sync_to_ec2.sh
Created August 17, 2023 20:09
Script to sync ebooks to my EC2 ubooquity server
# Declare the associative array for existing files
declare -A existing_files_map
# Generate log filenames based on the current date and time
skipped_log="logs/skipped_$(date +'%d-%m-%y %H:%M:%S').txt"
uploaded_log="logs/uploaded_$(date +'%d-%m-%y %H:%M:%S').txt"
# Fetch the list of files already present on the EC2 server using find with null delimiter
# and populate the associative array
Computer Information:
Manufacturer: Micro-Star International Co., Ltd.
Model: MPG X570 GAMING EDGE WIFI (MS-7C37)
Form Factor: Desktop
No Touch Input Detected
Processor Information:
CPU Vendor: AuthenticAMD
CPU Brand: AMD Ryzen 7 3800X 8-Core Processor
CPU Family: 0x17
CPU Model: 0x71
@mdrokz
mdrokz / delete_rust_target_folders.sh
Created July 30, 2023 16:44
delete target folders in your dir where you store all of your rust projects
#!/bin/bash
# Check if directory argument is provided
if [ -z "$1" ]; then
echo "Please provide a directory as an argument."
exit 1
fi
# Create an array of directories
dirs=($(ls -d "$1"/*))
@mdrokz
mdrokz / promtail_docker_logs.md
Created July 17, 2023 00:15 — forked from ruanbekker/promtail_docker_logs.md
Docker Container Logging using Promtail
@mdrokz
mdrokz / design_hashset_705.rs
Created May 30, 2023 15:09
Leetcode problem 705 design a hashset implemented in rust
struct MyHashSet {
buckets: Vec<Vec<i32>>,
}
/**
* `&self` means the method takes an immutable reference.
* If you need a mutable reference, change it to `&mut self` instead.
*/