Skip to content

Instantly share code, notes, and snippets.

View jpalala's full-sized avatar
🔭
Lets build something useful

Joe Palala jpalala

🔭
Lets build something useful
View GitHub Profile
@jpalala
jpalala / somebashscript.sh
Created September 26, 2025 13:00
manjaro or arch to install hyperland with rounded corners and sane defaults
#!/usr/bin/env bash
set -e
echo "=== Updating system and installing packages ==="
sudo pacman -Syu --noconfirm
# Hyprland dependencies (skip if already installed on Manjaro Sway)
sudo pacman -S --noconfirm hyprland waybar alacritty albert dunst rofi \
pipewire pipewire-pulse wireplumber brightnessctl wl-clipboard grim slurp swaybg
@jpalala
jpalala / leetpassphrasegenerator.php
Created September 26, 2025 03:36
leet password generator
<?php
function leetTransform($word) {
$result = "";
$vowels = ['a', 'i', 'o', 'u'];
foreach (str_split($word) as $c) {
if ($c === '-') {
$result .= '-'; // keep dash as-is
} elseif (strtolower($c) === 'e') {
@jpalala
jpalala / thundering_horde.md
Last active September 22, 2025 06:29
an example of thundering horde and mitigation steps with react

A thundering herd problem in React, where multiple components simultaneously fetch the same data, can be a major issue. To mitigate this, especially when using useEffect with a large, complex dependency array, you should avoid fetching data directly in components that are re-rendered frequently. A better approach is to centralize your data fetching logic.

  1. Data Fetching Outside of Components

The best way to prevent the thundering herd problem is to move your fetching logic out of the component tree entirely. This ensures that the data is fetched only once, regardless of how many times the components that depend on it re-render.

  • Custom Hooks: Create a custom hook that fetches and manages the data state. This hook can have its own internal state to prevent multiple fetches.
  • Centralized State Management: Use a state management library like Redux, Zustand, or a similar pattern with React Context to manage the global state of your application. The fetch request is initiated from an action cre
@jpalala
jpalala / README.md
Last active September 14, 2025 00:39
DEXEC.SH (NOW DEXEC IN C)

dexec

dexec is a small command‑line utility (written in C) that wraps Docker commands to make working with Docker Compose and docker exec easier. By default it runs docker compose, but when called with the -e (or --exec) flag, it runs docker exec.


Features

  • Checks that the docker binary exists before doing anything.
  • Default behavior: use docker compose with any arguments you pass.
@jpalala
jpalala / why zip.md
Last active September 9, 2025 22:38
Go zip
func Zip[T any](a, b []T) ([][2]T, error) {
    if len(a) != len(b) {
        return nil, fmt.Errorf("zip: lengths differ")
    }
    r := make([][2]T, len(a))
    for i, e := range a {
        r[i] = [2]T{e, b[i]}
    }
 return r, nil
@jpalala
jpalala / Laravel.dockerfile
Last active September 9, 2025 09:45
docker files for laravel
# Use the official PHP 8.4 FPM Alpine image as the base
FROM php:8.4-fpm-alpine
# Update and upgrade packages, then install basic dependencies
# The --no-cache option keeps the image size smaller
RUN apk update && apk upgrade --no-cache \
&& apk add --no-cache bash git
# Install PHP extensions
# This part assumes you have a script named install-php.sh in your .docker directory
@jpalala
jpalala / using_yajra_datatables_laravel.md
Created September 6, 2025 01:16
solving the problem with yajra datatable

Yes, it's definitely possible to present a Laravel API resource as a paginated DataTable, and libraries like Yajra DataTable make this process significantly easier!

You're on the right track by mentioning Yajra DataTable. It's a very popular and powerful package that handles exactly what you're looking to achieve.

Here's a general overview of how you'd approach this in Laravel using Yajra DataTable:

1. Install Yajra DataTable:

First, you'll need to install the package via Composer:

@jpalala
jpalala / cplusplus_remove_duplicates.md
Created September 1, 2025 23:29
remove duplicates c++

Using C++ how do you remove duplicates from a vector set

To remove duplicates from a std::vector in C++, the most common and efficient approach involves using std::sort and std::unique from the header, followed by std::vector::erase. This method modifies the original vector and sorts its elements.

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
@jpalala
jpalala / gist.md
Last active August 23, 2025 02:57
hyde theme using tailwind

I asked Gemini to make me this and it came up with this.

@jpalala
jpalala / Git.md
Created June 29, 2025 01:24
Git and Symfony things

Undoing git stash

To undo a git stash, it depends on what exactly you mean by “undo”:


🔁 1. If you applied a stash and want to undo the changes:

git stash apply       # or git stash pop