Skip to content

Instantly share code, notes, and snippets.

View ifirmawan's full-sized avatar
🎯
Focusing

Iwan firmawan ifirmawan

🎯
Focusing
View GitHub Profile
@ifirmawan
ifirmawan / external-hdd-ubuntu.txt
Created June 26, 2024 05:06
Unable to mount NTFS external hard drive
sudo ntfsfix /dev/sdb1
@ifirmawan
ifirmawan / .htaccess-react-js
Created November 5, 2023 01:42
This file will help manage URL routing on your shared hosting platform
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
@ifirmawan
ifirmawan / index.html
Created October 18, 2023 12:57
Bootstrap 5 starter html
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Bootstrap CSS -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css"
rel="stylesheet"
@ifirmawan
ifirmawan / sips-image-compression.sh
Created April 13, 2023 14:02
Compress image size in Mac
sips -Z 1920 -s formatOptions 65 -s format jpeg * --out <source file>
@ifirmawan
ifirmawan / set_global_full_group.sql
Created December 26, 2022 09:02
Disable ONLY_FULL_GROUP_BY
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
@ifirmawan
ifirmawan / unbalanced_transportation_problem.py
Created December 16, 2022 01:50
Here is a Python function that solves an unbalanced transportation problem using the least cost method:
from typing import List, Tuple
def least_cost_unbalanced_transportation(supply: List[int], demand: List[int], cost: List[List[int]]) -> Tuple[List[List[int]], int]:
# Initialize the solution matrix with zeros
sol = [[0 for j in range(len(demand))] for i in range(len(supply))]
# Initialize the variables to store the row, column, and minimum cost
row = 0
col = 0
minval = float("inf")
@ifirmawan
ifirmawan / git-delete-all-branch.sh
Created January 9, 2022 03:27
Remove all unused branch except current, main or master
git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main" | xargs git branch -D
@ifirmawan
ifirmawan / AppServiceProvider.php
Created December 6, 2021 06:06
Laravel 8 install mix on shared hosting
<?php
namespace App\Providers;
use App\Support\Collection as SupportCollection;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@ifirmawan
ifirmawan / wordpress-sydney-posts.php
Created December 2, 2021 11:05
Customization Sydney theme posts template
<?php
/**
* @package Sydney
*/
?>
<?php do_action( 'sydney_before_loop_entry' ); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php // do_action( 'sydney_loop_post' ); ?>
<div class="row">
@ifirmawan
ifirmawan / ProductPage.jsx
Created September 20, 2021 01:40
Filtering with useEffect
import React, { useEffect, useState } from 'react';
import items from '../json/products.json'; // json file as data dummy for example.
const ProductPage = () => {
const [products, setProducts] = useState(items);
const [size, setSize] = useState(null);
const [keyword, setKeyword] = useState(null);
const [loading, setLoading] = useState(true); // Loading is true each page first load
const handleOnFiltering = (size, keyword) => {