mb_internal_encoding("UTF-8");
mb_send_mail( 'myrecipient@wherever.com', 'Polite subject', $message, $headers );
Tuesday, 30 August 2011
Sending UTF-8 mail with PHP
I was facing issues sending mail encoded as UTF-8 via PHP. In order to do it properly, you need to set UTF-8 as the encoding for the mail function (first line of code below). Then, mail can be sent (second line).
Sunday, 26 June 2011
Apache module modwsgi 3.3 on Ubuntu Lucid
A bit of library hell on Linux. I tried to install modwsgi on Ubuntu Lucid. I downloaded the Debian version. However,
You cannot install Python 2.7 (easily, at least) on Lucid, but you can install Python 3.1. Use
root@virt251:/tmp# dpkg -i libapache2-mod-wsgi_3.3-2+b2_i386.deb
...
dpkg: dependency problems prevent configuration of libapache2-mod-wsgi:
libapache2-mod-wsgi depends on libpython2.7 (>= 2.7); however:
Package libpython2.7 is not installed.
dpkg: error processing libapache2-mod-wsgi (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
libapache2-mod-wsgi
You cannot install Python 2.7 (easily, at least) on Lucid, but you can install Python 3.1. Use
apt-get
and that will do the trick.
Friday, 3 June 2011
Automatic creation of regular expressions in different computing languages
Regular expressions are a powerful tool, albeit they can become difficult to build. This page, text2re, helps you build complex re's and provides code in a number of computing languages such as Python, Perl, etc.
Wednesday, 4 May 2011
Modifying Xubuntu application menu
One of the most disturbing features of my Xubuntu desktop is the apparent inability to modify the application menu. In particular, I had a huge
So I edited the file
into
This is a simple example of what can be achieved if you (very carefully) edit the file.
settings
submenu with duplicated entries: many already appeared in the system
submenu.So I edited the file
/etc/xdg/menus/xfce-applications.menu
and changed the section
<Menu>
<Name>Settings</Name>
<Directory>xfce-settings.directory</Directory>
<Include>
<Category>Settings</Category>
</Include>
<Layout>
<Filename>xfce-settings-manager.desktop</Filename>
<Separator/>
<Merge type="all"/>
</Layout>
<Menu>
<Name>Screensavers</Name>
<Directory>xfce-screensavers.directory</Directory>
<Include>
<Category>Screensaver</Category>
</Include>
</Menu>
</Menu>
into
<Menu>
<Name>Settings</Name>
<Directory>xfce-settings.directory</Directory>
<Include>
<Category>Settings</Category>
</Include>
<Exclude>
<Or>
<Category>System</Category>
</Or>
</Exclude>
<Layout>
<Filename>xfce-settings-manager.desktop</Filename>
<Separator/>
<Merge type="all"/>
</Layout>
<Menu>
<Name>Screensavers</Name>
<Directory>xfce-screensavers.directory</Directory>
<Include>
<Category>Screensaver</Category>
</Include>
</Menu>
</Menu>
This is a simple example of what can be achieved if you (very carefully) edit the file.
Tweaking Xubuntu application menu
One of the things I find less appealing on my Xubuntu desktop is the apparent inability to modify your application menu. In particular, I had a huge settings submenu with duplicated entries, which already appeared in the system submenu.
So I edited the file
into
/etc/xdg/menus/xfce-applications.menuand changed the section
into
Settings
xfce-settings.directory
Settings
System
xfce-settings-manager.desktop
Screensavers
xfce-screensavers.directory
Screensaver
Sunday, 10 April 2011
Too many files in a directory hurting performance in Linux?
Some colleagues of mine have come to a situation where they believe that storing many files (in the order of hundreds of thousands) in a single UNIX directory (sorry, I ignore the file system that particular proprietary UNIX brand uses) seriously impairs performance.
Apparently,
True,
In summary, standard tools such as
Apparently,
ls
and related utils show a dismaying performance there. So I wanted to check that for myself on my own Linux backup directory on my ext3
external disk, where I store 100.000 files approx. (Note: I keep time stamped copies of my directory structure with hard links to a single directory where I store the actual files so as to avoid data multiplication).True,
ls
and ls -lrt
are slow, very slow there. However, ls -lrt > /tmp/ls.txt
is as fast as you could expect for a 7.5MB file. Also, touch kk
and rm kk
are as fast as in an empty directory.In summary, standard tools such as
ls
and find
may not be ready to deal with huge directories. The sorting abilities of ls
may scale as bad as O(n^2)
in some circumstances. Also, shell expansion (for *
, say) may not be very efficient. However, accessing files for creation, editing or deletion may be blazingly fast even in relatively oldish file systems such as ext3
on the cheapest hardware.
Thursday, 10 February 2011
Inserting Google visualizations in Wordpress blogs
I tried to insert a Google visualization into my (other) blog. I run into problems that Google itself solved.
The solution? Use the Custom fields shortcode plugin for Wordpress: first, install and activate it. Then, wherever your visualization goes, insert
[cf]this_is_my_tag_name[/cf]
If your plugin is properly inserted, at the bottom of the page you will see a form with title "Custom fields". Add a new custom field with name this_is_my_tag_name and paste the code for your visualization into the adjacent field.
The plugin will replace your tag with the code you inserted and your visualization will be properly shown in your entry.
Subscribe to:
Posts (Atom)
About Me
- cjgb
- Madrid, Spain
- Powered by datanalytics