Skip to content

Instantly share code, notes, and snippets.

View shaneturner's full-sized avatar
🤔

Shane Turner shaneturner

🤔
View GitHub Profile
@shaneturner
shaneturner / PHP New Test Method.sublime-snippet
Created September 27, 2016 00:22
PHPUnit new test method converting descriptive text to snake_case method name
<snippet>
<content><![CDATA[
/**
* @test: ${1:This is what we are testing}
*
* @return void
*/
public function ${1/(\w)|(?: (\w))/(?1\l$1:)(?2_\l$2:)/g}()
{
\$this->assertTrue(true);
@shaneturner
shaneturner / web.php
Created October 8, 2016 07:58
Resourceful routing and controller example. With nested relationships.
Route::resource('foo', 'FooController');
// Specific methods for the relation between models
Route::resource('foo.bar', 'Foo\BarController'); // For accessing Bar related with Foo
Route::resource('foo.bar.bez', 'Foo\Bar\BezController'); // For accessing Bez related with Foo and Bar
Route::resource('foo.bar.bez.biz', 'Foo\Bar\Bez\BizController'); // For accessing Biz related with Foo, Bar and Bez
// General methods for each collection/resource
Route::resource('bar', 'BarController'); // For accessing bar
Route::resource('bez', 'BezController'); // For accessing bez
@shaneturner
shaneturner / Preferences.sublime-settings
Created October 18, 2016 03:39
To remove node_modules definitions from Sublime Text definitions popup.
{
"binary_file_patterns": [".svn/", ".git/", ".hg/", "CVS/", "node_modules/", "bower_components/"],
}
@shaneturner
shaneturner / BS Text.sublime-snippet
Created February 27, 2017 00:14
Bootstrap Text Field Snippet with Laravel Scoping
<snippet>
<content><![CDATA[
<div class="form-group">
<label for="${1:name}">${2}:</label>
<input type="text" class="form-control" id="${1}" name="${1}"/>
</div>
${0}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>bstext</tabTrigger>
@shaneturner
shaneturner / craft-cms-entries-by-category-group.twig
Created December 4, 2017 00:26
Craft CMS: Getting entries grouped by category in order of the category type drag & drop order.
{# Get the categories related to my "entrySection" entries in structure order #}
{% set entries = craft.entries.section('entrySection') %}
{% set relatedCats = craft.categories.relatedTo(entries) %}
{# Loop the categories #}
{% for category in relatedCats %}
{{ category.title }}
{# Get and loop through entries related to this cat #}
@shaneturner
shaneturner / set-permissions.sh
Created June 14, 2018 23:49
Set normal permissions on files and directories
#!/bin/bash
# Sets 644 for files and 755 to directories in current directory and sub directories
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
@shaneturner
shaneturner / rm_node_modules.sh
Created August 31, 2018 01:03
Remove node_modules from git repo
#!/bin/sh
git rm -r --cached node_modules
git commit -m 'Remove node_modules directory'
git push origin master
sudo -- sh -c 'apt update && apt upgrade -o Dpkg::Options::="--force-confold" --force-yes -y && apt autoremove -o Dpkg::Options::="--force-confold" --force-yes -y && apt autoclean -o Dpkg::Options::="--force-confold" --force-yes -y'
@shaneturner
shaneturner / site-backup
Last active November 9, 2023 21:25
Make website backup copy using WGET
wget -R _H -k -K -p --random-wait -e robots=off -U mozilla ***URL_HERE***