Skip to content

Instantly share code, notes, and snippets.

View felipyamorim's full-sized avatar

Felipy Amorim felipyamorim

View GitHub Profile
find . -type f -name '*.csv' -exec \
sed -E -i.bak ":a; s/(\[|,)\s*'([^']*)'\s*(,|\])/\1\2\3/g; ta" {} +
find . -type f -name '*.csv' -exec \
sed -E -i '' ":a; s/(\[|,)\s*'([^']*)'\s*(,|\])/\1\2\3/g; ta" {} +
find . -type f -name '*.csv' -exec sed -E -i .bak "s/'([0-9A-Za-z]+)'/\1/g" {} +
@felipyamorim
felipyamorim / download-file.js
Created May 19, 2021 21:05 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@felipyamorim
felipyamorim / CategoryTree.vue
Created May 5, 2021 22:27 — forked from plong0/CategoryTree.vue
Demo of using single-select Radio Group with Vuetify Treeview
<template>
<v-card>
<v-card-text>
{{ category }}
<radio-tree :items="categories" value-key="id" v-model="category" ref="radioTree"></radio-tree>
</v-card-text>
<v-card-actions>
<v-btn @click.stop="nuke()" color="warning">Nuke</v-btn>
</v-card-actions>
</v-card>
@felipyamorim
felipyamorim / Dockerfile
Created April 16, 2021 19:37 — forked from xenogew/Dockerfile
Example of PHP 7.2.x Docker image install with MS SQL Server extensions
FROM php:7.2.11-fpm
WORKDIR /application
ENV ACCEPT_EULA=Y
# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive
# Install selected extensions and other stuff
RUN apt-get update \
version: '3'
services:
webserver1:
image: php:7.2-apache
network_mode: bridge
expose:
- 80
- 443
environment:
@felipyamorim
felipyamorim / Confirm.vue
Created March 18, 2021 19:52 — forked from eolant/Confirm.vue
Vuetify Confirm Dialog component that can be used locally or globally
<template>
<v-dialog v-model="dialog" :max-width="options.width" :style="{ zIndex: options.zIndex }" @keydown.esc="cancel">
<v-card>
<v-toolbar dark :color="options.color" dense flat>
<v-toolbar-title class="white--text">{{ title }}</v-toolbar-title>
</v-toolbar>
<v-card-text v-show="!!message" class="pa-4">{{ message }}</v-card-text>
<v-card-actions class="pt-0">
<v-spacer></v-spacer>
<v-btn color="primary darken-1" text @click.native="agree">Yes</v-btn>
@felipyamorim
felipyamorim / GenerateSchema.php
Last active March 4, 2021 05:33
Avoid doctrine diff to create foreign keys and indexes for tables described in schema_filter
<?php
namespace App\Doctrine;
use Doctrine\DBAL\Schema\Index;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
use Symfony\Component\DependencyInjection\ContainerInterface;
@felipyamorim
felipyamorim / TopFunction.php
Created September 17, 2020 19:19
Doctrine Custom Top function
<?php
/**
* Created by PhpStorm.
* User: felipy.amorim
* Date: 10/03/2017
* Time: 13:05
*/
namespace App\DQL;
@felipyamorim
felipyamorim / Condition.php
Created June 27, 2020 01:18 — forked from vudaltsov/Condition.php
Conditional validator
<?php
declare(strict_types=1);
namespace App\Validator\Constraints;
use Symfony\Component\Validator\Constraints\Composite;
/**
* @Annotation()
@felipyamorim
felipyamorim / CreatedBySubscriber.php
Created June 1, 2020 16:28
CreatedByTrait behavior tracks your records inserts and is able to set de user who created the record.
<?php
namespace App\EventSubscriber;
use App\Entity\User;
use App\Entity\Traits\CreatedByTrait;
use App\Entity\Traits\UpdatedByTrait;
use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;