Skip to content

Instantly share code, notes, and snippets.

@imliam
imliam / web.php
Created March 8, 2017 16:01
Laravel 5 - Routing an unknown number of sub-levels
<?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 March 8, 2017 16:08
MySQL - At least one column must have a value
/*
|--------------------------------------------------------------------------
| 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 November 26, 2018 15:23
Laravel 5 - Bootstrap 4 Pagination
<?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 November 9, 2019 15:52
Laravel 5 - URL Query String Helper
<?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 March 10, 2017 16:06
PHP - Font Awesome Icon Helper
<?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 May 16, 2022 06:19
Bootstrap 4 - Load Popover Content From DOM
<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 March 17, 2017 16:42
Bootstrap 4 - Close Popover When Losing Focus
/*
|--------------------------------------------------------------------------
| 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 March 20, 2017 13:17
Laravel 5 - Route must start with @
<?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 October 31, 2017 11:14
Commonly used 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 March 21, 2017 09:44
Nginx - Redirect www to non-www
server {
server_name www.yourdomain.com;
return 301 $scheme://yourdomain.com$request_uri;
}