Skip to content

Instantly share code, notes, and snippets.

View ericdowell's full-sized avatar

Eric Dowell ericdowell

View GitHub Profile
@ericdowell
ericdowell / addDecimals.ts
Last active November 16, 2021 06:12
Correct Floating Point Math
import { format } from 'util';
export const addDecimals = (...decimals: number[]): number => {
let total = 0;
for (const value of decimals) {
const fixedValue =
typeof value.toFixed === 'function' ? Number(value.toFixed(2)) : value;
const addition = (total * 100 + fixedValue * 100) / 100;
if (Number.isNaN(addition)) {
throw new Error(
@ericdowell
ericdowell / forge-redis
Last active November 24, 2019 18:52
Laravel Forge Enable Redis Extension
Last login: Sun Nov 24 17:39:58 2019
forge@solitary-thunder:~$ php -v
PHP 7.3.11-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 24 2019 18:23:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.11-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
forge@solitary-thunder:~/default$ pecl list
Installed packages, channel pecl.php.net:
@ericdowell
ericdowell / FreshCommand.php
Created December 13, 2017 20:01
Laravel Dusk - Migrate Database based on .env.dusk file
<?php
namespace Laravel\Dusk\Console\Migrations;
use Laravel\Dusk\Console\DuskCommand as Command;
class FreshCommand extends Command
{
/**
* The console command name.
@ericdowell
ericdowell / vagrant-bash-output.bash
Created July 10, 2017 19:40
Laravel Homestead 5.4.0 Vagrant Up Output
~/Projects/homestead-example   master  vagrant up
Bringing machine 'homestead' up with 'virtualbox' provider...
==> homestead: Importing base box 'laravel/homestead'...
==> homestead: Matching MAC address for NAT networking...
==> homestead: Checking if box 'laravel/homestead' is up to date...
==> homestead: Setting the name of the VM: homestead
==> homestead: Fixed port collision for 80 => 8000. Now on port 2201.
==> homestead: Fixed port collision for 443 => 44300. Now on port 2202.
==> homestead: Fixed port collision for 3306 => 33060. Now on port 2203.
==> homestead: Fixed port collision for 5432 => 54320. Now on port 2204.
<?xml version="1.0" encoding="utf-8"?>
<project title="API Documentation" version="v2.8.5">
<partials/>
<file path="helpers/request.php" generated-path="helpers.request.html" hash="f8369b5220c40f4237e587af2b61760e" package="Default">
<docblock line="0">
<description>Created by PhpStorm.</description>
<long-description>User: dowelec
Date: 12/15/15
Time: 5:28 PM</long-description>
<tag name="package" line="0" description="Default"/>