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 / 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')
"controller_mappings"
{
"version" "3"
"title" "GW2 Total Control by CoryOp v1"
"description" "#SettingsController_AutosaveDescription"
"creator" "76561198141443709"
"controller_type" "controller_steamcontroller_gordon"
"group"
{
"id" "0"
@patrickmaciel
patrickmaciel / .sql
Created April 26, 2019 20:50
export query result to csv + using dynamic name variables
SET @outpath = "/var/lib/mysql-files/";
SET @outfile = (SELECT date_format(now(), '%Y%m%d%H%m%S'));
SET @outextension = "_products.csv";
SET @csvfinal = ' FIELDS TERMINATED BY \',\' ENCLOSED BY \'"\' LINES TERMINATED BY \'\n\'';
SELECT CONCAT("your query here INTO OUTFILE ",@outpath,@outfile,@outextension,@csvfinal)
INTO @SQL; PREPARE stmt FROM @SQL;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;