Blog Spot!


Laravel queue solution for shared hosting

laracasts

What I have done in a similar situation (I have shared cpanel hosting and no way to install supervisor) I used the cron to run laravel's scheduler every minute and inside I used this:

$schedule->command('queue:work --daemon')->everyMinute()->withoutOverlapping();

So whats happening is, the first time it runs, it will start the queue worker in daemon mode, then on every minute it will basically use the withoutOverlapping to only run it again if the previous one crashed/exited/no longer running. This essentially produces a supervisor like functionality. At worst case it will take a minute before the queue worker comes back up in case of a failure / memory limit hit, but in most cases the first thread will stay alive and work through the queue. This is a better way to accomplish queue:listen like functionality without supervisor.

The caveat is of course, you need to run queue:restart whenever you deploy new code so that the daemon worker will restart and get fresh app code.

Hope this helps.

Added on 03.Sep.2018
Tags: laravel lumen queue shared hosting.

Simple way to connect PHP PDO to mysql database

<?php

$host    = '127.0.0.1';
$db      = 'test';
$user    = 'test';
$pass    = 'qwerty';
$charset = 'utf8mb4';

$dns = "mysql:host={$host};dbname={$db};charset={$charset}";
$opt = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false
];

$pdo = new PDO($dns, $user, $pass, $opt);

Added on 08.Aug.2018
Tags: pdo php db database sql mysql

JavaScript Design Patterns

article

Design patterns are advanced object-oriented solutions to commonly occurring software problems. Patterns are about reusable designs and interactions of objects. Each pattern has a name and becomes part of a vocabulary when discussing complex design solutions.

The 23 Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural, and Behavioral (see below for a complete list).

In this tutorial we provide JavaScript examples for each of the GoF patterns. Mostly, they follow the structure and intent of the original pattern designs. These examples demonstrate the principles behind each pattern, but are not optimized for JavaScript.

Added on 07.Aug.2018
Tags: js design patterns vanillajs good practices

GRUB Rescue

grub rescue > ls
(hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos1)
grub rescue > ls (hd0,msdos1) # try to recognize which partition is this
grub rescue > ls (hd0,msdos2) # let's assume this is the linux partition
grub rescue > set root=(hd0,msdos2)
grub rescue > set prefix=(hd0,msdos2)/boot/grub # or wherever grub is installed
grub rescue > insmod normal # if this produced an error, reset root and prefix to something else ..
grub rescue > normal

For a permanent fix run the following after you successfully boot:

sudo update-grub
sudo grub-install /dev/sdX

... where /dev/sdX is your boot drive.

askubuntu

Added on 31.Jul.2018
Tags: grub rescue linux partition

Sync directories in Linux terminal

rsync is fast and easy:

rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude

You can use --exclude multiples times.

Also you can add -n for dry run to see what will be copied before performing real operation, and if everything is ok, remove -n from command line.

stackoverflow

Added on 25.Jul.2018
Tags: nix rsync terminal sync

Search


PHP Libraries


Carbon lib / docs
Idiorm lib / docs
Image Workshop lib / docs
lorenzos/Minixed lib / docs
Parsedown lib / docs
PHP Paginator lib / docs
PHP Redis lib / docs
QrCode lib / docs
Requests lib / docs
Slim lib / docs
Spyc lib / docs
TWIG lib / docs
Upload lib / docs
Validation lib / docs
Zebra Image lib / docs

JS Libraries


AJV lib / docs
BackboneJS lib / docs
Bootstrap Notify lib / docs
C3.js lib / docs
ChartJS lib / docs
FastMD5 lib / docs
HighlightJS lib / docs
jQuery-Storage lib / docs
JS-Cookie lib / docs
Leaflet JS lib / docs
LowDB lib / docs
Marked lib / docs
NeedlyJS lib / docs
ParcelJS lib / docs
RequireJS lib / docs
Swig lib / docs
Toastr lib / docs
Underscore lib / docs
ValidateJS lib / docs
top