Skip to content

Instantly share code, notes, and snippets.

View richardfeliciano's full-sized avatar

Richard Feliciano richardfeliciano

  • 4fleet
  • Sao Paulo - Brasil
  • 08:20 (UTC -03:00)
View GitHub Profile
@richardfeliciano
richardfeliciano / Eloquent Filters
Created June 5, 2020 13:37
How to make an eloquent filter (lazy mode on)
public function getCategoryBySlug($slug, $request)
{
return Category::with([
'parent',
'products' => function ($table) use ($request) {
$params = collect($request);
$orderBy = isset($params['order_by']) ? $params['order_by'] : 'created_at';
$order = isset($params['order']) ? $params['order'] : 'DESC';
$results = isset($params['results']) ? $params['results'] : 30;
$filters = $params->except(['order', 'results', 'order_by']);
@richardfeliciano
richardfeliciano / laradock generate host to nginx
Last active February 3, 2020 16:06
Generate a laradock/nginx configuration for a single project it helps you to configure your projects a little bit faster.
#!/usr/bin/env php
<?php
/**
* --host: host example.dev
* --path: project-name/
* --company: company name if you want to use SSL
* --country: country name if you want to use SSL
**/
$args = getopt(null, ["host:", "path:", "company:", "country:"]);
$file = file_get_contents('./nginx/sites/app.conf.example');
{
"type": "dark",
"colors": {
"focusBorder": "#292d36",
"foreground": "#3d424d",
"widget.shadow": "#00010a",
"selection.background": "#161f2afd",
"textBlockQuote.background": "#0d1016",
"textLink.foreground": "#e6b450",
"textLink.activeForeground": "#e6b450",
Array
(
[GRU] => Array
(
[2018/03/10] => Array
(
[0] => Array
(
[0] => Array
(
return [
'1033edge.com',
'11mail.com',
'123.com',
'123box.net',
'123india.com',
'123mail.cl',
'123qwe.co.uk',
'150ml.com',
'15meg4free.com',
// PDO Connection to MySQL
$conn = new PDO('mysql:host=localhost;dbname=yourdbname', 'username', 'password');
// PDO Connection to PostgreSQL
$conn = new PDO('pgsql:host=localhost;dbname=yourdbname', 'username', 'password');
// A quick Select Query with For Loop
foreach ($conn->query("SELECT * FROM profile") as $row)
echo $row['fullname'];
@richardfeliciano
richardfeliciano / BackUpMysql
Last active February 3, 2020 19:57
Backup ALL MySql
#!/bin/bash
#your db settings
USER="db_root"
PASS="db_pass"
PATH="/path/to/backup/folder"
HOST="mysql_host"
DATE=`date +%d%m%y%H%M`
#get databases list
databases=`mysql --host=$HOST --user=$USER --password=$PASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`