Skip to content

Instantly share code, notes, and snippets.

View tiagodavi's full-sized avatar
🏠
Working from home

Tiago Davi tiagodavi

🏠
Working from home
View GitHub Profile
@tiagodavi
tiagodavi / login_spec.rb
Last active August 29, 2015 14:17
Capybara passes with rack_test, but don't passes with selenium. Wtf?
require 'rails_helper'
feature "Login" do
background do
#Factory Girl
@user = create(:user)
end
scenario "With correct credentials" do
<?php
// app/classes/myrules.php
class MyRules
{
// note this is a static method
public static function _validation_unique($val, $options)
{
list($table, $field, $id) = explode('.', $options);
$result = DB::select("LOWER (\"$field\")", 'id')
@tiagodavi
tiagodavi / estrutura.html
Created November 1, 2012 19:15
Estrutura HTML5
<!DOCTYPE HTML>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="estilo.css">
<title></title>
</head>
<body>
<header>
<!-- Topo aqui -->
@tiagodavi
tiagodavi / redirection.php
Created August 13, 2012 16:43
Exemplo de switch/case com números mágicos
<?php
#EXEMPLO 1 (PÉSSIMO)
class Cliente
{
var $tipo;
}
function redireciona(Cliente $cliente){
<?php
class Test_Soma extends TestCase
{
public function test_soma()
{
$soma = 2 + 2;
$this->assertEquals(4, $soma);
}
@tiagodavi
tiagodavi / phpunit.xml
Created May 8, 2012 01:41
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" stopOnFailure="false" bootstrap="../core/bootstrap_phpunit.php">
<php>
<server name="doc_root" value="../../"/>
<server name="app_path" value="fuel/app"/>
<server name="core_path" value="fuel/core"/>
<server name="package_path" value="fuel/packages"/>
</php>
<testsuites>
<?php
phpinfo();
@tiagodavi
tiagodavi / start-nginx.bat
Created May 1, 2012 23:06
start-nginx.bat
@ECHO OFF
c:\nginx\nginx.exe
c:\nginx\php5.4\php-cgi.exe -b 127.0.0.1:9000 -c c:\nginx\php5.4\php.ini
ping 127.0.0.1 -n 1>NUL
echo Starting nginx
echo .
echo .
echo .
ping 127.0.0.1 >NUL
EXIT
#remover o ; (caso exista) do início das linhas citadas.
#definir o path e liberar as extensões do MySQL e Curl.
; On windows:
extension_dir = "C:\nginx\php5.4\ext"
extension=php_curl.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
@tiagodavi
tiagodavi / nginx.conf
Created May 1, 2012 22:52
ngnix.conf
location / {
root html;
index index.html index.php index.htm;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;