Skip to content

Instantly share code, notes, and snippets.

James Doyle james2doyle

Block or report user

Report or block james2doyle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
james2doyle / vue.sublime-project
Last active Nov 8, 2019
A Sublime project file for Vue projects
View vue.sublime-project
"folders": [
"file_exclude_patterns": [
"folder_exclude_patterns": [
james2doyle / url-basic-auth
Created Nov 7, 2019
Using the browser URL to do basic auth
View url-basic-auth
View testing.json
james2doyle / load-factories.php
Last active Oct 11, 2019
Load model factories from a different folder in Laravel. Useful for tests that use vendor factories
View load-factories.php
// load factories from a different folder - useful for legacy vendor packages
$this->app->singleton(\Illuminate\Database\Eloquent\Factory::class, function ($app) {
$faker = $app->make(\Faker\Generator::class);
return \Illuminate\Database\Eloquent\Factory::construct($faker, base_path('tests/database/factories'));
james2doyle / delete-duplicate-jobs.sql
Created Oct 7, 2019
An SQL statement for Laravel database queue that removes duplicate jobs
View delete-duplicate-jobs.sql
DELETE `t1` FROM `jobs` `t1`
INNER JOIN `jobs` `t2`
WHERE `t1`.`id` < `t2`.`id`
AND `t1`.`payload` = `t2`.`payload`
james2doyle / zapier-webhook-form.html
Last active Sep 27, 2019
An example of using Zapier webhooks to handle file uploads from HTML forms
View zapier-webhook-form.html
<form action="" method="post" enctype="multipart/form-data">
<label for="name">Name:</label>
<input type="text" name="name" id="name">
<label for="email">Email:</label>
<input type="email" name="email" id="email">
<label for="attachment">Attachment:</label>
<input type="file" name="attachment" id="attachment">
<input type="submit" name="submit" value="Submit">
james2doyle /
Created Sep 24, 2019
This is a trick to load a .ENV file into the session and then evaluate a template file, replacing the variables in it
# read the .env file into the current env
source <(sed -E -n 's/[^#]+/export &/ p' .env)
# we need to escape the $ as ${DOLLAR} in the template,
# so now we can replace it correctly
sudo cat stub.conf.template | DOLLAR='$' envsubst > "${NEW_TEMPLATE_NAME}.conf"
james2doyle / wordpress.sublime-project
Last active Sep 27, 2019
A Sublime project file for Wordpress themes/sites. Assumes LSPs are being used as well as a "twentyseventeen" theme
View wordpress.sublime-project
"folders": [
"path": ".",
"folder_exclude_patterns": [
"wp-content/themes/twentynineteen", // make sure you dont ignore your own theme
james2doyle / wp-config.valet.multisite.php
Created Aug 30, 2019
A wp-config for using WordPress multisite under Laravel Valet. We use FQDN and not subdomains
View wp-config.valet.multisite.php
* Use Laravel Valet for WordPress Multisite
* Directory: ~/Sites/my-blog (contains wordpress setup)
* Assumption:
* - your valet TLD is `.localhost`
* - `my-blog.localhost` already loads the main WordPress site
* Commands:
james2doyle / repair-serialized-string.php
Last active Aug 12, 2019
An example of repairing a serialized PHP string. See:
View repair-serialized-string.php
// @see
namespace Corcel\Model\Meta;
PostMeta::where('meta_key', '_wp_attachment_metadata')->chunk(100, function ($collection) {
foreach ($collection as $meta) {
// recalculate the length of the elements in the serialized array
$fixed_data = preg_replace_callback('!s:(\d+):"(.*?)";!', function($match) {
You can’t perform that action at this time.