Skip to content

Instantly share code, notes, and snippets.

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

Lewis A. Sellers lasellers

🏠
Working from home
View GitHub Profile
@lasellers
lasellers / clean_code.md
Created October 9, 2020 21:01 — 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

class User {
private $name = null;
private $lastLoggedInAt = null;
private $lastLoggedOutAt = null;
function __construct($name) {
$this->name = $name;
}
function isLoggedIn() {
// nodejs minsort.js
function minimumSwaps(ratings) {
let swapCount = 0;
let partition = ratings.length - 1;
do {
// let sub = ratings.slice(0, partition);
// let minV = Math.min(...sub);
// let index = sub.findIndex(el => el === minV);
let minV = ratings[0];
let index = 0;
@lasellers
lasellers / sort3.cs
Created April 28, 2017 19:01
sort3 c# + linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
@lasellers
lasellers / sort2epromisefetch.html
Created April 23, 2017 14:57
Sort2 (e) promise+fetch
<!DOCTYPE html>
<html>
<body>
<p id="stdout"></p>
<script>
// @author lasellers@gmail.com Lewis A. Sellers
// sort2e with class literals (ie, object literals as classes) and es6 fetch
var Units = {
@lasellers
lasellers / sort2fvariant2.html
Created April 23, 2017 14:43
Sort2 (f) Variant 2 with different sort order
<!DOCTYPE html>
<html>
<body>
<p id="stdout"></p>
<script>
// @author lasellers@gmail.com Lewis A. Sellers
//sort2(f) as variant2 with different sort order
var unitsFilename = 'units.txt';
@lasellers
lasellers / JSONEndpointDocumentation.php
Last active April 22, 2017 20:06
Creates REST API Endpoint documentation returned as JSON indexing per class (PHP/Laravel 5)
<?php namespace Intrafoundation;
/**
* This class (for PHP/Laravel 5) scans the DOCBLOCK comments for a function and generates a JSON-able object
* that contains an index of public functions and various data that is for use by developers to consume a public API.
*
* In other words, if you have Endpoints in a class such as:
* /api
* /api/posts
* /api/post?id=5
@lasellers
lasellers / gist:6c0a0e54c04df7633f7c32ab25dd9298
Created April 20, 2017 22:10
Full Jenkins CI for Intrafoundation
<?xml version="1.0" encoding="UTF-8"?>
<project name="intrafoundation" default="full-build">
<!-- By default, we assume all tools to be on the $PATH -->
<property name="pdepend" value="pdepend"/>
<property name="phpcpd" value="phpcpd"/>
<property name="phpcs" value="phpcs"/>
<property name="phpdox" value="phpdox"/>
<property name="phploc" value="phploc"/>
<property name="phpmd" value="phpmd"/>
<property name="phpunit" value="phpunit"/>
@lasellers
lasellers / cloud_init.sh
Last active April 18, 2017 20:25
Script Template for AWS instance deployment, Laravel + NGINX
#!/usr/bin/env bash
USER=lewisasellers
GIT=https://lewisasellers@bitbucket.org/lewisasellers/intrafoundation.git
NAME="Lewis A. Sellers"
EMAIL=lasellers@gmail.com
WEBPARENT=/usr/share/nginx
WEBROOT=/usr/share/nginx/html
yum update -y
yum install -y php70 php70-fpm
@lasellers
lasellers / sort2promise.js
Last active April 23, 2017 14:46
sort2promise.js (sort2 js+html+promises)
<!DOCTYPE html>
<html>
<body>
<p id="stdout"></p>
<script>
// @author lasellers@gmail.com Lewis A. Sellers
// sort2d with class literals and promises
var Units = {