Skip to content

Instantly share code, notes, and snippets.

@imliam
imliam / take.php
Last active January 15, 2020 14:30
Run functions consecutively by piping through the result of one into the next.
<?php
if (! function_exists('take')) {
/**
* Run functions consecutively by piping through the result of one
* into the next.
*
* @param mixed $value A value
*
* @return object
*/
@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],
/**
* Register a new wildcard route that returns a view if it exists.
*
* @param string $path
* @param string $viewDirectory
* @param array $data
* @return \Illuminate\Routing\Route
*/
\Route::macro('viewDir', function ($path, $viewDirectory = null, $data = []) {
$pathWithSegments = trim($path, '/') . '/{page?}';
@imliam
imliam / cmd.lua
Created April 26, 2017 16:01
Command line argument parsing
command_strings = {
'php artisan make="hi mate" heh "I have a value"',
"php artisan make:auth",
[[I "am" 'the text' and "some more text with '" and "escaped \" text"]],
[[1 2 word 2 9 'more words' 1 "and more" "1 2 34"]],
[[omo "This is a string!" size=14 font="Comic Sans" break= hmm "thing and 'thing'" ]]
}
function command_parse(s)
local t={}
/*
|--------------------------------------------------------------------------
| Spacing
|--------------------------------------------------------------------------
|
| Utilities for controlling an element's padding and margin.
|
*/
$spacing-class: (
@imliam
imliam / hamburger-spin.scss
Created April 5, 2017 16:43
Bootstrap 4 - Animated Hamburger Icon
// Additional spin to the animation.
.hamburger {
display: inline-block;
width: 1.5em;
height: 1.5em;
padding-top: 0.3em;
padding-bottom: 0.3em;
vertical-align: middle;
@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 / sizing-helpers.scss
Created August 9, 2018 23:20
Utilities for controlling an element's padding and margin.
/*
|--------------------------------------------------------------------------
| Spacing
|--------------------------------------------------------------------------
|
| Utilities for controlling an element's padding and margin.
|
*/
$spacing-class: (
<?php
if (! function_exists('catch_exit')) {
/**
* Catch when a part of a script exits and execute a custom function at
* that point. Note that if exiting, the script does not continue.
* You can use this to, for example, flash a message and
* redirect the user instead of showing the default
* black text on white background "exit" view.
*
<?php
define('PIPE_VALUE', '__pipe-' . uniqid());
class Pipe implements ArrayAccess, Iterator, Serializable
{
public $value;
private $position = 0;
public function __construct($value)