Skip to content

Instantly share code, notes, and snippets.

Liam Hammett imliam

Block or report user

Report or block imliam

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
@imliam
imliam / web.php
Created Mar 8, 2017
Laravel 5 - Routing an unknown number of sub-levels
View web.php
<?php
/*
|--------------------------------------------------------------------------
| Routing an unknown number of sub-levels
|--------------------------------------------------------------------------
|
| This is how you can route an unknown number of sub-levels and pass them
| to the same controller. For example, the following URLs will go through
| the same route:
|
@imliam
imliam / trigger.sql
Created Mar 8, 2017
MySQL - At least one column must have a value
View trigger.sql
/*
|--------------------------------------------------------------------------
| At least one column must have a value
|--------------------------------------------------------------------------
|
| This is a simple pair of triggers for MySQL databases that will disallow
| a row to be inserted into a table unless at least one of two predefined
| columns has a value set.
|
*/
@imliam
imliam / pagination.blade.php
Last active Nov 26, 2018
Laravel 5 - Bootstrap 4 Pagination
View pagination.blade.php
<?php
/*
|--------------------------------------------------------------------------
| Laravel 5, Bootstrap 4 Pagination
|--------------------------------------------------------------------------
|
| A partial view to handle pagination for collections in Laravel's query
| builder or Eloquent ORM, styled with Bootstrap 4.
|
| The pagination displays like the following, where * denotes the current
@imliam
imliam / query_string.php
Last active Nov 9, 2019
Laravel 5 - URL Query String Helper
View query_string.php
<?php
/*
|--------------------------------------------------------------------------
| Laravel 5 - URL Query String Helper
|--------------------------------------------------------------------------
|
| A helper function to take a URL string then quickly and easily add query
| string parameters to it, or change existing ones.
|
| url_queries(['order' => 'desc', 'page' => 2],
@imliam
imliam / font_awesome_icon_helper.php
Created Mar 10, 2017
PHP - Font Awesome Icon Helper
View font_awesome_icon_helper.php
<?php
/*
|--------------------------------------------------------------------------
| PHP - Font Awesome Icon Helper
|--------------------------------------------------------------------------
|
| A helper function to build the HTML for a Font Awesome icon with all of
| the recommended accessibility tags.
|
*/
@imliam
imliam / popover-dom-content.html
Last active Feb 13, 2020
Bootstrap 4 - Load Popover Content From DOM
View popover-dom-content.html
<div id="unique-id" style="display:none;">
<div class="popover-heading">This is a heading</div>
<div class="popover-body">This is HTML content that will be loaded inside a </div>
</div>
<span tabindex="0" role="button" data-toggle="popover" data-placement="bottom" data-popover-content="#unique-id">
Click me to load a popover
</span>
@imliam
imliam / popover-close-when-losing-focus.js
Created Mar 17, 2017
Bootstrap 4 - Close Popover When Losing Focus
View popover-close-when-losing-focus.js
/*
|--------------------------------------------------------------------------
| Bootstrap 4 - Close Popover When Losing Focus
|--------------------------------------------------------------------------
|
| A JavaScript snippet that closes a Bootstrap 4 popover when clicking off
| of it, but unlike the default behaviour, allows it to stay open when
| clicking within the popover itself.
*/
@imliam
imliam / web.php
Created Mar 20, 2017
Laravel 5 - Route must start with @
View web.php
<?php
/*
|--------------------------------------------------------------------------
| Laravel 5 - Route must start with @
|--------------------------------------------------------------------------
|
| A quick snippet showing use of the Route::where(); method that lets you
| define a regex pattern for the route to match, such as the "@" symbol
| at the beginning to denote a user.
|
@imliam
imliam / .bash_aliases
Last active Oct 31, 2017
Commonly used bash aliases
View .bash_aliases
## Misc. Commands ##
alias h='cd ~'
alias c='clear'
alias ls='ls -alh'
alias pubkey="/bin/cat ~/.ssh/id_rsa.pub | pbcopy"
## A quick way to get out of the current directory ##
alias ..='cd ../'
alias ...='cd ../../'
alias ....='cd ../../../'
@imliam
imliam / nginx.conf
Created Mar 21, 2017
Nginx - Redirect www to non-www
View nginx.conf
server {
server_name www.yourdomain.com;
return 301 $scheme://yourdomain.com$request_uri;
}
You can’t perform that action at this time.