Skip to content

Instantly share code, notes, and snippets.

View RobDWaller's full-sized avatar

Rob Waller RobDWaller

View GitHub Profile
@RobDWaller
RobDWaller / dan.php
Created February 12, 2018 18:08
An example of some awful PHP code I once reviewed. Saved for posterity.
<?php
function blogPreviews($numberOfPosts)
{
$blogPreviews = [];
$args = array(
'numberposts' => $numberOfPosts
);
@RobDWaller
RobDWaller / dave.php
Last active February 27, 2018 10:07
Dave's Code
<?php
function everyValueDivisibleByFive($array)
{
$newArray = [];
if (!count($array)) {
$result = 'error';
}
else {
@RobDWaller
RobDWaller / Vagrant
Created March 7, 2018 12:09
Scotch/Box 3.0 Vagrant Setup
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
# Remove Broken Old PHP Repo
sudo rm /etc/apt/sources.list.d/ondrej-php5-5_6-trusty.list
# Install PHP 7.1
sudo add-apt-repository ppa:ondrej/php
@RobDWaller
RobDWaller / Vagrant
Created March 21, 2018 15:04
Add Selenium and Chrome to Vagrant for testing
# If you need to add Selenium and Chrome to a Vagrant box for testing purposes the below deployment script should help.
# Currently works with Scotchbox, but should be fine on any Ubuntu Vagrant.
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
# Install Java and accept terms and conditions
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update -y
@RobDWaller
RobDWaller / Vagrant
Created April 6, 2018 14:13
With Yarn and Node, plus Selenium and Chrome
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<SCRIPT
# Remove Broken Old PHP Repo
sudo rm /etc/apt/sources.list.d/ondrej-php5-5_6-trusty.list
# Install PHP 7.1
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
@RobDWaller
RobDWaller / return-type.php
Created April 16, 2018 06:42
PHP return types will cast variable types if setup wrong
<?php
/**
* In PHP if you don't turn on strict types return types will interpret and
* cast variable types. For example the integer 123 if returned from a method
* with a return type of string will return '123'.
*
* Always turn on strict types in your application.
*
* declare(strict_types = 1);
@RobDWaller
RobDWaller / nginx.conf
Last active September 21, 2018 06:27
Nginx 301 SSL Redirect Server Block
server {
listen 80;
server_name www.website.com website.com;
if ($args) {
return 301 https://website.com$uri?$args;
}
return 301 https://website.com$uri;
@RobDWaller
RobDWaller / keygen.sh
Created July 16, 2018 09:39
SSH Key Generation
ssh-keygen -t rsa
@RobDWaller
RobDWaller / certbot.sh
Last active September 6, 2018 06:14
Command for Certbot Nginx
sudo certbot --authenticator webroot --installer nginx
# Cron Job
10 9,16 * * * sudo /bin/certbot renew --quiet && sudo systemctl restart nginx
@RobDWaller
RobDWaller / gitconfig.sh
Created July 17, 2018 14:44
Git Config File Permissions
git config core.fileMode false
git config core.fileMode false --global