Skip to content

Instantly share code, notes, and snippets.

View irineujunior's full-sized avatar
😎
You are not done when it works, you are done when it's right.

Irineu Martins Junior irineujunior

😎
You are not done when it works, you are done when it's right.
View GitHub Profile
@andreshg112
andreshg112 / OrderByField.php
Last active April 6, 2023 09:25
It can be used for queries like this in MySQL: `SELECT * FROM `plans` ORDER BY FIELD(`interval`, 'day', 'week', 'month', 'year');`
<?php
namespace App\Traits;
/**
* Traits that eases the use of ORDER BY FIELD with an eloquent model.
* https://github.com/laravel/ideas/issues/1066
*/
trait OrderByField
{
@puncoz
puncoz / critical-css-laravel-mix.js
Created September 18, 2018 04:52 — forked from bayareawebpro/critical-css-laravel-mix.js
Generate Critical CSS Paths with Laravel Mix
let mix = require('laravel-mix');
let httpRequest = require('request')
let criticalCSS = require('critical')
//Run your asset compilation commands...
//Then we will generate critical css...
mix.then(()=>{
console.log("Build Post-Processing...")
const criticalRoutes = [
@standaniels
standaniels / after.sh
Last active March 9, 2022 06:08
Create supervisor program for Laravel queue worker in Homestead
#!/bin/sh
# This script creates a supervisor program for the Laravel queue worker and writes
# the log to the storage folder of the project. It also starts the http server on
# port 9001 so you need to add this port forwarding to your Homestead.yaml file.
sudo sh -c 'echo "[inet_http_server]
port = 9001
username = homestead
password = secret
@zabaala
zabaala / BindDatabaseServiceProvider.php
Last active March 2, 2021 07:50
php artisan db:log <start> <stop>
<?php
namespace App\Commands\Database;
use Illuminate\Support\ServiceProvider;
class BindDatabaseServiceProvider extends ServiceProvider
{
public function boot()
{
@vielhuber
vielhuber / Model.php
Last active July 11, 2023 16:51
custom relationship in eloquent / eager loading #laravel
<?php
public function foos() {
$relation = $this->hasMany('App\Bar');
return $relation; // default behaviour
// modify the query builder
$relation->where('foo','bar');
return $relation;
@ZackStone
ZackStone / slack-invite-all-members-to-a-channel.js
Created April 14, 2017 13:48
Invite all team members to a Slack channel
/*
https://webapps.stackexchange.com/questions/100820/how-do-i-invite-all-team-members-to-a-new-slack-channel#answer-104062
Instructions: Just browse to the appropriate channel and paste
this script (below) into your Chrome/Firefox dev console and hit enter.
Then wait for the script to run until it completes.
It might take time as there is a limit to how many users may be invited at once.
The script will loop until all team members are invited.
*/
var foundAny=false;
function selectAllByLetter(remainingLetters) {
@rafaelpatro
rafaelpatro / magento-address-autocomplete.js
Last active October 14, 2019 13:36
Magento Address Auto Fill based on Postcode
/**
* Address Auto Fill based on Postcode
*
* Author:
* Rafael Patro <rafaelpatro@gmail.com>
*
* Intallation:
* Add a CMS Static Block applying the entire script below.
* Add a Widget to pages with address forms.
*
@hfalucas
hfalucas / [1] main.js
Last active June 22, 2024 10:52
[Vue.js] Authentication and Authorization
/**
* Think of this "main.js" file as your application bootstrap.
*/
import Vue from 'vue'
import Resource from 'vue-resource'
import VueRouter from 'vue-router'
import routes from './routes'
import middleware from './middleware'
@alfhen
alfhen / homestead_install_elastic_search.sh
Last active September 27, 2019 17:18
Install ElasticSearch on Laravel Homestead
# Login as root
sudo -s
# Update Aptitude
apt-get update
# Install Java
apt-get install openjdk-7-jre-headless -y
# Download and install Elasticsearch Public Signing Key
@solancer
solancer / mod_pagespeed .htaccess
Last active January 11, 2023 07:25
mod_pagespeed .htaccess configuration
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"