0

unit tests for PECL extensions and how to make them work

Posted by Gabriel on Dec 4, 2009 in pecl, php

Recently I’ve been installing a few PECL extensions, I dev on Snow Leopard which is PHP 5.3 but my colod server is Ubuntu 8.04 LTS which is PHP 5.2, so being me I ignored the various warnings on the sqlite3 page of php.net ( Note: This extension was briefly a PECL extension but that version is only recommended for experimental use. ).
I managed to get the extension installed fine ( phpize, ./configure, sudo make, sudo make install )

wget http://pecl.php.net/get/sqlite3-0.6.tgz
tar xvzf sqlite3-0.6.tgz
cd sqlite3-0.6/
phpize
./configure
sudo make
sudo make install

Now the last line for make install asks you kindly to “Don’t forget to run ‘make test’.”
So let’s do that
Lots of output

Variations on that line appear about 20 times, it seems to be looking in a directory relative to the sqlite3-0.6 directory for the modules
The lovely Cyberspice has made an entry about this already
building php c extensions on ubuntu 9.10
unfortunately I didn’t see this until after I went my own, different route.
Thanks to Derick in #php.pecl on efnet I came up with this bit of code

TEST_PHP_EXECUTABLE=`which php` php /home/gabriel/sqlite3-0.6/run-tests.php /home/gabriel/sqlite3-0.6/tests/*.phpt

which then outputs
Lots of output

So I’d chalk that up as a win, there might be things that get missed running it like this, but I’m not sure.
You can either just run that line of code in the shell or have it in a bash script and then build the bash script to accept parameters so it becomes a lot more customisable.

Tags: , ,

 
2

istat server monitoring via iphone

Posted by Gabriel on Nov 27, 2009 in iphone, linux, server admin

So last night I decided that with my shiny new iPhone I was gonna check out a few apps for monitoring servers, obviously running my own server and a few VMs on it monitoring it is very important (but until now has basically been me checking top/free etc when I remember and getting an email if any vm doesn’t respond for a preset time).
I knew the company that produced istat pro (a mac os widget for monitoring your local system) had something so I decided to give that a try, cunningly named istat. £0.60 spent at the app store and I was sorted, it was easy enough to set up monitoring my mac book from the iphone when on the same wifi (it does it via bonjour) but a little trickier to setup the port forwarding on my airport base station (yes I’m an extreme Apple user now, but not an evangelist of Apple so I get to avoid the fanboi name tag, at least that’s what I tell myself). After checking I could still monitor my mac book via 3G it was time to move on to the servers.
Now the company the produces the istat monitoring app and istat pro (islayer aka bjango) doesn’t officially have a daemon for running on *nix, but some kind soul had created one which bjango links to from their home page, called istatd (istats daemon, geddit?) which is available via google code.
So, ssh into my experimental vm (running ubuntu 8.04 lts) that I use to try new stuff out on,

wget http://istatd.googlecode.com/files/istatd-0.5.4.tar.gz
tar xvzf istatd-0.5.4.tar.gz
cd istatd-0.5.4
./configure

, ah, dependency, no problem

sudo aptitude install libxml2-dev
./configure

and it passes fine this time.

sudo make
sudo make install
and there we have it, all installed, the configure file by default goes in rather a bizarre place, so we do

sudo nano /usr/local/etc/istat.conf

and made it for my configuration look like this

#
# /etc/istat.conf: Configuration for iStat server
#

# network_addr 127.0.0.1
# network_port 5109
server_code 10293
# server_user istat
# server_group istat
# server_socket /tmp/istatd.sock
# server_pid /var/run/istat/istatd.pid
# cache_dir /var/cache/istat

# Note: Only support for one network interface, limited by client.
monitor_net ( eth1 )

# Array of disks to monitor. Specify mount path or device name.
monitor_disk ( / /home /usr /var /mnt/music )

# Set to 1 if you want to use mount path as label instead of the device name.
disk_mount_path_label 1

# Try to probe the filesystem for disk label, will override the mount path label.
disk_filesystem_label 1

# Set custom disk label. Will override all other labels.
# disk_rename_label /dev/sda1 "root"
# disk_rename_label /home "home"

# End of file

make sure you do this line so that you get a nice display of your mounted points
disk_mount_path_label 1

Now unfortunately there’s no standard init script for it, so atm it gets started with
sudo istatd &
though I’ll probably knock one together at some point and there we have it, all nicely done and monitoring the vm, it doesn’t monitor temps or fan speeds atm but hopefully sometime it will, here’s an image of it monitoring the vm this blog is on

istat monitoring istatd on 403.be

istat monitoring istatd on 403.be

I’m going to try installing it onto my SuSe vm this evening, so I’ll update this post with how that goes as well as any init script I come up with.

btw if you don’t know how to grab a screen shot of your iphone, hold the home key and press the sleep key at the top, a flash of white later and it’s saved on your film roll.

Tags: , , , , , , , ,

 
0

PHP and PECL Extensions on Snow Leopard

Posted by Gabriel on Nov 15, 2009 in pecl, php, snow leopard

This is a quick post that I could possibly come back and improve later

This is based on something being in a users home dir/sites/ directory.
Although it doesn’t really matter for a cli script
So we have
/Users/gabriel
/Users/gabriel/Sites
/etc/apache2/users/gabriel.conf
is the conf file for the vhost in your user dir which you shouldn’t really have to worry about, but always good to know where it is.

sudo nano /etc/apache2/httpd.conf

uncomment the php line that is found in here, I also uncommented the fastcgi line after it for kicks

sudo apachectl restart

And that’s you sorted for php on apache, note this is php5.3 on apache 2.2.13

For this I’m installing the runkit PECL extension “For all those things you…. probably shouldn’t have been doing anyway….”
We need to install the sex that is xcode, grab the latest one from the Apple Developer Connection website http://developer.apple.com/tools/xcode/

We have svn installed already so grab a copy of it, http://svn.php.net/repository/pecl/runkit/trunk/ is the repo and http://svn.php.net/viewvc/pecl/runkit/trunk/ is the fancy human readable version

svn checkout http://svn.php.net/repository/pecl/runkit/trunk runkit
cd runkit
phpize
./configure
sudo make
sudo make install

and we’re nearly done!
I couldn’t find a default php.ini and a simple phpinfo(); seems to indicate there isn’t one, so we:

sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini

find the long list of commented out modules
and add

extension=runkit.so

Quit and save and

sudo apachectl restart

you don’t really need todo that since you’re probably using it in cli but it’s fun to do anyway

Tags: , , ,

 
0

Zend Dojo Decorators

Posted by Gabriel on Jul 22, 2009 in dojo, php, zend

I’ve been having some trouble getting zend decorators to change the way a form layout displays on the page, by default zend likes to display it’s forms like this

<form>
<dl>
<dt>Label</dt><dd><input type=…></dd>
<dt>Label</dt><dd><input type=…></dd>
<dt>Label</dt><dd><input type=…></dd>
</dl>
</form>

and I wished them to be more div-y.
Unfortunately due to the complex ways of them creating horizontal sliders this wasn’t usual, so I decided to settle for a table, tr and tds, because of the strange way we’re doing the form (we start with the form hidden and reveal each question as the previous one passes validation (zend’s validators for the appearence and some custom ones before revealing the next question, stored in a hidden field)) this was actually quite tricky, especially when we had questions that didn’t need answering, so they needed to pass validation before they were even focused on so that the next field would be revealed until the time that a required question was met. It would have been a lot easier to have all the voluntary questions in one block at the end or beginning but the order of the questions was important.

So in the way of the decorators we have
$decoratorsOpen = array(
‘DijitElement’,
‘Errors’,
array(array(‘data’ => ‘HtmlTag’), array(‘tag’ => ‘td’)),
array(‘Label’, array(‘tag’ => ‘td’)),
array(array(‘row’ => ‘HtmlTag’), array(‘tag’ => ‘tr’, ‘openOnly’=>’true’, ‘class’ => ‘hiddenToReveal’, ’style’ => ‘display:none;padding:auto;’, ‘id’ => $IDName.’TR’)),
);
Fairly easy, we ignore DijitElements (because they tend to be a bit complex for our generic decorator) and errors, we find the elements regarde as data and chuck em in a td, same with the labels, we then suround the group in a tr, but with ‘openOnly’=>’true’ this means the tr only gets open and we can tack some more elements into the same tr. Set the trs class, some styling and the id of the tr, this is what gets used to identify the element to be revealed.
And then we add in a hidden element that contains the validation regex and close the tags with a similar decorator except with ‘closeOnly’=>’true’.

After all that we define some js to check the current element (onfocus, onkeyup etc) and validate and then get all the elements of class hiddenToReveal, loop through till they find the element whos predecessor is the one we just validated and reveal it to the world! (dojo.fx.wipeIn ftw)

One of the noticable things about dojo is their lovely tooltips, unfortunately they don’t always work with each element, for example datetextbox extends validationtextbox, validationtextbox has a promptmessage method for doing the tooltip, datetextbox can use this method without Eclipse or PHP complaing, but it just doesn’t display the tooltip, so we have genrerate them seperatly and add them ignoring promptmessage.

This might break mvc but I’m not sure:

In the view
foreach( $this->TooltipArray as $elementId => $tt){
echo $this->tooltip(
$elementId.”TT”,
null,
array(‘connectId’ => $elementId, ‘label’ => $tt ));}
And all we do is pass it an array of ['elementId']=’tooltip’, the tooltip itself has an id elementIdTT, the tooltip is connected to elementId and the tooltip has the value \o/

Now I get the fun of doing serverside validation and playing with dojo.xhr to submit the data. :)

Tags: , , , ,

 
0

She lives!

Posted by Gabriel on Jul 21, 2009 in GoMAD thinking, dojo, linux, php, zend

I haven’t posted in a while, I’ve just started my University placement and am currently working for GoMAD thinking designing an online coaching tool using the Zend Framework and Dojo. It’s quite different learning to use php in a proper MVC way, even trickier learning to work with Zend to get around it’s interesting little foibles. I decided to resurrect this blog and use it as a kind of dev blog, charting the pitfalls and solutions I’ve encountered on my journey, I also plan to explain a bit more about the company and the location we’re working in.

We work currently on our own laptops that the company provides, we have stands to put them in and keyboards and mices to attach, no external monitors so I’m very glad I managed to get a new one with a decent screen, a toshiba Satellite Pro A300, it originally came with Windows Vista Business in and I’ve left that on here but I’ve also installed Ubuntu 9.04 which seems to be working well.

I’m developing using the latest eclipse from source for php developers and the standard php/Apache that comes on the Ubuntu repos (5.2.6 and 2.2.11)

I’m working with Gavin a fellow student from DMU and Antonios, a DMU PhD student working towards a doctorate in fuzzy logic style.

I’m currently working on a SMART goals defining webpage, generating questions from a db, using dojox.fx to hide and reveal questions as and when they become active. Having a little trouble with decorators at the moment and I’m waiting for a reply on nabble, Matthew Weier O’Phinney has helped me via nabble so far and hopefully we can get this sorted today.

I’m really enjoying working here so far, and learning to use Zend/MVC helps lots to keep me interested.

Tags: , , , , , ,

 
0

Snow! G1!

Posted by Gabriel on Feb 2, 2009 in G1, snow

Yay it’s snowing, and as I was walking to Uni I thoguht I’d take some pics using my G1, they’re a bit blurry, the G1 takes it’s time taking photos, but here they are anyway.

 
0

Apple Store Staff and the Heroin trade

Posted by Gabriel on Sep 15, 2008 in Uncategorized

I wrote this a few days ago and completely forgot to publish it.

I had some spare time yesterday and so instead of sitting geeking online all day I decided to head out and investigate The World. The shopping centre in town has been expanded and renovated so I went on a tour and to see if I can find pretty clothes for myself. I found some nice jeans I might buy in a couple of weeks but the real reason for going was to pop into the Apple store and have a play. The new Mac books look nice, not that horrid shiney plastic crap they used to be We use the white plastic iMacs at Uni, but the new ones seem to be a nice shiney alu, so might have to nab one of them. I really do think the people at the Apple store have to be on some form of heroin, they’re perpetually happy and bouncy, not once whilst I was cruising amongst the throngs of people in there did I see anything other than beaming smiles and happy thoughts. They’ve had a nice refresh of some of the apple stock as I mentioned above, the Mac Books look nice, iPod nano is quite nice looking too, although I might by a shuffle, they’re kinda neat but I wish they had more space.

G’night readers.

 
0

phpBB2 and the futility of package management

Posted by Gabriel on Sep 8, 2008 in Uncategorized

So since we moved Hidden Agenda’s website off the old rented website and onto the lovely new colod server there hasn’t been a forum available, mostly through my own laziness. So yesterday after discussing it with Ben I decided to get it installed again and let him get on with it. I’d already had a few problems with apt/aptitude on our home server trying to get transcoding working for fruppes etc (finally given up and returning it to windows/tvaversity so I approached this with some trepidation. After apt-cache searching I found that the only version available was phpBB2 which is approximately 2000-2! I decided sod it and install that version anyway for simplicities sake. Unfortunately the version in the repo for Hardy is somewhat fucked and wont actually install, a quick Google turns up a known bug and a fix, sod that. If I’m not installing from the repo I might as well not bother with Yea Olde version and just nab the source for phpBB3, 5 minutes later and bang, all sorted, it took longer to try and install v2, find the fix and decide not to bother than it did to install v3 from source! I am determined one day just to give up on repository stuff and go straight for building everything from source and on slackware. But eh, I’m far far too lazy todo that, so I’ll stick with broken, out of date repository stuff and enjoy bitching about it.
2 weeks till student loans, I’ve already ear marked most of my money:

  • new server and collocation (thinking Dell R200/300 or possibly home grown, I don’t really need advanced RAID on it. I plan on 2 hard drives, non-RAID, 1 as the work horse hosting the vms etc and then using the other as a backup.
  • new laptop, I really want a nice thin one, still torn between a Mac Air or a new EEE 1000. I don’t want a giant 17inch monstrosity but maybe a 15 inch Mac Book. I’ve been looking lot at the refurbished Macs they sell on their site, same warrenty as a brand new Mac but discounted and with the possibility of slight cosmetic injury.
  • a new PC. Since I blew the last one when it was connected to Dave’s single stage I need a new one, I haven’t really missed gaming that much tbh so I might consider having a Mac for my main PC and triple booting MacOS/Ubuntu/Windows. Of course if I get an expensive Mac laptop I’ll be having to use that as my main pc and just connect it to monitors when using it at home. But we shall see.

Ofcourse I’ll change my mind about this all completely tomorrow, but it’s fun to speculate… :)

I’m still getting headaches :/

 
0

Standards? Me? No thanks!

Posted by Gabriel on Sep 8, 2008 in Uncategorized

So after finally getting a fair bit of the mod_rewrite and general hacking of wordpress needed to make it all fit in nice and neat with the rest of the site I started thinking about the rss feed icon. This lil image has been around a while and was quite boring and didn’t really fit in where it was placed: in the iframe below the blog_name text. So I went off on a wander around the webness searching for different and possibly interesting icons to use instead of the b(l)og standard one. Lo and behold I found this neat little chap, one of a pair infact on this here blogwebsitething. A little editing in Gimp later and we have this neat little chap, comment out the code for the rssfeed in the blog itself and add it to the main site and tah dah. Now he looks very cute but the rest of my site didn’t really match, going from the plain black&white of the original to beige/brown/black of the newer one really made me think about the lack of “decent” colour schemes used in most peoples websites. Anywho I wanted my little RSS chap, who I shall name Bob, to feel relaxed and fit in so I thought I’d try and mod the text on the pages to fit in with the colour, unfortunately this didn’t really work and most of the text became unreadable. So I decided what the hey and tried changing the back ground of the site to fit in with, and I think it looks much, much better this way, I may change the colour of the iframe stuff when I get round to it, but I think it looks quite groovey atm. So here it is, 3am and I’m waiting up for my incomings to appear so I can scrape ome def together for them whilst firefox is busy telling me I’ve spelt “colour” incorrectly and me verbalising at it to bog off. I’ve run out of beer but the pepsi stocks remain intact, I’ve got massive attack on the ipod, half a packet of cigerettes and I’m wearing sunglasses. I like my life :)
Join me tomorrow for the fun and frollocks of installing phpbb3 when ubuntu’s repositry version of phpbb2 is severely fucked in the ass.
Gnight all, stay funky.

P.S. trying to type this on an EEE whilst it’s within the iframe is endless fun ;)

 
0

mod_rewrite and the death of my sanity

Posted by Gabriel on Sep 7, 2008 in Uncategorized

So I decided temporarily to forgoe finishing the site in order to setup wordpress and attempt my first use of mod_rewrite to integrate the blog with the rest of my site, I had to choose a theme for wordpress that only consisted of one column in order to fit it in nicely with the iframe (I hate iframes but eh). This all seemed to go fine and I managed to get mod_rewrite to integrate internal links into the iframe I use.
Unfortunately trying to abuse mod_rewrite to accept a url as a parameter and put this as the source of the iframe doesn’t seem to work, it strips the http:/ off the front of the url and thus tries to access it as if it was local. I managed todo an ugly hack like this: RewriteRule ^links/http:/(.+)$ index.php?iframe=http://$1 [L] to make it work. I’m guessing something like // escapes the slash and thus only one is found. All seems to be working now, so yay.

Now to get back to coding ircbots to stalk people.

Copyright © 2010 Random Rantings of a Demented Mind All rights reserved. Theme by Laptop Geek.