Skip to content

Instantly share code, notes, and snippets.

View jhonoryza's full-sized avatar
🏠
Working from home

fajar sp jhonoryza

🏠
Working from home
View GitHub Profile
@jhonoryza
jhonoryza / docker-snippets.md
Last active April 7, 2021 04:37
Docker Snippets

this will create a new laravel project in /var/www/html

docker run --rm -i -v "$(pwd):/var/www/" -u "$(id -u):$(id -g)" composer composer create-project --prefer-dist laravel/laravel /var/www/src

make php file as executable for vscode from docker php

path=$(printf '%s\n' "${PWD##*/}")
command="docker exec ${path}_php_1 php "$@""
echo "Running php on docker ${path}_php_1"
upstream django_app {
server 127.0.0.1:8000;
}
server {
listen 80;
server_name demo.gatos.io;
access_log /var/log/nginx/app.log;
@jhonoryza
jhonoryza / zsh-terminal.md
Created August 27, 2021 14:42
show branch and color in zsh terminal

add these to show branch and color in zsh terminal

function parse_git_branch() {
    git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
setopt PROMPT_SUBST
NEWLINE=$'\n'
export PROMPT="%F{grey}%n%f %F{cyan}%~%f %F{green}$(parse_git_branch)%f ${NEWLINE} %F{normal}$%f "
@jhonoryza
jhonoryza / simple-bootstrap.md
Created August 31, 2021 15:58
simple-bootstrap.md

style.css

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap');

body{
    font-family: 'Quicksand', sans-serif;
}

.bg-dark{
 background: #7952b3!important;

Livewire won't refresh child components as they are isolated from each other, so the way to get them to refresh is a bit of a hack, using keys. What happens is by changing the key, Livewire thinks it's actually a new dom element and so it deletes the old child component and launches a new one with the new key, and as such the new, refreshed, data.

Using the key like I suggested key('vehicle' . $vehicle->id) originally won't work for forcing the child component to refresh. That is why you will see people using keys like you suggested that has time() in it.

I would consider this a bad idea, purely because time changes every time the parent component re-renders. As such all child components that have that in the key will be deleted and replaced, and any dirty state they may have contained will be gone.

What I prefer to do now, is actually create a property on the parent component like public $uniqueKey; and populate that in your mount method $this->uniqueKey = uniqid();.

Then on your child components, set th

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name example.co.id;

    return 301 https://example.co.id$request_uri;
}

server {
@jhonoryza
jhonoryza / mysql-8-setup.md
Last active June 12, 2023 20:41
setup mysql 8

setup mysql

sudo mysql_secure_installation

enable remote access

  • edit /etc/mysql/mysql.conf.d/mysqld.cnf
  • set bind-address
bind-address = 0.0.0.0

add this to bashrc file

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\u@\h \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]$ "
"terminal.integrated.profiles.windows": {
        "cmder": {
            "path": "C:\\Laragon\\bin\\cmder\\cmder.bat",
            "args": [
                "."
            ]
        }
    },
"terminal.integrated.defaultProfile.windows": "cmder"
  • Delete largon/data/mysql-8
  • cd to laragon/bin/mysql8.0.0.x/bin folder via cmder (important for step 3)
  • run 'mysqld --initialize --console' (remember the password)
  • run 'start mysqld'
  • run 'mysql -u root -p'
  • put in the password from 3.
  • You are now in mysql shell and can remove the password again: "ALTER USER 'root'@'localhost' IDENTIFIED BY '';"
  • run 'exit' and ctrl + c the spawned tab from step 4.