Skip to content

Instantly share code, notes, and snippets.

View xthiago's full-sized avatar

Thiago Rodrigues (xthiago) xthiago

View GitHub Profile
@xthiago
xthiago / gist:5927503
Created July 4, 2013 13:00
Get the module, action and parameters from a url in Symfony 1.4
<?php
/* Author: http://snippets.symfony-project.org/snippet/61 (comment #12 by 'Anonymous') */
$referer = $this->request->getReferer();
if (strlen($referer) > 0)
{
$pathInfo = $request->getPathInfoArray();
$referer = str_replace(
array('http://', 'https://'),
'',
@xthiago
xthiago / data-sqlserver.php
Created August 13, 2013 19:53
Transformar Datetime do SQL SERVER em DateTime do PHP
<?php
/**
* Esse pequeno trecho demonstra como converter um Datetime oriundo do SQL Server em
* um objeto do tipo DateTime do PHP.
*/
// exemplo de data retornada pelo SQL Server
$dataSqlServer = 'Jul 30 2013 02:44:27:000PM';
// formato reconhecida pelo PHP
<?php
function searchCriteria($criteria){
$cleanCritera = array();
foreach($criteria as $key => $value){
if( isset( $this->_class->fieldNames[$key] ) && !empty($value) ){
$cleanCritera[$key] = $value;
}
}
if(empty($cleanCritera)){
@xthiago
xthiago / nginx.conf
Created December 2, 2013 04:39 — forked from LouWii/nginx.conf
# Things needed to be adapted :
# server_name my-domain.com
#
# root /home/www
# The root of the Symfony "web" folder (with app.php and app_dev.php in it).
#
# fastcgi_pass unix:/var/run/php5-fpm.sock
# This sock can be elsewhere (/var/run/php5-fpm/php5-fpm.sock for example...)
#
# There are other things needed to be changed/fixed.
@xthiago
xthiago / README.md
Created December 8, 2013 13:35 — forked from oodavid/README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@xthiago
xthiago / Vagrantfile
Last active January 2, 2016 23:19
Vagrant: LAMP (Ubuntu 12.04 + Apache2 + MySQL 5.5 + PHP 5.5) + nodejs + wkhtmltopdf
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu1204-64"
config.vm.provision :shell, :path => "bootstrap.sh"
config.vm.network :forwarded_port, host: 2015, guest: 80
@xthiago
xthiago / bumblebee.conf
Last active January 2, 2016 23:29
Bumblebee configuration for Nvidia Geforce GT740M in Linux Mint 16 Cinnamon AMD64
# /etc/bumblebee/bumblebee.conf
# Configuration file for Bumblebee. Values should **not** be put between quotes
## Server options. Any change made in this section will need a server restart
# to take effect.
[bumblebeed]
# The secondary Xorg server DISPLAY number
VirtualDisplay=:8
# Should the unused Xorg server be kept running? Set this to true if waiting
Vagrant::Config.run do |config|
config.vm.customize do |vm|
vm.name = "PHP dev"
vm.memory_size = 512
end
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "ubuntu32"
# Assign this VM to a host only network IP, allowing you to access it
@xthiago
xthiago / README.md
Created April 24, 2016 02:09 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \