diogomelo's blog

user warning: Table 'diogomelo.ds_settings' doesn't exist query: ds_get_settings /* Anonymous : ds_get_settings */ SELECT module, type, build_mode, settings, fields FROM ds_settings WHERE module = 'nd' AND type = 'blog' AND build_mode = 'teaser' in /mnt/sdf/proj/diogomelo/sites/all/modules/ds/ds.module on line 980.

grep -- Binary file (standard input) matches

When grep finds your match on a binary input, instead of printing the matches, it will just tell you that there was a hit.

If you want to see the matches, uses the option "-a". Example:

cat file | grep -a

Error with libicu 48 while compiling Tesseract for training

If while compiling tesseract 3.03 for training you find this output error

libtool: link: g++ -std=c++11 -o .libs/mftraining mftraining.o mergenf.o ./.libs/libtesseract_training.a ./.libs/libtesseract_tessopt.a ../api/.libs/libtesseract.so -llept -lpthread
/bin/bash ../libtool --tag=CXX --mode=link g++ -std=c++11 -o set_unicharset_properties set_unicharset_properties.o libtesseract_training.la libtesseract_tessopt.la -licui18n -licuuc ../api/libtesseract.la -llept -lpthread

Easy way to record desktop using ffmpeg

Just use the following command to record the desktop with audio to a mkv (or whatever format you want) file

ffmpeg -f alsa -ac 2 -i pulse -f x11grab -s 1280x1024 -r 30 -i :0.0 ~/out.mkv

PHP, Session and a Bottleneck

I learned something new, recently. Sessions in PHP are blocking. At Amuzi, I try to keep the user from have to go to another URI, this way the music won't stop. So I end up using a lot of Ajax. Some of this are concurrent. For instance, when a user click to add a music, one request is fired to fulfill that request and another one to search for similar music. The problem is that, on server side, the two requests won't run simultaneously if they use sessions.

How to log every query on MySQL

To know every sql being executed on your server, you have to 1) set debug on, 2) specify the output and 3) know how to look a it. Here are the commands that address this three issues. You must run then as superuser on your mysql:

SET GLOBAL general_log = 'ON';
SET GLOBAL log_output = 'TABLE';
select * from mysql.general_log;

How to Connect to Oracle Database With PHP Zend Framework

Start by installing Oracle Instant Client basic and devel/sdk provided by oracle from this link http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.

On Fedora you will have to apply the following commands:

"couldn't load plugin" message on Chrome, Linux

A lot of people is getting this error today. Probably some bad update. They are noticing it mainly on youtube. Anyway, in linux it is very easy to fix. Just delete your PepperFlash directory.

rm -rf .config/google-chrome/PepperFlash/

Please, comment if this doesn't work or if there is a better solution, or more information regarding what is happening.

JavaScript - Compatibility with Internet Explorer

There is a few javascript functions that are very useful but are not implemented on IE: Function.bind, String.trim, Array.indexOf, Array.lastIndexOf and a few more...

I found an script on stackoverflow (lost the link) that tests it those functions exists and, if it doesn't, implement them. Also, as I use console.log for debugging, IE kept claiming console.log doesn't exists, so I added that too (dummy version, just to stop it from complaining).

Here is the script: ie-compatibility.js

Convert Virtualbox/VMware/QEmu Linux Machine to an Amazon EC2 Instance

Just a reminder. There is a great post about converting a Virtualbox/QEmu/VMware linux machine to an Amazon EC2 instance. http://www.ioncannon.net/system-administration/1246/converting-from-virt...

Using a printer shared by another CUPS

To register a printer shared by another CUPS, you can simply use the command:

lpadmin -p printer -E -v ipp://server/printers/printer

I got this from this page http://www.cups.org/documentation.php/doc-1.4/sharing.html

Syndicate content