domingo, 27 de maio de 2012

Fatal error: Call to undefined function curl_init()

Veja bem,

estava eu trabalhando com o yii (framework php) e tomei este erro
Fatal error: Call to undefined function curl_init()
Obs: Estou usando o XAMPP

Como resolve?

Acesse o arquivo php.ini
xxxxxx\php\php.ini
descomente
;extension=php_curl.dll
tira o ponto e vírcula
extension=php_curl.dll
Reinicia a máquina.

Voilà!

Ask me nicely and maybe I'll tell you... - Game Of thrones

And what's your story, bastard?

 

Problemas com acentuação (a revanche)


Veja bem,

O conteúdo que vem do banco do MySql estava vindo perfeito. Entretanto os labels, das páginas PHP estava aparecendo com problemas.

Exemplo:

Arboriza��o *

Como resolvi:

$label_arborizacao = utf8_encode("Arborização");
echo $label_arborizacao;

Resultado

Arborização.

Voilà!

Problemas com acentuação


Veja bem,

depois de importar centenas de milhares de linhas para o meu banco MySql, descobri que a acentuação estava toda equivocada.

ã aparecia como este sinal |-

Como resolvi:

Estou usando o MySql.exe. Uso o prompt do DOS. A performance é melhor.

MySql.exe -u root -p
<b>&gt; charset Latin1</b>
source C:\xxx\xxx\xxx\arquivo.sql

Voilà!

Apesar do collation das tabelas estar
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

ao mudar o charset antes da importação, os acentos da nosso idioma não são afetados.

And that's it.

sábado, 26 de maio de 2012

Substituição de caracteres de arquivos via DOS


Achei uma bat para fazer replace de caracteres em arquivos muito grandes
O nome da bat é : BatchSubstitute.bat

Estou testando com um arquivo de 50 MB.


Visite : http://www.dostips.com/?t=batch.findandreplace 

Description:This batch allows string substitution in a text file. It parses each line of a text file for a particular string and replaces it with another string.
I.e. To replace all occurrences of "Yellow Submarine" in "color.txt" with "uboot" and put the output on the screen run:
BatchSubstitute.bat "Yellow Submarine" uboot color.txt
Or
type color.txt|BatchSubstitute.bat "Yellow Submarine" uboot

Optionally pipe the output into a new file, i.e.
BatchSubstitute.bat "Yellow Submarine" uboot color.txt>newfile.txt
Or
type color.txt|BatchSubstitute.bat "Yellow Submarine" uboot>newfile.txt
Note: Due to the nature of the FOR command and string substitution, the following known restrictions apply:
  • Lines starting with "]" character will end up empty
  • OldStr must not start with "*"
  • Lines must not contain any of the following characters within a quoted string: "&<>|^"


echo off
REM -- Prepare the Command Processor --
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION

::BatchSubstitude - parses a File line by line and replaces a substring"
::syntax: BatchSubstitude.bat OldStr NewStr File
::          OldStr [in] - string to be replaced
::          NewStr [in] - string to replace with
::          File   [in] - file to be parsed
:$changed 20100115
:$source http://www.dostips.com
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
    set "line=%%B"
    if defined line (
        call set "line=echo.%%line:%~1=%~2%%"
        for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
    ) ELSE echo.
)

Viagem aos limites do universo

Veja bem,
um video excelente!

sexta-feira, 25 de maio de 2012

MySQL - Executar arquivos gigantes

Veja bem,
Estou subindo a base de CEP dos correios para o meu MYSQL.
Se você quer fazer tem um SQL de 50 MB ou mais, que é o meu caso,
utilize o MySQL.exe e faça isso via DOS.

No prompt digite

source [caminho para o arquivo]

pronto!

Assim é bem mais prático e não trava a sua máquina (fica apenas um pouco mais lenta que o normal até acabar a execução de todo o SQL).