Skip to content

Instantly share code, notes, and snippets.

View cwhite92's full-sized avatar
👋

Chris White cwhite92

👋
View GitHub Profile
@cwhite92
cwhite92 / fqcn_from_path.php
Last active April 19, 2024 18:25
Get the FQCN from a PHP file specified by file path
<?php
public static function fqcnFromPath(string $path): string
{
$namespace = $class = $buffer = '';
$handle = fopen($path, 'r');
while (!feof($handle)) {
$buffer .= fread($handle, 512);
@cwhite92
cwhite92 / AdvancedSharing.php
Created July 24, 2019 19:43
AdvancedSharing trait
trait AdvancedSharing
{
/**
* Modifies a model query to ensure that the authed user is allowed to see this entity.
*
* @param Builder $query
* @param VisibleTo $visibleTo
* @return Builder
*/
public function scopeVisibleTo(Builder $query, VisibleTo $visibleTo): Builder
<?php
use Sparky\PhpSdk\Sparky;
$folder = Sparky::folder($folderHash);
echo $folder->asset('avatar.jpg')->flipVertical()->maxWidth(500)->url();
@cwhite92
cwhite92 / gist:e284694399991ca823a0aaa53fd6408c
Last active June 23, 2017 21:39
.ebextensions cronjob.config
files:
"/etc/cron.d/scheduler":
mode: "000644"
owner: root
group: root
content: |
#* * * * * root docker run --rm -v /var/app/current:/var/www/html 132274109557.dkr.ecr.eu-west-1.amazonaws.com/yourproject/artisan:latest schedule:run >> /dev/null 2>&1
container_commands:
001-uncomment-cron:
docker build -t yourproject/artisan .
docker tag yourproject/artisan:latest 132274109557.dkr.ecr.eu-west-1.amazonaws.com/yourproject/artisan:latest
docker push 132274109557.dkr.ecr.eu-west-1.amazonaws.com/yourproject/artisan:latest
@cwhite92
cwhite92 / Dockerfile
Created April 28, 2017 21:52
PHP 7.1 Artisan Dockerfile
FROM php:7.1-cli
RUN apt-get update && apt-get install -y libmcrypt-dev
RUN docker-php-ext-install pdo_mysql mbstring mcrypt
RUN usermod -u 1000 www-data
WORKDIR /var/www/html
ENTRYPOINT ["php", "artisan"]
Table create query:
CREATE TABLE `records` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`number` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1000002 DEFAULT CHARSET=utf8;
Filled the table with one million rows, with `number` being a random integer between 0 and 100.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+rMuk1BHGQiZm8wFdguFhWkvg7MOe5GdaRA1V7GxX13x/CsLaP6ekXxhTqxJzVBg/TLhLVLseqUN32vpA/r44jlYBwV4KGvIW4TFQeDf6a6S8rty33+J3NpPhBBEQMXmFlAHG4UmFZbiaSgK/PFyxmrHcffiryeyqOTyWyNzKafVyCy40lWgLv+WbxeKvquOSqvVdoUpyC1rhGJYEpwNPp5Ed22/naHOVte7B4ByNtK/m3Ghg1NEpMRv8Rwo53PpkxmpDP/7WJYatl/pQ2UxJDbzuJNEZFcOm1RQ4rvRGEXO/mo+fXu+sEpEWWvufyQf293NOSni4GILErmnqClveuoyiVxgkduI2W1vbjdIuva0LYnfgLSGYXw6Dy32aJ78Rd+RSdjcEAIXEotJ9e9ItXd08H81JgthI7CD3nyOKmLva/aUAGE0ZwpOohR7ib4Xe12EDtryMq2JIYxWcOsZ9MA2Eevew0IqeS+y8bRJshWc36OFenDI6CMkguMngWghytcYt8zMvkKQ1Mkf2hLCk8aQ28fhEZ5mecNnuNfspdVtnqwsPJXXC6j1zFin0CfmC1mfR8dR2wg3HphQWeUV7TArEHLf6TMz0nKY7hgu3feICamMHJKZrNqkEf164OA6ypo2smnxA1vO6c9g31n/VwiibbczffmHlQjHO2Lrmvw== cwhite@ESPC-01485
<?php
namespace App\Polylines;
class PathCleaner
{
/**
* Cleans up the polyline's path by trying to remove any incorrect path points.
*
* @param $path