Skip to content

Instantly share code, notes, and snippets.

View patrickmaciel's full-sized avatar
🙏
Jesus is coming!

Patrick Maciel patrickmaciel

🙏
Jesus is coming!
View GitHub Profile
@patrickmaciel
patrickmaciel / .php_cs
Created March 4, 2020 02:11
PHPCS Fixer .php_cs Laravel 5+
<?php
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'@PSR1' => true,
'@PSR2' => true,
'yoda_style' => false,
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
@patrickmaciel
patrickmaciel / upgrade-php7.sh
Created February 28, 2020 14:29 — forked from skynet/upgrade-php7.sh
Upgrade PHP to 7.3 on Amazon Linux (specifically for Elastic Beanstalk but should work elsewhere)
#!/usr/bin/env bash
# Upgrade an Amazon Linux EC2 to PHP 7.3
#
# Last tested w/ PHP 7.2 AWS Linux version 2.8.5
#
# Must be ran as sudo:
# sudo bash upgrade-php7.sh
#
# Can be added to ./.ebextensions/20_php.config like so:
# container_commands:
@patrickmaciel
patrickmaciel / settings.json
Created January 11, 2020 17:09
Visual Studio Code settings for Javascript React Eslint + Laravel PHP CS
{
"breadcrumbs.enabled": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontWeight": "400",
"editor.formatOnType": false,
"editor.lineHeight": 22,
@patrickmaciel
patrickmaciel / reduced.sh
Created November 22, 2019 21:31
Reduce a large sql file ignoring insert's of specific tables
```sh
#!/bin/bash
sed '/INSERT INTO `rev_reviews`/d' dump.sql |
sed '/INSERT INTO `rev_log`/d' |
sed '/INSERT INTO `p_logconsulta`/d' |
sed '/INSERT INTO `p_logconsulta_20190726`/d' |
sed '/INSERT INTO `rev_log_products`/d' |
sed '/INSERT INTO `rev_log_tasks`/d' |
sed '/INSERT INTO `rev_log_products_client`/d' |
@patrickmaciel
patrickmaciel / index.js
Created November 21, 2019 18:42
Notification badge with submenu/notification list
return (
<Container>
<Badge onClick={handleToggleVisible} hasUnread={hasUnread}>
<MdNotifications color="#7159c1" size={20} />
</Badge>
<NotificationList visible={visible}>
<Scroll>
{notifications.map(notification => (
<Notification key={notification._id} unread={!notification.read}>
@patrickmaciel
patrickmaciel / .eslintrc.js
Created October 25, 2019 01:45
ESLINT - allow htmlFor to work with next elements not only nested
{
"jsx-a11y/label-has-associated-control": [ 2, {
"required": {
"some": [ "nesting", "id" ]
}
}]
}
@patrickmaciel
patrickmaciel / index.php
Last active October 22, 2019 13:52
Google Maps URL to check if place or address exists
<?php
// example: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=YOUR_PLACE_OR_ADDRESS_HERE,YOUR_CITY_HERE%2C+TO%2C+Brasil&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key=YOUR_KEY_HERE
function cleanString($string) {
$string = str_replace('&','e', $string);
$string = str_replace("'",'', $string);
return $string;
}
function geocode($place, $city){
@patrickmaciel
patrickmaciel / keybindings.json
Created July 3, 2019 01:24
my vscode shortcuts
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus",
},
{
"key": "ctrl+tab",
"command": "workbench.action.terminal.focusNext",
@patrickmaciel
patrickmaciel / settings.json
Created July 3, 2019 01:23
my vscode settings
{
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": [
"-l",
"-i"
],
"workbench.editor.enablePreview": false,
"emmet.includeLanguages": {
"blade": "html",
"javascript": "javascriptreact"
@patrickmaciel
patrickmaciel / Model.php
Created June 26, 2019 16:51
Query Builder with join group and count raw
<?php
$stores = DB::table('stores as s')
->leftJoin('products as p', 'p.store_id', '=', 's.id')
->leftJoin('coupons as c', 'c.product_id', '=', 'p.id')
->leftJoin('coupon_user as cp', function($join) {
$join->on('cp.coupon_id', '=', 'c.id')
->on('cp.used', '=', DB::raw(1));
})
->leftJoin('coupons as c2', 'c2.product_id', '=', 'p.id')