Skip to content

Instantly share code, notes, and snippets.

View blakethepatton's full-sized avatar

Blake Patton blakethepatton

View GitHub Profile
@blakethepatton
blakethepatton / shadowing.php
Created September 6, 2016 01:01
Laravel Shadowing
// The simplest implementation to express the concept.
// Routes
Route::get( 'admin/user/switch/start/{id}', 'UserController@user_switch_start' );
Route::get( 'admin/user/switch/stop', 'UserController@user_switch_stop' );
// Inside User Controller
public function user_switch_start( $new_user )
<?PHP
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "emailtest@YOURDOMAIN";
$to = "YOUREMAILADDRESS";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
@blakethepatton
blakethepatton / migrate.php
Created February 2, 2017 20:32
Laravel migrator
<?PHP
$migrationRepository = app('migration.repository');
if (!$migrationRepository->repositoryExists())
{
$migrationRepository->createRepository();
}
$migrator = app('migrator');
@blakethepatton
blakethepatton / upgrade-script.md
Last active April 13, 2023 13:18
Upgrading ubuntu 15.04 to 15.10 and to 16.04
sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
sudo apt-get update && sudo apt-get dist-upgrade

mkdir wily && cd wily
wget http://old-releases.ubuntu.com/ubuntu/dists/wily-updates/main/dist-upgrader-all/current/wily.tar.gz
tar -xzf wily.tar.gz

sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' Ubuntu.info
sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' Ubuntu.mirrors
@blakethepatton
blakethepatton / spwriter.php
Last active May 8, 2019 18:26
Stored Procedure Writer v2.0
<pre>
<?PHP
$sqlserver = '';
$username = '';
$password = '';
$database = "";
/*
* writer.php version 2.0 - Major update
* Takes stored procedure name, the input variables and an array of output variables
* outputs php code necessary for getting results using php pdo
@blakethepatton
blakethepatton / disable.script
Created April 6, 2018 04:29
Fully disable Windows 10 Upgrade Assistant
# So I got fed up with windows 10 and its constant supply of updates. And I've had them disabled, but
# now they've got this handy little tool called Windows 10 Upgrade assistant. This just goes ahead and
# starts updating your system without notifying you and without your permission. Some great code there!
# So of course you can uninstall it, but at a random time interval later, it reinstalls the updater.
# Total BS if you ask me. I think I've figured out how to disable it more long term though and this is
# how. Since I know I'm not the only one who's going to want to do this.
1. Uninstall Windows 10 Upgrade assistant (from the control panel)
2. Create a folder on the C:/ Drive called "Windows10Upgrade" and go in and modify it's permissions
a) Make sure that you've revoked all permissions to everyone including yourself.
@blakethepatton
blakethepatton / gist:2da1720f33dfd494042813603d9a854f
Last active July 1, 2018 07:09
Installing Ubuntu 18.04 on Razer Blade 2016 (GTX970m)
Just some notes I'm keeping for myself about my install that got things working - in case
I screw things up at some later point.
Get a drive with ubuntu installer image on it.
Run the check the drive utility to make sure things are all good before installing (You dealt
with a bad drive before, everythin looked good, but things didn't work perfect)
Install ubuntu via the second option, "install ubuntu" not through the try it first.
It crashed at the reboot part of the process
@blakethepatton
blakethepatton / readme.md
Last active July 5, 2018 20:00
A simple script that downloads and installs phpMyAdmin in its root location

I really don't recommend using this in production environments. There are potential issues with this script that could cause some damage.

@blakethepatton
blakethepatton / Description.md
Last active November 7, 2023 09:37
Getting Mailhog running on a dev server (nginx, letsencrypt, ssl, ubuntu)

Get it running as a service

wget https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64

mv MailHog_linux_amd64 mailhog

chmod +x mailhog

sudo vi /etc/systemd/system/mailhog.service

<?php
$q = (isset($_REQUEST['q'])) ? $_REQUEST['q'] : '';
$records = dns_get_record("{$q}.domainname.tld", DNS_TXT);
$return = [];
if($records===false)exit( "Nope. ") ;
foreach($records as $record){
$arr = explode(':', $record['txt'], 2);
if(preg_match("/:/", $record['txt'])==true && is_numeric($arr[0])){
$return[$arr[0]] = $arr[1];
} else {