Skip to content

Instantly share code, notes, and snippets.

View andrewwoods's full-sized avatar

Andrew Woods andrewwoods

View GitHub Profile
@andrewwoods
andrewwoods / longest-word.md
Last active July 6, 2024 02:57
The longest word that can be typed on the top row of a QWERTY keyboard

The Longest Word

Someone mentioned recently that "typewriter was the longest word that can be typed on the top row of a qwerty keyboard". I thought that was interesting. I was curious to know what other words were in the running. So I thought would write some code to find out.

The List of Words

First, I need a list of all the words in the English language. I didn't have to look very far. Every Linux and Mac system has a list available. On my 2023 16-inch Macbook Pro, it lives at /usr/share/dict/words. My mac is set to US English.

@andrewwoods
andrewwoods / rg-php-inlcudes.sh
Created May 10, 2023 17:46
RipGrep all PHP requires/includes on command line
# rg --type-list will show all the file types with their associated file extensions.
# Use the --type-add option once for each additional type you want
# to be seen as a PHP file.
rg -e '^require(_once)?\b' -e '^include(_once)?\b' --type-add 'php:*.inc' --type php
@andrewwoods
andrewwoods / binary-search.php
Created May 11, 2021 22:34
Binary Search in PHP using recursion
#!/usr/bin/php
<?php
/*
* Binary Search Function - uses recursion
*
*/
function binarySearch(array $search, int $find): bool
{
$length = count($search);
@andrewwoods
andrewwoods / new-account-setup.bash
Created January 16, 2020 17:57
Bash function to setup new user account files
#
# Whenever you get a new computer, you need to create some files and
# directories to get things configured. No need to load this in your .bashrc
# file. Just source this when you need it. Call it like this:
#
# $ source new-account-setup.bash
# $ cd ~ && new_account_setup
#
function new_account_setup {
@andrewwoods
andrewwoods / docker-compose.yml
Created July 2, 2019 02:20
Laravel Docker Configuration
# building app and required component for running the app
version: '3'
services:
database:
build: docker/mysql
ports:
- "3306:3306"
environment:
- MYSQL_USER=laravel
@andrewwoods
andrewwoods / wp-install.bash
Created October 10, 2018 03:49
WordPress Install Bash Script
#!/bin/bash
#
# Client website setup script
#
echo "Commencing WordPress trunk Setup"
DB_NAME="name_of_database"
DB_USER="database_username"
DB_PASS="database_password"
@andrewwoods
andrewwoods / add-date-interval.php
Last active October 19, 2017 01:06
Add Date Intervals with PHP
<!-- GATHER INFORMATION FROM FORM -->
<!-- Get date due, the Friday before the week for which the taxi fare applies -->
<?php
/*
* Create date for testing (due date Friday, 10-13-17)
*/
$monthDue = 10; // $_POST['monthdue'];
$dayDue = 13; // $_POST['daydue'];
$yearDue = 2017; // $_POST['yeardue'];
@andrewwoods
andrewwoods / functions.php
Last active October 17, 2017 05:32
WordPress Theme Directory Structure
<?php
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* FUNCTIONS *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
require_once 'admin/menus.php';
@andrewwoods
andrewwoods / README.md
Last active July 10, 2017 22:32
30 Hour days

30 Hour Days

I want to change the world, but they won't give the source code :)

People try hard to accomplish things on their to-do list, but they often feel like they don't have enough time. To anyone who has been on Twitter long enough, you'll eventually come across a tweet similar to the following:

ZOMG! I need more time! How can I stretch out the number of hours in a day to 30 hours!

The desired number of hours in the tweets usually differs, but the sentiment remains the same. Let's see how we can do that!

@andrewwoods
andrewwoods / composer-install.txt
Created March 8, 2017 23:15
Composer-Install
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"