Skip to content

Instantly share code, notes, and snippets.

View raphox's full-sized avatar

Raphael Araújo raphox

View GitHub Profile
@raphox
raphox / controllers.achievements.py
Created November 15, 2013 18:22
Upload with Flask, Flask-WTF, WTForms and WTForms-Alchemy
import os
from app import app
from app.database import db_session
from app.models.achievement import Achievement
from app.forms.achievement import AchievementForm
from flask import Blueprint, render_template, abort, request, redirect, flash, url_for
from werkzeug import secure_filename
@raphox
raphox / vagrant.bat
Created April 29, 2014 11:35
Vagrant bat to up/halt/suspend for Windows
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
:: Se você tiver mais de um projeto com Vagrant
SET WORKSPACES=(^
"D:\Proteste\vagrant\"^
"D:\Raphael\vagrant\"^
)
IF "%1" == "" (
@raphox
raphox / routes.rb
Created May 15, 2014 20:53
routes format default
Rails.application.routes.draw do
...
namespace :api, defaults: {format: 'json'} do
namespace :v1 do
resources :products, only: [:index, :show]
match "/products" => "products#index", via: :options
end
end
@raphox
raphox / gist:2fc60479339dc7384d25
Created August 27, 2014 02:44
Execute native query #doctrine #symfony2
<?php
class AcmeController extends Controller
{
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$conn = $em->getConnection();
$conn->prepare('SET foreign_key_checks = 0')->execute();
// ...
}
@raphox
raphox / HotsiteListener.php
Last active November 7, 2019 16:01
Symfony script to create dynamic routes to hotsite or subdomains #php #subdomain #routes #dynamic
<?php
namespace Acme\HotsiteBundle\EventListener;
use Acme\HotsiteBundle\Controller\HotsiteSignedController;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\RedirectResponse;
<Shop>
<shopid>22105</shopid>
<name>EUROSPIN</name>
<street>Via Maldacea 58.0 </street>
<zipcode>00000</zipcode>
<city>ROMA</city>
<citycode></citycode>
<phone></phone>
<fax></fax>
<email></email>
@raphox
raphox / NfeController.php
Created December 20, 2016 12:19
Symfony 2 + NFePHP + Form + Controller
<?php
namespace Labone\Bundle\OrderBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
-- FIX sequencial
SELECT setval('familias_id_seq', max(id)) FROM familias
@raphox
raphox / Factory.php
Created April 13, 2017 14:01
Laravel provider to inlude javascript files on blade view
<?php
namespace App\Providers;
use Illuminate\View\Factory as FactoryContract;
class Factory extends FactoryContract
{
/**
* The extension to engine bindings.
[
{
"name": "Machado de Assis",
"books": [
{ "name": "Dom Casmurro", "publicatedAt": "2016-05-18T16:00:00Z" },
{ "name": "Contos", "publicatedAt": "2016-05-18T16:00:00Z" },
{ "name": "Helena", "publicatedAt": "2016-05-18T16:00:00Z" }
]
},
{