yum install php54-php-pdo yum install php54-php-pdo_mysql
A friend of mine asked the excellent question on why I bought an I²C 1-Wire expansion module for 300 SEK (about €30) when there are kernel drivers for using 1-Wire over GPIO right away and exposing the 1-Wire network below /sys/bus/w1/. I honestly didn’t know of this option!
Now I’ve made some investigations and realized that for example the DS2406 1-Wire chips I already bought are not yet supported by the kernel. There is a patch, for those who like to compile their own Raspberry Pi kernel. I don’t.
Also, OWFS seems to do an OK job of hiding the way of interfacing the 1-Wire network, so as long as use OWFS to access my 1-Wire stuff I should be able to switch to the w1 kernel drivers in the future.
For now, I will continue to use the I²C 1-Wire expansion module, because it works fine, I already bought more than one of them (!), and all my stuff is supported.
Me and my wife recently bought a cottage half an hour’s drive from where we live.
She is enjoying herself immensely with interior decorating, grinding floors and mowing the lawn. She is also looking forward to washing and painting the windows and exterior walls…
Naturally I will also do some work on and around the cottage. I use to say that I’m only handy when forced to, but that’s not entirely true…
Now for the fun part. I have taken on to implement home automation for the cottage. At start it will be mostly monitoring temperature, measuring electricity consumption and checking door and motion sensors.
My main sources of 1-Wire hardware is the special interest Swedish web shop m.nu. For other stuff I use the Radio Shack of Sweden: Kjell & Company, and, of course, eBay!
This is a list of some stuff I bought on eBay for various parts of this project. Prices provided in case want to compare to ordinary web shops…
- 10 × PIR motion sensors, $12.59
- RJ45/RJ11 cable tester, $2.91
- 100 × RJ11 plugs, C $4.33
- RJ45/RJ11 Crimp Tool, GBP 4.99
- NoIR camera module for Raspberry Pi, $28.49
- 2 × Infrared lights for NoIR camera module, $9.49
- 9800mAh DC 12V rechargeable Lithium-ion Battery, $27.53
- Micro USB splitter charge cable, GBP 1.49
- 20 × magnetic door/window sensors, $17.12
So, what is all that stuff good for? My plan is to make a series of posts about the various parts of the project, but I make no guarantees…
At work today we discussed the concept of future-proofing, which I consider a bad practice. I can elaborate another time but my talented colleague Anders Holmberg invented now-proofing on the spot. That’s what we should be aiming for!
Our bried discussion was inspired by this quote:
If you are not embarrassed by the first version of your product, you’ve launched too late.
– Reid Hoffman
Inspired by ThoughtWorks Technology Radar, here is an attempt to write down my current world view:
- Cloudflare – reverse proxy in the cloud, protecting and speeding up your web sites
- Composer – PHP package manager
- Redis – key/value database
- sphinx – search server
- Tonic – PHP microframework for REST(ish) web services
- VirtualBox – virtualization engine
- Mozilla Persona – use the same e-mail address and password to login to many web sites (not so many yet though)
- OpenShift – cloud application platform
- “Private cloud” – run your own “cloud” server
- Raspberry Pi – small and cheap computer
- Server Sent Events
- Chef or Puppet
Is the formatCurrency method of the NumberFormatter class in PHP working properly for you or does it return things like “NaN” and “¤¤¤”?
I have worked around it by being more careful about what locales are allowed.
If you haven’t tried OpenShift yet, you should!
Anyway I have a WordPress installation there. When upgrading WordPress to a new version, files are changed on the server but they would be overwritten if I push the repository. So I created a script to download a snapshot of the OpenShift app, extract the changes in the
php directory where WordPress resides, and add them to repository.
It is fully automated except for the crucial
The script is called update-repo-from-snapshot.sh and is meant to be commited to the root of each repository.
I’m a very happy user of New Relic for my websites, even if I’m only leeching on the free tier.
One of my WordPress sites, taurin.se has been suffering from this out-of-memory error for quite some time now and I finally tracked it down. New Relic shows the stack trace, with the failing line on top:
in wpdb::get_results called at /usr/share/wordpress/wp-includes/wp-db.php (1413)
in wpdb::get_results called at /usr/share/wordpress/wp-includes/meta.php (295)
in update_meta_cache called at /usr/share/wordpress/wp-includes/post.php (4133)
in update_postmeta_cache called at /usr/share/wordpress/wp-includes/post.php (4113)
in update_post_caches called at /usr/share/wordpress/wp-includes/query.php (2534)
in WP_Query::get_posts called at /usr/share/wordpress/wp-includes/query.php (2695)
in WP_Query::query called at /usr/share/wordpress/wp-includes/query.php (2791)
So, it fails when updating the postmeta cache. What’s that? Well, had a look in the database.
In the database I found the wp_postmeta table. A quick check revealed that it contained thousands of syndication_item_hash entries. These are added by the FeedWordPress plugin.
Unfortunately taurin.se is quite low priority for me, and the blogs I have been syndicating seem quite dead. But the upside is that I could just disable FeedWordPress and delete all syndication_item_hash entries from the wp_postmeta table.
Now my web server should work much better!
I’m currently running three Raspberry Pi projects, with Raspbian as my choice of distribution. One of the machines will be co-located at FS Data and run ownCloud. The other will be handle switching a central heater between oil and electricyty via SMS. The third is a surveillance camera heavily inspired by Dummy camera made smart with Raspberry Pi by my talented colleague Tomas Bjerre.
While examining the default Raspbian image I noticed there were some things I will never use, so I disabled them to free up some RAM:
- Disable the consoles by putting a # in front of all lines containing /sbin/getty in /etc/inittab:
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
If you get into network issues and need the console you can always mount the SD card on another machine and edit the file there!
- If you don’t have a keyboard connected or otherwise don’t want global hotkeys, disable the triggerhappy global hotkey daemon:
sudo update-rc.d triggerhappy disable
- If you have Transmission installed but is not using UPnP, disable the minissdpd daemon for keeping track of UPnP devices:
sudo update-rc.d minissdpd disable
- If you run Apache, disable modules you don’t use. Maybe:
sudo a2dismod dir
sudo a2dismod cgi
sudo a2dismod negotiation
sudo a2dismod autoindex
sudo a2dismod setenvif
- Run sudo apt-get install libapache2-mod-spamhaus
- Open /etc/apache2/mods-enabled/mod-spamhaus.conf for editing (as root)
- Edit the MS_METHODS configuration setting. Make sure that POST is included and GET is not. Example:
- Edit the MS_Dns configuration setting. If the IP address of your server is 198.51.100.222, and the port of your web server is 80 as usual, you start with the port number, reverse the numbers in the IP address and the setting becomes:
So, for IP address A.B.C.D and port E, the value becomes E.D.C.B.A.ip-port.exitlist.torproject.org
- You may also want to edit the MS_CustomError setting. In my case it looks like this:
MS_CustomError “Limited access for certain clients. Please contact abuse at 2good.net to get full access to our services.”
- Enable the apache module with sudo a2enmod mod-spamhaus
- Restart apache with sudo service apache2 restart
[Fri Nov 16 04:28:05 2012] [crit] [client 126.96.36.199] mod_spamhaus: address 188.8.131.52.184.108.40.206.109.ip-port.exitlist.torproject.org is blacklisted. Deny connection to forum.taurin.se/index.php, referer: http://forum.taurin.se/index.php?topic=1731.0