segunda-feira, 28 de março de 2011

Função mail do PHP não funciona (mail() php function doesn't work )

aptitude install sendmail
(ou pear install mail...)

sábado, 26 de março de 2011

Livros gratuitos de TI online (Free IT books online)


http://safaribooksonline.com/Corporate/Index/
http://www.redbooks.ibm.com/
http://www.freecomputerbooks.com/
http://www.onlinecomputerbooks.com/
http://www.mcsedirectory.com/books.shtml
http://www.freetechbooks.com/
http://www.techbooksforfree.com/
http://www.gayanb.com/
http://www.freebookcentre.net/
http://books.google.com/

quinta-feira, 24 de março de 2011

NO_PUBKEY apt-get

gpg --keyserver pgpkeys.mit.edu --recv-key (chave)
gpg -a --export | apt-key add -

terça-feira, 22 de março de 2011

PHP + Oracle Client + Ubuntu 10


1. Baixe o oracle-instantclient11.2-sdk e o oracle-instantclient11.2-basic do site da oracle
2. mv oracle-instantclient* /opt
3. unzip oracle-instantclient11.2-sdk && unzip oracle-instantclient11.2-basic
4. cd instantclient/instantclient_
5. mv libclntsh.so. libclntsh.so && ln -s libclntsh.so libclntsh.so.
6. apt-get install php-pear php5-dev apache2.2-common libapache2-mod-php5 php5
7. echo "/opt/instantclient/instantclient" >> /etc/ld.so.conf && rm /etc/ld.so.cache && ldconfig
8. cd /opt && mkdir php5 && cd php5
9. apt-get source php5
10. cd php5
11. make clean && rm config.cache
12. ./configure --with-oci8=shared,instantclient,/opt/instantclient/instanclient
13. make
14. cp /opt/php5/php5/modules/oci8.so /usr/lib/php5/20060613+lfs/
15. echo "extension=oci8.so" >> /etc/php5/apache2/php.ini
16. echo "extension=oci8.so" >> /etc/php5/cli/php.ini
17. /etc/init.d/apache2 restart
18. Seja feliz!

segunda-feira, 21 de março de 2011

sexta-feira, 18 de março de 2011

Montar diretório no FSTAB usando SSHFS - SSH

No cliente:

1. Instale o sshfs:
apt-get install sshfs

2. Gere as chaves:
ssh-keygen -t rsa

3. Copie a chave pública pro servidor:
scp /home/<usuario>/.ssh/id_rsa.pub <usuario>@servidor:/home/<usuario>/

4. Adicionar, no /etc/fstab:
sshfs#<usuario>@<servidor>:/home/<usuario> /mnt fuse user,noauto,transform_symlinks 0 0

No servidor:

1. Copiar a chave pública do cliente pro authorized_keys:
cd /home/<usuario>/
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
cat id_rsa.pub >> .ssh/authorized_keys
chown -R <usuario>:<usuario> .ssh

2. Editar o /etc/ssh/sshd_config:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PS.: Reiniciar o sshd

Ps.: No cliente, basta dar um "sudo mount -a" para atualizar o fstab (e montar o diretório remoto em /mnt);

fuse: failed to open /dev/fuse: Permission denied

sudo usermod -a -G fuse
newgrp fuse

Instalando o SSHFS no RH5 - Red Hat Enterprise 5

SSHFS: serve para montar compartilhamentos remotos utilizando ssh;

1. Instale o fuse:
tar xvf fuse-2.7.4.tar.gz
cd fuse-2.7.4
./configure
make
make install
modprobe fuse

2. Automaticamente carregar o módulo:
touch /etc/sysconfig/modules/fuse.modules
echo "modprobe fuse" > /etc/sysconfig/modules/fuse.modules
chmod +x /etc/sysconfig/modules/fuse.modules

3. Instalar os rpms necessários:
rpm -ivh fuse-2.7.3-1.el5.rf.x86_64.rpm
rpm -ivh fuse-sshfs-1.9-1.el5.rf.x86_64.rpm

4. Testando
sshfs usuario@host:/caminho /ponto_de_montagem
Ex.: sshfs cleorbete@servidor1:/home/cleorbete/public_html /mnt
Obs.: Para desmontar, utilize "fusermount -u mountpoint"

Issaaaa! (me empolguei)

quinta-feira, 17 de março de 2011

JCaptcha em Grails - Exemplo


1. Utilizando o DOS ou Shell, vá pro diretório do seu projeto grails e execute o comando "grails install-plugin jcaptcha";
2. No Config.groovy, crie uma captcha:
//JCAPTCHA
import java.awt.Font
import java.awt.Color
import com.octo.captcha.service.multitype.GenericManageableCaptchaService
import com.octo.captcha.engine.GenericCaptchaEngine
import com.octo.captcha.image.gimpy.GimpyFactory
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage
import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator
import com.octo.captcha.component.image.backgroundgenerator.GradientBackgroundGenerator
import com.octo.captcha.component.image.color.SingleColorGenerator
import com.octo.captcha.component.image.textpaster.NonLinearTextPaster

import com.octo.captcha.service.sound.DefaultManageableSoundCaptchaService
jcaptchas {
image = new GenericManageableCaptchaService(
new GenericCaptchaEngine(
new GimpyFactory(
new RandomWordGenerator("abcdefghijklmnopqrstuvwxyz1234567890"),
new ComposedWordToImage(new RandomFontGenerator(
20, 30, [new Font("Arial", 0, 10)] as Font[]),
new GradientBackgroundGenerator(140, 35,
new SingleColorGenerator(Color.white),
new SingleColorGenerator(new Color(152, 245, 255))),
new NonLinearTextPaster(6, 6, new Color(108, 123, 139))
)
)
),
180,
180000)
}
3. No create.gsp (ou outra gsp), adicione o campo:
<tr class="prop">
<td valign="top" class="name">
<label> </label><jcaptcha:jpeg name="image"/>
</td>
<td valign="top" class="name">
<label>O que há na imagem?</label><br>
<g:textField name="captcha" value="" />
</td>
</tr>
4. No seu controller:
if (!jcaptchaService.validateResponse("image", session.id, params.captcha)) {
pessoaInstance.errors.reject("blank.captcha")
}
5. Crie uma linha no messages.properties com o chave "blank.captcha" e o texto desejado. Ex.:
blank.captcha=Informe corretamente o texto da imagem

Pronto!

quarta-feira, 16 de março de 2011

Problema de acentuação no Grails

No Config.groovy:

grails.views.default.codec = "html" // none, html, base64
grails.views.gsp.encoding = "ISO-8859-1"//"UTF-8"
grails.converters.encoding = "ISO-8859-1"//"UTF-8"
grails.enable.native2ascii = false

Obs.: Visite o www.grails.org para saber mais.

E é isso.