Skip to content

Instantly share code, notes, and snippets.

View donypurnama's full-sized avatar

Dony P donypurnama

View GitHub Profile
@donypurnama
donypurnama / clean_code.md
Created April 22, 2023 12:38 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@donypurnama
donypurnama / scan_dir.php
Created March 28, 2023 15:05 — forked from joeydenbraven/scan_dir.php
Scan dir sorted on modified date
function scan_dir($dir) {
$ignored = array('.', '..', '.svn', '.htaccess'); // -- ignore these file names
$files = array(); //----------------------------------- create an empty files array to play with
foreach (scandir($dir) as $file) {
if ($file[0] === '.') continue; //----------------- ignores all files starting with '.'
if (in_array($file, $ignored)) continue; //-------- ignores all files given in $ignored
$files[$file] = filemtime($dir . '/' . $file); //-- add to files list
}
arsort($files); //------------------------------------- sort file values (creation timestamps)
$files = array_keys($files); //------------------------ get all files after sorting
<?
# MIT license, do whatever you want with it
#
# This is my invoice.php page which I use to make invoices that customers want,
# with their address on it and which are easily printable. I love Stripe but
# their invoices and receipts were too wild for my customers on Remote OK
#
require_once(__DIR__.'/../vendor/autoload.php');
@donypurnama
donypurnama / gist:58eff489cdb862c65f35fcc4eb55defd
Created November 22, 2020 14:34 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>