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 / 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
{
@kuya-joe
kuya-joe / import.md
Last active May 22, 2023 00:06 — forked from iamstoick/import.md
How to import database in MySQL in Docker?

This is a simple way of importing MySQL database in Docker.

  1. In you Dockerfile you must have a shared folder. Shared folder is a directory in your host machine that is mounted to Docker instance.

  2. Put the exported sql file in the shared folder.

  3. Login to your Docker instance via docker exec -it DOCKER_CONTAINER_ID bin/bash.

  4. Login to MySQL via mysql -u USERNAME -p. Use -P/--port to specify the port if your exposed port of your docker mysql service is different.

@kuya-joe
kuya-joe / .tmux.conf
Created April 11, 2023 07:02 — forked from tsl0922/.tmux.conf
vim style tmux config
# vim style tmux config
# use C-a, since it's on the home row and easier to hit than C-b
set-option -g prefix C-a
unbind-key C-a
bind-key C-a send-prefix
set -g base-index 1
# Easy config reload
bind-key R source-file ~/.tmux.conf \; display-message "tmux.conf reloaded."