Skip to content

Instantly share code, notes, and snippets.

View kuya-joe's full-sized avatar

Joe kuya-joe

View GitHub Profile
@kuya-joe
kuya-joe / mysql_good_at_insert_or_reading.md
Last active November 3, 2024 02:13
copy-on-write idea chatgpt idea

Relational databases like MySQL are generally optimized for both read and write operations, but their performance can vary based on several factors:

Insert Operations

  • Speed: Inserts can be fast, especially for bulk inserts, as relational databases are optimized for transaction management and can handle multiple inserts efficiently. However, performance can be impacted by factors like indexing, foreign key constraints, and the size of the dataset.
  • Locking: During inserts, MySQL may lock rows or tables, which can lead to contention if many concurrent writes are occurring.
  • Transaction Overhead: If you're using transactions, there may be some overhead that affects the speed of individual inserts.

Read Operations

  • Speed: Reading data is typically very fast, especially if the necessary indexes are in place. Indexes allow the database to locate rows more efficiently without scanning the entire table.
  • Caching: Many databases, including MySQL, utilize caching mechanisms (like que
@kuya-joe
kuya-joe / reddit.md
Created September 2, 2024 02:25
laravel community guide

This is for the Laravel Philippines community use only

Q: What is the argument for a community outside of facebook.

In the Philippines, tech groups are a faceboook group thing, because we pinoys generally like to use social media, despite the issues other countries might have regarding privacy. However,we need a forum like place to be able to link with the original founders of the facebook group, who were previously admins but now were kicked out. The reason that was given being a semi-satirical post that the original admin posted and changing the rules to STILL ALLOW freedom of expression.

This is the alternative path to be able to continue the work that the original founders started.

Q: There is an existing reddit r/laravel group already, why not post there - isn't this wrong?

@kuya-joe
kuya-joe / index.php
Created August 27, 2023 03:12 — forked from vinzenz/index.php
Extremely Simple Sample TODO List App in PHP
<!--
Copyright 2017 Vinzenz Feenstra, Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@kuya-joe
kuya-joe / deploy.sh
Last active July 22, 2023 23:57 — forked from BenSampo/deploy.sh
Laravel deploy script
# Change to the project directory
cd $FORGE_SITE_PATH
# Turn on maintenance mode
php artisan down || true
# Pull the latest changes from the git repository
# git reset --hard
# git clean -df
git pull origin $FORGE_SITE_BRANCH
@kuya-joe
kuya-joe / gist:7c78be94ec68a493f195fba02ed10e88
Created June 29, 2023 02:07
7 best practices to start using in your next commit

https://sourcelevel.io/blog/7-git-best-practices-to-start-using-in-your-next-commit

  1. Rebase your working branch frequently. It’s crucial always to keep your branch rebase with the latest code. Writing new code upon obsolete one is useless. It is as meaningless as fixing a bug that may already be fixed. You should rebase your working branch frequently to prevent bugs, rework, and the tedious job of resolving conflicts with the upstream branch. You can do it easily by running these commands:
git checkout 
@kuya-joe
kuya-joe / getdiff-and-apply-steps.markdown
Last active June 28, 2023 14:45
pseudo script to manually get difference between files itself and then apply those changes to fix conflicts

Using git you can just diff between branches. So you have the diff between the destination branch from your feature branch and you just want to "put your code changes" together Accordin to https://stackoverflow.com/a/22390257/1345527

To create the patch : git diff dev > master.patch To apply it : patch < master.patch

In theory, if diff and git diff are similar you could do the following to put your code changes on top of a target branch (usually when doing a MR to master).

  1. git checkout master (or other target branch)
  2. git diff (your-source-branch ) &gt; final-destination.patch
@kuya-joe
kuya-joe / fetch-function.php
Created June 21, 2023 12:34
example fetch function using php
<?php
/* from StackOverflow: https://stackoverflow.com/a/52662522/1345527 */
function fetch(string $method, string $url, string $body, array $headers = []) {
$context = stream_context_create([
"http" => [
// http://docs.php.net/manual/en/context.http.php
"method" => $method,
"header" => implode("\r\n", $headers),
"content" => $body,
"ignore_errors" => true,
@kuya-joe
kuya-joe / very_useful_aliases.sh
Created June 13, 2023 23:25
very useful command aliases
alias v='fd --type f --hidden --exclude .git | fzf-tmux -p --reverse | xargs nvim'
@kuya-joe
kuya-joe / AppServiceProvider.php
Created June 6, 2023 09:00 — forked from simonhamp/AppServiceProvider.php
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@kuya-joe
kuya-joe / ArrayPaginator.php
Created June 6, 2023 07:48 — forked from kkiernan/ArrayPaginator.php
A reusable helper class for pagination of array items in Laravel.
<?php
namespace App\Http\Utilities;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
class ArrayPaginator
{