At its basic level, the Law of Fives is a practical demonstration that perception is intent-sensitive; that is, the perceiver's intentions inform the perception. To whatever extent one considers that perception is identical with reality, then, it has the corollary that reality is intent-sensitive.
2011/12/04
Observer bias
2011/11/30
A startup
Anyway, the real goal of this post is to get a link to my latest companies brand new website. I'd like to brag about how awesome this website is, but it isn't awesome and prolly never will be. I didn't make it so don't blame me for the flash animation and canned newsroom sound.
But the thing is though, the product we sell really kicks ass. A fully configurable automagic document classification and document archiving intranet application. It can handle volumes of over 1 million documents a year. That's a lot of documents. One thing I realised a while back is that we didn't just write an archiving app, we wrote a tool to build an archiving app with. Which is both great and a pain because each install is so customised I have trouble keeping track.
It is noteworthy that this is the very first time one of my companies has even HAD a website. Which is another irony given that I developed websites for a living for over 10 years.
The URL again, for those that don't know how to the clicky-clicky: http://www.quaero.ca
(Full disclosure: I founded Quaero and yes this is a blatant attempt at seeding the search engines.)
2011/11/08
Sharp!
I was wondering how to glue the sand paper to the platter. Them things are polished smooth. I was figuring sanding the platter and using epoxy. But it turns out that the centrifugal force at 5200 RPM flattens things out just find. Who would have thought!
One of the first things I did was grind myself a shiv. Because life is tough in the En-Aitch.
I then promptly dulled it cutting up some paper. See? Even the paper is tough in En-Aitch.
2011/09/14
Pretty lights
Not that I care about a light that tells me if I have e-mail pending. But controling pretty lights from the computer? I'm all over that. Someone had already written a script in Python to control these things. I ported it to Perl because, well because I like Perl.
To use it, you must have Device::USB installed. And perl, of course.
Doing setcolour will show you all devices installed
Doing setcolour 1294:1320 1 will set all mail devices to colour 1, which is blue on one of my devices, green on the other.
Doing setcolour 2-7 2 will set one mail device to colour 2, which is red on both my devices.
2011/09/12
UPS and power conditioning
This is non-negotiable.
Not doing this risks you showing up Monday morning and not getting any work down while an admin drives 100 km to fix a problem.
And if you have any piece of important electronic equipment, you'll want a filter. And no the fuse on your power bar doesn't count.
2011/08/22
SSH tunneling for a small VPN
#!/bin/bash
HOST=$1
LOCAL_IP=$2
REMOTE_IP=$3
eval $(ipcalc --network $LOCAL_IP/24)
if [[ "NETWORK=$NETWORK" != $(ipcalc --network $REMOTE_IP/24) ]] ; then
echo "Local IP ($LOCAL_IP) and remote IP ($REMOTE_IP) must be on the same network" >&2
exit 3
fi
ip route del $NETWORK/24 dev eth0 2>/dev/null
set -e
set -x
ssh -w 0:0 $HOST "
ip link set tun0 up
ip addr add $LOCAL_IP peer $REMOTE_IP/32 dev tun0
arp -sD $REMOTE_IP eth0 pub
echo 1 >/proc/sys/NETWORK/ipv4/ip_forward
echo OK
while true ; do sleep 3600 ; done
" | (
set +x
read OK;
echo "Connected to $HOST: $OK"
ip link set tun0 up
ip addr add $REMOTE_IP peer $LOCAL_IP/32 dev tun0
ip route add $NETWORK/24 via $REMOTE_IP dev tun0
iptables --append FORWARD --in-interface eth0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface tun0 -j MASQUERADE
set +e
read -e -p 'Connected' K iptables --delete FORWARD --in-interface eth0 -j ACCEPT
iptables --table nat --delete POSTROUTING --out-interface tun0 -j MASQUERADE
echo "Use ^C to stop background ssh"
)
Note that the script has very little error checking beyond verifying that REMOTE_IP and LOCAL_IP are on the same /24.
The script is executed as
vpn-ssh remote-host local-ip remote-ip
. For example:ssh my-client 192.168.100.130 192.168.100.205192.168.100.130 is now an IP for the local computer. It may be connected to from the remote computer and anything on the remote network. If you set up your routing properly, other computers on the local network may also connect to the remote network also.
To create a tunnel ssh must run as root and must connect as root on the remote side. You should use have public/private keys set up, as allowing password login for root over ssh is a bad idea. Tunneling and root login are often deactivated by default, so you'll have to turn them on.
2011/08/19
Arduino on CentOS 5
All I wanted was to get one LED to flash. But that requires a avr-cpp-g++, which isn't available for CentOS 5. GRRRR!
So I wasted to much time getting the CentOS 6 SRPMs and getting them to compile. But you may fetch them from my psuedo-repo.
While time was a wasting, a kind soul on IRC sent me a hex file for bitlash which I managed to upload to the board. This allowed me to flash a few LEDs and get on with my work.
Writing code for the Arduino Uno in CentOS 5
RPMs will need from the psuedo-repo
avr-libc-1.7.0-1.noarch.rpm
avr-libc-docs-1.7.0-1.noarch.rpm
avr-binutils-2.20-2.x86_64.rpm
avrdude-5.10-1.x86_64.rpm
avr-gcc-4.5.0-2.x86_64.rpm
avr-gcc-c++-4.5.0-2.x86_64.rpm
gmp-4.3.1-7.x86_64.rpm
gmp-devel-4.3.1-7.x86_64.rpm
gmp-static-4.3.1-7.x86_64.rpm
libmpc-0.8-3.x86_64.rpm
libmpc-devel-0.8-3.x86_64.rpm
mpfr-2.4.1-6.x86_64.rpm
mpfr-devel-2.4.1-6.x86_64.rpm
You will also need arduino-0022.tar.gz, which I installed in /opt/arduino.
Now the IDE works, but it's in Java. Which hates me, hates Linux and I hate Java just as much, just for good measure I also hate IDEs. Working from two tutorials and with some slamming my head into the table, I got it working. The trick was massaging Johan's Makefile into something that worked. I also had to patch /opt/arduino/hardware/arduino/cores/arduino/wiring_private.h.
To start a new project, lets say "blink2"
mkdir blink2
cd blink2
wget http://awale.qc.ca/CentOS/rhel5/Makefile.arduino -O Makefile
wget http://awale.qc.ca/CentOS/rhel5/resetArduino.pl
touch blink2.pde
Now add your code to blink2.pde.
And here is my first Arduino program. It's a 6 LED chaser. It would be more, but I can only find 6 LEDs right now. Pins 13-9 are red, pin 8 is green. The green light stays on twice as long as the others.
#define DELAY 100
int state;
void setup(void) {
int pin;
state = 1;
for(pin=13; pin >=8; pin-- )
pinMode(pin, OUTPUT);
}
void set_state(void) {
int pin;
int mask = 1;
for(pin=13; pin >=8; pin-- ) {
digitalWrite( pin, (state & mask) );
mask <<= 1;
}
}
void loop(void) {
if( state == 1 ) {
state = 3;
}
else {
state = state << 1;
}
/* 0001 1000 = 18 */
/* 0011 0000 = 30 */
if( state == 0x60 ) { /* 0110 0000 = 60 */
state = 0x20;
set_state();
delay( DELAY*4 );
state = 1;
}
/* 0100 0010 = 42 */
else if( state == 0x42 ) {
state = 3;
}
set_state();
delay(DELAY);
}
Now compile and upload it:
make && sudo make upload
2011/07/21
Not Garbage Yet!
- Shiny and new and desirable;
- Garbage (very little survives);
- Old and desirable (aka Retro or Antique).
An example: the Pullman car was something a president wanted; North America reworked its railroads to accommodate it (and him). By now, most are destroyed. However, The New Brunswick Railway Museum has two. They also have a small shunting yard full of train cars, engines and cabooses that have survived the Garbage phase (in some cases just barely) and are moving into the Old and Desirable phase.
I ended up at the museum by accident; driving back to Shediac from the Hopewell Rocks, I saw a jet fighter plane parked by the side of the road. On a lark I turned the van around and drove pack to take pictures of it. My 14-year-old self wouldn't have forgiven me. But then Désirée claimed she wanted to see the trains. In fact she wanted to enter the trains. And so we did. And this brought back my 8 year old self and memories of the few train trips I made from Toronto to Montreal. There were no VIA Rail cars from the 70s, which I assume are still in the Garbage Phase, but some of the car seats from the 60s looked I bit like what I remember.
The real joy (for me) was in the large shed, where they had a Caboose we could enter. As a kid in North Hatley we used to watch the trains go by and wave at the man in the caboose. Cabooses (cabeese?) are now only a thing of memory (I had to explain to Dominique what a caboose was), but my inner 8-year-old-train-geek got a kick waving from the caboose at the passing kids. Or rather, my wife.
The next best thing was clambering around 3 locomotives, 2 diesel-electrics from the late 50s and a steam locomotive beast from 1912. And this is what is so awesome about this museum. I was afraid it would be all staring at immaculate restorations through plexiglass. Quite the contrary: we got to clamber on and around the locomotives and into the engineering rooms, sit on the beat-up seats, admire the different levels of tech in the controls from large brass levers all the way to 80s era scram switches and digital speedometers. Désirée could have shimmied into the boiler's furnace if her mother would have allowed her and her father could have cajoled her to do so. We pushed on the huge levers, pull the ropes, opened up the panels to see the turbines.
Were we supposed to do all this? No one was around to tell us not to; these are huge machines made to withstand years of hard work. We would have been hard pressed to break anything the engineers hadn't already.
Conclusion: Worth the price, worth a detour, would go again.
2011/07/20
Weighing the border
Because really, what you want is to give a border crossing a very high weight, so the AI will give it a low priority. CD-ROMs might also make you think of a time when crossing a border consisted of answering "yes,
$DESTINATION
, no, no" to a surly border guard. Nowadays it requires passports, finger printing and the possibility that you get shot when you go to reach for your glove compartment. So whatever the weight used to be, multiply it by 5. Or you could have a user configuration "USA border guards scare the hell out of me."All this makes me wonder if there's someone at Google Maps who's job is to evaluate the relative difficulty of crossing various borders, updating the system as foreign policy deteriorates.
What brought this back to mind is that I'm currently IN Shediac, New Brunswick.
In semi-related news: I've finally mastered wireless connection setup in CentOS. Delete ifcfg-eth1 (in both
/etc/sysconfig/network-scripts
AND /etc/sysconfig/networking/devices
), run nm-connection-editor
, let the wizard to its work. NetworkManager stores its config in ~/.gconf/system/networking/connections. The WEP key is stored somewhere else. Yes, the place I'm staying uses WEP, which takes less then a minute to crack but more then a minute for the owner to write down for you.
2011/07/15
Pain
Something you don't see everyday:
# cat /proc/mdstatOf course, this happens the day before I leave on a 2 week vacation.
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdb2[3](S) sdc2[2] sda2[4](F)
312367616 blocks level 5, 256k chunk, algorithm 2 [3/1] [__U]
unused devices:
2011/07/08
Fun with mysqldump
However, before I work on integrating xtrabackup, I decided to see how slicing the dump with a LIMIT clause would work. mysqldump doesn't allow me to set LIMIT directly, however it does zero validation on the WHERE clause I can set. So:
(
mysqldump --opt DB --ignore-table BIGTABLE
mysqdump -NB --no-data DB BIGTABLE
MAX=$(mysql -NB DB -e 'select count(*) from BIGTABLE')
INC=$(( $MAX/1000 ))
seq -f '%.0f' 0 $INC $MAX | while read start ; do
mysqldump --compact --no-create-info DB BIGTABLE --where "1 LIMIT $start,$INC"
done
) > /my/backup.sql
This only works because mysqldump blindly tacks the WHERE clause onto it's select statement, giving us (roughly)
SELECT * FROM BIGTABLE WHERE 1 LIMIT 0,918732
This is a hack and a half: a- while it works now (Perconna 5.1.54) there's no guarantee it won't break at some point. But more importantly, b- this will still take a week to restore.
BTW, black-eyes to the idiots made
%g
the default seq
format.
2011/06/27
Phishing
Now, I'm going to be highly suspicious of anyone calling me long distance without caller ID info. The "Global Security mutter mutter" made me highly suspicious that this was part of a new phishing scam that's been going on. The goal is to have you install some "Microsoft Security product" which is of course malware.
Notice to readers and family members: They are calling people in Canada. Never ever install anything a cold-caller says to. Ideally stop using Windows at all. It's security is atrocious and the knowledge required to keep it secured is beyond most normal users.
2011/06/03
Alpine Linux
lbu ci
after any config change.What's awesome: finally getting tcpdump on my router!
What's strange: full perl 5.12.3 on my router!
Alpine also include clamav, so you could use it to scan Windows computers for viruses. Kind of like these instructions.
2011/05/18
CentOS5 and a recent kernel.
But even if you don't want or need multiple OSes, vserver installs a RHEL 6 kernel. And it works with CentOS 5. Say you need ATA TRIM? You got it. Having trouble getting WiFi working? Bingo. Card reader on your Laptop not working? It does now.
EDIT: the catch is that sound is no longer working. While this is OK for the laptop, it isn't for my desktop. Ah well.
However, I can TRIM corey's SSD by booting with the vserver kernel, then doing
dd if=/dev/zero of=/tmp/very-largeThe first command is going to fill any remaining space on the disk with zeros, so don't be doing anything important at the same time. When the disk fills up, it will exit and the second command will free the space.
rm /tmp/very-large
You could also do the same thing with any boot CD that has TRIM support.
2011/05/17
Z8NA-D6 and lm-sensors
sensors
sees the chip, it doesn't manage to read the values. Must poke at it further.
Update: I finally got it working.
2011/05/04
Disk speed
# time dd if=/dev/zero of=/dev/sdc2 bs=1024k count=20480
20480+0 records in
20480+0 records out
21474836480 bytes (21 GB) copied, 704.374 seconds, 30.5 MB/s
real 11m44.375s
user 0m0.029s
sys 0m21.517s
Same operation on an ASUS M2N-MX SE with "only" 4 GB of RAM:
# time dd if=/dev/zero of=/dev/sdb2 bs=1024k count=20480Mind you, Xorg is running also, so that takes up RAM and CPU.
20480+0 records in
20480+0 records out
21474836480 bytes (21 GB) copied, 847.95 seconds, 25.3 MB/s
real 14m7.969s
user 0m0.335s
sys 7m17.540s
2011/04/01
loopback magic
dd
to grab the entire contents of a disk. Now you want to copy that disk to another one. Only the new disk isn't the exact same size as the old one, and probably doesn't have the same geometery. In which case you would be better off doing an rsync
then dd
to the new disk. The following trick will also work if you just want to read a partition.
First we need the offset of each partition:
#sfdisk -uB -l fulldumpWe ignore the warning messages, because we see that the first partition starts at 28*1024=28672 bytes. So we can mount that easily.
last_lba(): I don't know how to handle files with mode 81a4
Disk fulldump: cannot get geometry
Disk fulldump: 17 cylinders, 255 heads, 63 sectors/track
Warning: The partition table looks like it was made
for C/H/S=*/224/56 (instead of 17/255/63).
For this listing I'll assume that geometry.
Units = blocks of 1024 bytes, counting from 0
Device Boot Start End #blocks Id System
fulldump1 28 144255 144228 83 Linux
fulldump2 144256 39080831 38936576 8e Linux LVM
fulldump3 0 - 0 0 Empty
fulldump4 0 - 0 0 Empty
# mount -o loop,offset=$((28*1024)) fulldump /mntI used
# ls /mnt
config-2.6.18-164.el5 message
config-2.6.18-194.11.3.el5 symvers-2.6.18-164.el5.gz
grub/ symvers-2.6.18-194.11.3.el5.gz
initrd-2.6.18-164.el5.img System.map-2.6.18-164.el5
initrd-2.6.18-194.11.3.el5.img System.map-2.6.18-194.11.3.el5
initrd-2.6.18-194.11.3.el5-PG1.img t/
initrd-2.6.18-194.11.3.el5-PG2.img vmlinuz-2.6.18-164.el5
initrd-2.6.18-194.11.3.el5-SSD1.img vmlinuz-2.6.18-194.11.3.el5
lost+found/
$((28*1024))
because this way bash does the calculation for us.
2011/03/11
Rocky (again)
I then did a little calculation. A complete set of toner carts are 220 $ (plus shipping) for 3000 pages. That's roughly 7.25 cents per page. Using Lexmark toner, roughly 15 cents per page. Refilling by the carts by-hand brings it down to 3 cents a page pus my wasted time. So no matter how you look at it, this is an expensive toy. I think I'l put a kitty jar next to the printer to collect money on each print.
2011/03/07
Rocky
It works. At least, the web server works and it will print up test pages. It being a first generation POS it uses some secret sacred line protocol that will require a bit of work to get running under Linux.
And 2 of the toner cards need cleaning. But that is just going to be fun.
But the really annoying part is that I'm going to have to spend a day or 3 doing colour calibration, because I'm that kind of compulsive that if I'm going to print out pictures, I want them to look good.
2011/03/02
2011/02/24
Google does it again
Not only do they flag recipe as a special search type, but they allow me to refine my search by ingredient, cooking time and calories. OK, that last one is stupid and the list of ingredients they do allow me to exclude/include are a bit short, it's still impressive.
While on the subject of Google, take a look at this:
See that subtle little blue bar above "Web"? What's more, they only waste 130 pixels before getting to search results.
Microsoft wastes 145 pixels, which is not bad considering how much more fluff they have.
And Yahoo! wastes 190 pixels. And has blinding blue links that I kinda, strangely enough.
Pixels are important. Everyone seems to have made the mistake of buying a wide screen LCD, vertical pixels are at a premium.
2011/02/20
Nice one, Microsoft
Now, if there's something I enjoy more then complaining about computers, it's complaining about Microsoft. Not only that, I've been staring at websites for the last +16 years. Rarely has a website design made me go "woah, yes!" Black/white/grey/orange? Liberal use of whitespace? Visible clutter approaching zero? WOAH! YES!
What's more, the videos of the Metro design language I've seen make it look really nice. I would call it what happens when you mix Helvetica, iOS and the minimalism of the 1972 Munich Olympic pictograms.
PS: I was going to post a link to Apple's iOS 4 page, but I had to spend a few minutes refusing all the cookies they wanted to set. Fuck 'em.
2011/02/08
Nice one Google
YES! That is so useful, it makes you wonder why they didn't have it before. Or did they and I only just noticed.
Also works: Asus, CPAN, boardcom, youtube. (Woah, 'you' returns youtube. OK, maybe not so strange, considering who owns youtube.)
I wonder what it takes to get the site-search treatment, because the following don't work: Linux, Perl, Apple, Wacom.
2011/02/03
2011/02/02
CentOS4 and gcc4
query_response_time.cc: In function `void query_response_time::add_time_atomic(query_response_time::TimeCounter*, uint64)':
query_response_time.cc:160: error: `__sync_fetch_and_add' was not declared in this scope
query_response_time.cc: In member function `void query_response_time::time_collector::collect(uint64)':
query_response_time.cc:261: error: `__sync_fetch_and_add' was not declared in this scope
make[3]: *** [query_response_time.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory /usr/src/redhat/BUILD/Percona-Server/sql'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory /usr/src/redhat/BUILD/Percona-Server/sql'
make[1]: *** [all] Error 2
make[1]: Leaving directory /usr/src/redhat/BUILD/Percona-Server/sql'
make: *** [all-recursive] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.49946 (%build)
You curse and swear.
__sync_fetch_and_add
is part of Intel's Itanium ABI and just plain isn't implemented in GCC 3, the default compiler in CentOS 4.
But the solution is easier then you think:
yum install gcc4 gcc4-c++
export CC=gcc4 CXX=c++4
OK, so maybe it's harder then that; you will probably have to add the following to your spec file:
BuildRequires: gcc4 gcc4-c++
%define cc_cmd ${CC:-gcc4}
%define cxx_cmd ${CCX:-g++4}
And replace any hardcoded reference to gcc or c++ with
%{cc_cmd}
or %{cxx_cmd}
.
2011/01/21
Perl signals and fork aren't safe.
Long story short: there is a race condition between the safe signal handlers (which just update a flag) and
pp_fork()
invokes the system fork()
. No, pp_fork()
doesn't reset all the flags, so the signals could be dispatched in the child process, even if they were meant for the parent.What boggles me is that this bug is easily over 10 years old. I find it hard to believe that no one noticed it before. Of course, it will take a while for a patch to make it into perl. And all the perls installed out their still have the bug.
The work around is to block signals, fork(), then unblock signals.
I'll write (or someone) IPC::SafeFork to do the above. But also draw attention to the issue.
Sphinx and daemontools
fghack
(which doesn't work) and --console
(which isn't what is wanted).
However, peering into the source code to see if I could prevent it from backgrounding, I found just what I wanted: the undocumented
--nodetach
switch. Well, it has some documentation; there is a changelog entry that calls it a debug switch, which it isn't. Shame on you Sphinx-team!
Anyway, here is my daemontools
run
script:
#!/bin/bash
config=/opt/sphinx/etc/sphinx.cfg
servicename=sphinx
echo $(date "+%Y/%m/%d %H:%M:%S") $$ Sphinx searchd
exec setuidgid dw \
/opt/sphinx/bin/searchd --config $config --nodetach 2>&1 \
| /usr/bin/logger -p info -t $servicename
BTW, I have RPMs of Percona-Server (aka MySQL with a bunch of good patches) with SphinxSE.
2011/01/14
I need more RAM, Scotty!
~ (root@corey:)# free4GB of RAM on Corey, boyee!
total used free shared buffers cached
Mem: 3913752 821824 3091928 0 38376 439640
-/+ buffers/cache: 343808 3569944
Swap: 0 0 0
RAM is really cheap. I've been saying this for years. USD is also cheap these days. And I was finding Firefox really annoying at times. So I poked around Asus's site, discovered that Kingston claims that a M2N-MX SE can take 4GB of RAM. Out came the credit card. Thank you Newegg, thank you Purolator.
And yes, Firefox is subjectively much faster. Even though, as you can see above, I'm still using less then the 1 GB I had previously.
Or maybe it just stutters less. Or maybe it's the fresh reboot.
2011/01/13
Perl crumudgeon
Write the minimum of code and it would All Just Work.
Of course, I got over that. No framework can be all-dancing. There's a joke about a Clippy-a-like for an IDE: "I see you are writing a framework. Would you like me to a- erase this and Google for something that does what you want?"
But that's not all: I have a colocated server that runs some applications for clients. These apps were written for perl 5.004_05. I have no time nor want to get the running with a modern perl or mod_perl. But for years all the code I wrote had to with 5.004. And I insisted that POE would too.
And it now seems everyone is using Catalyst and Moose. And the shiny new things like "say" and "given/when." And perl 5.12. I JUST STARTED USING 5.8!
Of course "just" means a few years ago.
I think I've become a Perl curmudgeon, a more recent version of my associate Jean-Phillipp. When I first started working with him, he was using a modem to get to his customers, telnet and rlogin to communicate between servers, SCO and BASIC for everything. He's now accepted ssh (though I spotted an instance of rlogin last summer), gets me to install and sysadmin Linux. But still uses BASIC.
I guess I'm showing my years. "say" just looks ugly as a language construct; I have no problem typing "\n". Moose rubs me all wrong, despite it being very much aware of how much it is needed.
And while I've done a good deal of JavaScript recently, I haven't done any real AJAX, ie bidirectional. What they call comet.
In my defence, I've only really started 2 large projects in the last 6 years. These projects have taken most of my time. And with large projects, you should to stick with what the Way It Is Done or you get schizophrenic code. Not that my code isn't schizophrenic, but I've decided that just because you discovered some cool new way of doing something, you shouldn't use it the same day in an existing project. Magic is very hard to maintain.
What's more my toes are cold.
Now that I've identified the above, maybe I can change somethings and not be as hide-bound.