Skip to content

Instantly share code, notes, and snippets.

@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
@santoshachari
santoshachari / Laravel PHP7 LEMP AWS.md
Last active February 20, 2024 10:00
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
@greenspace10
greenspace10 / AppServiceProvider.php
Created June 14, 2021 17:16
Laravel, Livewire, Alpine JS Toast Notifications
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Component::macro('notify', function ($message, $title = '', $type = 'success') {
$this->dispatchBrowserEvent('notify', ['message' => $message, 'title' => $title, 'type' => $type]);
});
@h-collector
h-collector / Foo.php
Last active November 1, 2023 16:32
Standalone Laravel Queue + Redis example
<?php
namespace Jobs;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Redis\Database as Redis;
class Foo extends Job
{
use InteractsWithQueue;
<?php
Builder::macro('deferredPaginate', function ($perPage = null, $columns = ['*'], $pageName = 'page', $page = null) {
$model = $this->newModelInstance();
$key = $model->getKeyName();
$table = $model->getTable();
$paginator = $this->clone()
// We don't need them for this query, they'll remain
// on the query that actually gets the records.
@rosswintle
rosswintle / AppNavigationMenu.php
Last active September 13, 2023 21:45
Laravel Jetstream Livewire Navigation Menu
<?php
/**
* This class extends the base NavigationClass provided by Jetstream.
* Note that the base class includes the navigation-menu.blade.php
*/
namespace App\Http\Livewire;
class AppNavigationMenu extends \Laravel\Jetstream\Http\Livewire\NavigationMenu
{
@steveosoule
steveosoule / track-javascript-errors-with-google-analytics.js
Created April 11, 2014 19:13
Track JavaScript Errors with Google Analytics
// FROM: http://davidwalsh.name/track-errors-google-analytics
// Track basic JavaScript errors
window.addEventListener('error', function(e) {
_gaq.push([
'_trackEvent',
'JavaScript Error',
e.message,
e.filename + ': ' + e.lineno,
true
@pxlrbt
pxlrbt / Readme.md
Last active September 30, 2022 20:20
Filament Geocoder

Usage

  • Install Geocoder Laravel: https://geocoder-php.org/docs/
  • Publish config php artisan vendor:publish (Look for Geocoder)
  • Setup your Google Geocoding API-Key in config/geocoder.php
@touhonoob
touhonoob / Ranking.php
Created June 13, 2012 09:39
Reddit Ranking Algorithms in PHP
<?php
/**
* Ranking Library
* contains alogrithms for story ranking
* Basically a PHP Implementation of reddits algorithms
*
* @author Lucas Nolte <lnolte@i.biz>
* @since 0.1
* @package Polska Wiadomosc
* @subpackage Libraries
@burnz
burnz / AnyLivewireComponent.php
Created April 22, 2021 06:54 — forked from binaryweavers/AnyLivewireComponent.php
Fluent toaster(alerts) for laravel/livewire using alpinejs and tailwindcss
public function showToasters(){
// default info toaster with timeout
$this->toaster('your message');
// makes it persistent
$this->toaster('your message')->persistent();
// warning toaster with timeout
$this->toaster('your message')->warning();