Tuesday, December 04, 2012

change sender in email



easier way

export EMAIL=newsender@domain.com ; mutt -s "subject" destination@domain.com < /dev/null


Wednesday, November 28, 2012

trigger in sqlite


given a field called last_update datetime in the table log
a couple of triggers solved the need of keeping track of the last update time automatically inserted in the record:


create trigger log_ins after insert on log
begin
  update log set lu=datetime('now') where rowid=new.rowid;
end;

create trigger log_upd after update on log
begin
  update log set lu=datetime('now') where rowid=new.rowid;
end;

Wednesday, January 04, 2012

Installing Fedora 16: you have not created a bootloader stage1 device

I was getting this message when trying to install Fedora 16 as a Virtual
Machine in VMWare,

In the default installation I had an "autoinst.iso" as the primary
optical drive and the actual ISO as a secondary

Removing the primary (replacing it with the actual ISO) solved this issue

Sunday, December 11, 2011

installing rails on OSX with mysql

trying to install and use ruby on rails on OSX with a mysql installation made by hand in /usr/local/mysql


$ rails server/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/mysql-5.5.17-osx10.6-x86/lib/libmysqlclient.18.dylib (LoadError)  
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle  
Reason: no suitable image found.

I'm probably missing something about a correct installation on osx and with a correct distribution of mysql libraries but I've seen that the fastest way of getting rid of this problem was a:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

use the

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

should be the proper solution

Thursday, March 25, 2010

yum problems


upgrading after a while I encountered these problems:

[...]
Trying other mirror.
http://ftp.crc.dk/fedora/linux/releases/12/Everything/x86_64/os/Packages/privoxy-3.0.13-beta.1.fc12.1.x86_64.rpm: [Errno 14] PYCURL ERROR 6 - ""
Trying other mirror.
http://fedora.uni-oldenburg.de/releases/12/Everything/x86_64/os/Packages/privoxy-3.0.13-beta.1.fc12.1.x86_64.rpm: [Errno 14] PYCURL ERROR 6 - ""
Trying other mirror.
ftp://ftp.pbone.net/pub/fedora/linux/releases/12/Everything/x86_64/os/Packages/privoxy-3.0.13-beta.1.fc12.1.x86_64.rpm: [Errno 14] PYCURL ERROR 6 - ""
[...]


these 2 commands solved my night:

# yum clean all

# yum check-update

Tuesday, February 23, 2010

DBD::mysql on Leopard


I've encountered this problem

dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: dynamic lookup

dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: dynamic lookup


I always have problems due to multiple installation of mysql my hand, 32 and 64 bit, and 2 different installations of perl (one coming from Leopard, the other from port).

To solve this (due to 64bit mysql libraries and missing 32bit libs) I decided to recompile DBD::mysql on my box in CPAN

CPAN> force install DBD::mysql

and apparently this solved the problem

sudo: sorry, you must have a tty to run sudo

running a rather complex command through ssh :

# ssh user@remotebox "sudo su - user2 -c remotecommand"


gives me the following error:

sudo: sorry, you must have a tty to run sudo


fortunately sudo offers the option -t for a pseudo terminal allocation
and the instruction

# ssh -t user@remotebox "sudo su - user2 -c remotecommand"



now works perfectly

Monday, January 04, 2010

spamassassin 2010 bug


I understand it's a pretty stable program,
but this error is really gross!

https://secure.grepular.com/blog/index.php/2010/01/01/spamassassin-2010-bug/

changed local.cf and added:

score FH_DATE_PAST_20XX 0.0

Monday, December 28, 2009

will Mysql die ?

http://monty-says.blogspot.com/2009/12/help-saving-mysql.html

Tuesday, August 11, 2009

lovely error message from CPAN


Undefined subroutine &Compress::Zlib::gzopen called at /opt/local/lib/perl5/5.8.8/CPAN.pm line 5721

no solution, yet!

my best wild guess is that port/CPAN has broken the installation of CPAN/port.

Should I use cpan or port ?
May I use both ?
Since I'm not binded to any version in particular I could probably u

se both...

Sunday, July 26, 2009

CPAN not working


uh, CPAN stopped working on my MacBook yesterday...
no apparent reason for that, only an error like:

Can't locate Mac/Files.pm in @INC (...)

after checking libraries and the file /Library/Perl/5.8.8/AppendToPath
I've decided to make a fresh installation of Mac::Files...

I've downloaded from:
http://search.cpan.org/~cnandor/Mac-Carbon-0.77/Files/Files.pm

and made a forced installation...

CPAN is back at work, now!

Tuesday, March 10, 2009

ImageMagick


I think ImageMagick is the right weapon for most image manipulation scripts...

I generally use mac ports to install / update it, I've found a small bug about
a mismatching checksum.

A port selfupdate solved all (since some good guy solved the checksum bug ahead)

Tuesday, March 03, 2009

reset mysql password


just a short memo, as usual:

stop mysql

restart in safe mode:

mysqld_safe --skip-grant-tables &

enter as root, now:

mysql -u root

and reset table password:

use mysql
update user set password=PASSWORD('newpassword') where user='root';

Wednesday, February 11, 2009

Web Scraping


AKA convert a standard web page to RSS feed...

still to check:

http://www.feedyes.com

http://www.feed43.com

http://www.feedfire.com

Tuesday, February 03, 2009

installing PHP with GD on OS X


I was quite disappointed when realized that the apache+php coming with OS X was without the GD libs compiled in...

A complete recompile of both programs is needed, but this guy decided to help:
http://www.entropy.ch/software/macosx/php/
from here you can dowload an updated version of php precompiled, with some libraries included... se his pages for more details.

Apache, as usual from http://httpd.apache.org...

I paraphrased MArk's advices for compiling Apache:
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i686" sudo ./configure --prefix=/opt/apache2 --enable-mods-shared=all --enable-proxy-balancer --enable-proxy-ajp --enable-proxy-http --enable-proxy-ftp --enable-proxy-connect --enable-proxy --enable-ssl --enable-so

I've changed the location of the brand new sdk, removed the 386 arch, the ppc arch and added the i686 arch.

sudo make
sudo make install

sudo shouldn't be really necessary 'til the last step, but shouldn't harm much.

Created a conf/other directory for my configurations,
added an Include directive in the main .conf file,
added the php.conf as described in the entropy.conf

Unfortunately a nasty error message appeared on starting up the web server on a missing lib...

I needed to:
696 cd /opt/apache2/
697 sudo mkdir lib
698 cd lib
699 sudo ln -s /opt/local/lib/libexpat.0.dylib .
create the missing dir, creating a symlink to the missing library to resolve this. Dumb working solution.

Tuesday, December 09, 2008

install LAMP (Apache - mysql - php) on Ubuntu

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install mysql-server-5.0

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

Wednesday, December 03, 2008

show / unshow all files in Finder - OSX

with the command, from the Terminal:

defaults write com.apple.finder AppleShowAllFiles [ TRUE | FALSE ]

and restarting Finder (note the upcase)

killall Finder

Finder will show/unshow all the hidden files

Monday, October 13, 2008

php and XML

I wanted to run some php scripts to parse and create XML docs,
but on my Fedora 9 the XML package called DOM is disabled

the error on the script was:
PHP Fatal error: Class 'DOMDocument' not found

on phpinfo()
--disable-dom was one of the preprocessing compiling directives...

solution is easy and straightforward:

yum install php-xml

Thursday, July 31, 2008

last n records in a query

I'm using mysql for this:

This is straightforward:

SELECT * FROM tab LIMIT 0, 10

will display the first 10 rows from the table tab.

SELECT * FROM tab LIMIT 5, 2

display rows 6 and 7 (5 is the offset, 2 the count)

And:

select * from (select * from TAB order by id desc limit 5 ) TA order by id;

display the LAST 5 rows.