This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Pagination helper written for laravel, available for any project. | |
* | |
* A couple examples: | |
* | |
* [1] $current_page = 1; $total_pages = 1; | |
* <no output, no pagination needed> | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Examples of input (assumes $homepage = 'http://site.com'): | |
* | |
* Input: url('') | |
* Return: http://site.com/ | |
* | |
* Input: url('home') | |
* Return: http://site.com/home |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function human_fsize ($size, $unit = '') | |
{ | |
if (( ! $unit && $size >= 1 << 40) || $unit == 'TB') { | |
return number_format($size / (1 << 40), 2) . ' TB'; | |
} | |
if (( ! $unit && $size >= 1 << 30) || $unit == 'GB') { | |
return number_format($size / (1 << 30), 2) . ' GB'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function slug ($string, $delimiter = '-') { | |
$string = trim($string); | |
$string = preg_replace('#[^a-z0-9 ]#i', '', $string); | |
$string = preg_replace('#\s+#', $delimiter, $string); | |
return $string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/* Install notes: | |
Copy this script onto your web server. I'll assume the location is /opt/tools/add_vhost.php | |
Give it the right privileges: | |
# chmod +x /opt/tools/add_vhost.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Works for: | |
* | |
* isset_or($_GET['test'], false) | |
* and | |
* isset_or($_GET['test'], 'other true value', false) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = 'This is my data that contains SOMETHING I DON\'T WANT in it.'; | |
preg_match('#^(?:(?!SOMETHING).)*$#', $data, $results); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Recursively sets DOM tree unique ids | |
* on each child element of the given jQuery selector. | |
* | |
* E.g. Given elem = $('<div> <p> <strong></strong><strong></strong> </p> <p></p> </div>') | |
* | |
* setTreeIds(elem) will result in: | |
* | |
* <div tid="0"> | |
* <p tid="00"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (! function_exists('get_slug')) { | |
/** | |
* Returns the requested slug part from the REQUEST_URI. | |
* | |
* E.g.: | |
* get_slug(1) where the URI is /app/123/edit will be equal to "app" | |
* get_slug(2) where the URI is /app/123/edit will be equal to "app/123" | |
* get_slug() where the URI is /app/123/edit will be equal to "app/123/edit" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- A SematicUI Dropdown VueJS Component --> | |
<template> | |
<div :class="classes"> | |
<div class="text" v-if="showTitle"> | |
<img :src="selected.avatar" v-if="hasAvatar && selected"> | |
<span v-text="title"></span> | |
</div> | |
<i class="icon" :class="{ dropdown: ! loading, loading }"></i> |
OlderNewer