Skip to content

Instantly share code, notes, and snippets.

View nwaweru's full-sized avatar
🤙
Available

Ndirangu Waweru nwaweru

🤙
Available
View GitHub Profile
@Laratipsofficial
Laratipsofficial / lateral join.md
Last active February 10, 2024 02:07
Implementing lateral join in Laravel

Implementing lateral join in Laravel

Making of joinLateral macro

use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Expression

Builder::macro('joinLateral', function ($query, $as, $type = 'inner') {
    [$query, $bindings] = $this->createSub($query);
@jakebathman
jakebathman / logslaravel.sh
Created August 19, 2018 00:06
Tail Laravel logs and filter out the stack traces
tail -f -n 450 storage/logs/laravel*.log \
| grep -i -E \
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
--color
@mlocati
mlocati / exceptions-tree.php
Created March 9, 2017 10:58
Throwable and Exceptions tree
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');
@marijn
marijn / README.markdown
Last active September 1, 2023 08:56
List of nationalities in YAML, CSV and TXT format

List of nationalities

It's time someone compiled a list of nationalities to use within a web application. This gist attempts to make a first move at that.

List of countries

I've also compiled a list of countries

<?php
/**
* Join a string with a natural language conjunction at the end.
*/
function natural_language_join(array $list, $conjunction = 'and') {
$last = array_pop($list);
if ($list) {
return implode(', ', $list) . ' ' . $conjunction . ' ' . $last;
}
return $last;
<?php
namespace Tests;
use Mail;
use Swift_Message;
use Swift_Events_EventListener;
trait MailTracking
{
/**
* Delivered emails.
@aurawindsurfing
aurawindsurfing / cloudSettings
Last active August 31, 2022 10:45
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-07-27T19:36:28.740Z","extensionVersion":"v3.4.1"}
@mtwalsh
mtwalsh / deploy.php
Last active October 20, 2021 22:17
Deployer recipe for Laravel projects.
<?php
namespace Deployer;
require 'recipe/common.php';
// Project name
set('application', 'enovate.co.uk');
// Project repository
set('repository', 'git@githosting.com:enovatedesign/project.git');
@JacobBennett
JacobBennett / blog.md
Last active March 26, 2021 02:47
API Token Authentication in Laravel 5.2 & 5.3

I recently had the need to write a small url shortening application. I am aware that this problem has been solved quite a few times before, but what is being a developer if not reinventing the wheel just for the heck of it? Custom CMS anyone?

Knowing that this was going to be a tiny RESTful API and also knowing that Laravel 5.2 had API rate limiting built in, I was eager to give it a try. Taylor Otwell being Taylor Otwell shipped 5.2 with the rate limiting defaults set up out of the box and I had my application building out short url's in a matter of minutes. The problem for me came when I wanted to start associating those short urls with a user.

Typically my applications have a UI and authentication is done through a simple login page. Obviously for a RESTful API, having a login page isn't ideal. Instead, my hope was to have users append an api_token to the end of their query string and use that to auth