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
@xthiago
xthiago / estados-brasileiros.php
Last active June 18, 2021 05:16
Array PHP com estados brasileiros
<?
$estados = array(
array("sigla" => "AC", "nome" => "Acre"),
array("sigla" => "AL", "nome" => "Alagoas"),
array("sigla" => "AM", "nome" => "Amazonas"),
array("sigla" => "AP", "nome" => "Amapá"),
array("sigla" => "BA", "nome" => "Bahia"),
array("sigla" => "CE", "nome" => "Ceará"),
array("sigla" => "DF", "nome" => "Distrito Federal"),
array("sigla" => "ES", "nome" => "Espírito Santo"),
<?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