Skip to content

Instantly share code, notes, and snippets.

View felipyamorim's full-sized avatar

Felipy Amorim felipyamorim

View GitHub Profile
@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 \
@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 / 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()
$sql=" SELECT distinct
cs.cd_pac,
duracao,
DATEDIFF(DAY, cs.dt_dispensa_sol, (select min(cs1.dt_dispensa_sol) from capa_solicitacao cs1, rl_capa_prep cp1
where cs1.cd_dis <> '972' AND cs1.tp_solic = 'F' AND cs1.profilax_sol = 'F' AND cs1.cd_dis = cp1.cd_dis AND cs1.num_sol = cp1.num_sol
AND cs.cd_pac = cs1.cd_pac and cp1.co_seq_retorno_prep is not null and cp1.co_paciente_prep = tpp.co_paciente_prep and
cs1.dt_dispensa_sol > cs.dt_dispensa_sol) ) as diferenca,
cd_uf,
rz_dis
<?php
class Aluno
{
protected $nome;
protected $media;
protected $n1, $n2, $n3, $n4;
public function __construct($dados)
{
@felipyamorim
felipyamorim / docker-destroy-all.sh
Created April 17, 2017 01:44 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@felipyamorim
felipyamorim / bootstrap.php
Created February 14, 2017 13:20 — forked from tournasdim/bootstrap.php
A simple example how to handle errors in Silex
use \Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
$app->error(function (\Exception $e) use ($app) {
if ($e instanceof NotFoundHttpException) {
return $app->json(array('error' => 'Page Not Found'), 404);
}
$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500;
return $app->json(array('error' => $e->getMessage()), $code);
});
@felipyamorim
felipyamorim / array-validation-error-mapping.php
Created December 5, 2016 17:19 — forked from webmozart/array-validation-error-mapping.php
A little experiment: Validating (potentially multi-leveled) arrays with the Symfony2 Validator component and returning the errors in the same data structure as the validated array by using the Symfony2 PropertyAccess component.
<?php
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\Validator\Constraints\All;
use Symfony\Component\Validator\Constraints\Choice;
use Symfony\Component\Validator\Constraints\Collection;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Optional;
use Symfony\Component\Validator\Constraints\Required;