Archive for the ‘Tech’ Category

Chirp

Thursday, July 26th, 2012 | Tech, Thoughts

Chirp is a fantastic new service that lets devices literally talk to each other.

Actually, by devices, I mean iPhones. It’s not specifically for iPhones, but that is the only client they have released so far. It does also work fine on the iPad as well though, so if you have both you can test it by getting them talking to each other. But anyway…

The idea is that a lot of devices these days have speakers and microphones – so rather than having to mess around with bluetooth pairing, instant messaging, emails that never arrive, etc, the devices could just talk to each other – using sound.

When you want to send a link, or a photo, or anything for that matter, you simply “chirp” it and your phone outputs a sound. Other devices listening in can then hear it and decode what it says. The simplicity of it is its brilliance – any device could talk to another, without having to connect, or pair, or any such nonsense. Finally you could share a link or photo to all your friends in the bar without having to mess around with some complicated system – even texting it to them requires you to have their number in your phone for example, but Chirp doesn’t.

It’s an amazing concept; you have to wonder why nobody has done it before.

One drawback I will note is that the devices are actually just communicating locations to each other – so rather than chirping a photo to each other, the photo is actually uploaded to Chirp’s cloud, then the device listening simply hears the location and goes and downloads it. This means all your data has to pass through Chirp’s cloud, which isn’t ideal, but as a chirp is inherently public to anyone who is listening in anyway, you should never use it to transfer private data in any case.

Killing zombie processes

Wednesday, July 25th, 2012 | Life, Tech

Zombie processes are very hard to kill, like cave trolls, but there is a way. We need to get the parent IDs for them and use those.

ps -Al
kill <ppid>

Install APD on CentOS 5

Thursday, July 19th, 2012 | Life, Tech

Here is how to install APD (Advanced PHP Debugger) on CentOS 5. Lets start by creating a directory for it to log files to.

cd /tmp
mkdir apd
chown apache:apache apd

We need to remove ioncube, or it will cause errors.

rpm -e php-ioncube-loader

Now we can install APD, via PECL.

pecl install apd

Add the following to php.ini.

[apd]
zend_extension=/usr/lib64/php/modules/apd.so
apd.dumpdir=/tmp/apd
apd.statement_tracing=0

My PHP binary was in a different location, so I had to alter the script too.

cd /usr/bin/
vim pprofp

Change /usr/local/bin to /usr/bin and save the file.

You also need to ensure PEAR is in your include path (/usr/share/pear) for the script to work.

LESS & SASS

Thursday, July 19th, 2012 | Limited, Programming, Tech

Still writing regular CSS? Pfft, you’re living in the dark ages! These days it’s all about two new technologies that are almost identical, so I’m going to discuss them in the same post.

The idea is dynamic stylesheets – bringing concepts we use every day in regular programming and implementing them in stylesheets to avoid duplication and make everything cleaner, nicer and more up to update with current paradigms.

So what can you do with these tools? Here is a quick overview…

Variables

Using a colour everywhere that you might want to change later? No worries, just save it as a variable and if you do need to change it at a later date, you just update the variable and it will be changed everywhere.

@myColour: #FFCC00;

.header { background: @myColour; }
.footer { background: @myColour; }

Mixins

Inheritance! What a sexy thing to have in CSS. No longer do you have to place loads of DOM references in lots of different places. Now you can just write it once and included it wherever else you need it.

.bigBorder { border: #FF99CC 10px solid; padding: 5px; }
.header { .bigBorder; background: @myColour; }
.footer { .bigBorder; background: @myColour; }

Nested rules

This one is a huge time saver! How many times have you had to reference half a dozen elements in one DOM reference? Probably very rarely, but certainly two or three tags is the every day reality. No longer though, because you can now nest your rules.

.header {
	.bigBorder
	
	a {
		font-size: 200%;
	}

In this example, the 200% font size will only apply to a tags inside .header, just as if you had done .header a in your DOM reference.

Operations

Want to make a header colour slightly darker? No worries, just add two colours together.

@mainColour: #FFCC00;

.header { background: @mainColour + #333333; }

But these are just a few of the features of these languages. They allow you to do a lot more – including things like full blown functions that you can pass parameters into, guards and much more.

The main difference between LESS and SASS is that LESS is a client-side JavaScript library (although has now been ported to Node) – you send the browser your .less file and include a JavaScript library that converts it. Meanwhile, SASS is a Ruby Gem that compiles a stylesheet to send to the client each time you edit your .sass file.

To find out more, visit the LESS and SASS websites.

Install memcached on CentOS 5

Friday, July 13th, 2012 | Life, Tech

First step, you’ll need to add the EPEL repository to Yum.

Once you’ve done that, you can install all the YUM packages.

yum -y install memcached.x86_64 libmemcache.x86_64 libmemcache-devel.x86_64 zlib-devel.x86_64

Then add the memcache extension to PHP.

pecl install memcache

Add the extension to your PHP configuration.

extension=memcache.so

Configure memcached appropriately.

vi /etc/sysconfig/memcached
add OPTIONS="-l 127.0.0.1"

Configure it as a service, and start.

chkconfig memcached on
service memcached start

Create permenant aliases with .bashrc

Saturday, July 7th, 2012 | Life, Tech

Sometimes, it’s easier to create an alias when working with the Unix command line. Having to create these every time seems to defeat the point of having a short alias though. Luckily, you can make them persistent.

Lets assume that we are using a user called mike. We need to be in our home directory.

cd /home/mike

The .bashrc file should be in there, but hidden.

ls -a

You should be able to see it listed. Now lets edit it.

vim .bashrc

And add a command in, for example, to save our usual CVS update command.

alias upd='cvs -q update -P -d'

Now save and exit. After that, every time you log onto the box you can use the upd command to run the CVS update.

Worfo.lk

Thursday, July 5th, 2012 | Limited, Tech

Inspired by Kieran’s recent registration of kjo.sh to use as his own short URL code, I decided to go on a bit of a search for any names which could be similarly useful.

Wouldn’t you know it, Sri Lanka happens to have a top level domain made up of the last two letters of my name – .lk. Seeing that the domain worfo was available, I’ve now snapped it up to form worfo.lk. Boasting an extra three letters on top of the minimum length of domain names, it isn’t the shortest short URLs in the world, but I’m more than happy to make the trade off.

Of course, please remember that clicking a worfo.lk link doesn’t guarantee you won’t end up on a web page containing hardcore pornography.

Installing GCC 4.4 on CentOS 5

Sunday, July 1st, 2012 | Life, Tech

If you’re running CentOS, you may find yourself frustrated that you have GCC 4.2 or older, when you need to be running at least 4.3 for some features – for example, if you want to compile HipHop for PHP.

Never fear, you don’t need to compile a compiler from source!

As well as the gcc RPMs in the repository, there are also a set for GCC 4.4, appropriately enough named gcc44 and you can install them in the usual way.

yum install gcc44 g++44

Using Apache Bench to load test your website

Monday, June 25th, 2012 | Life, Tech

Apache comes with a cool load testing script called Apache Bench, which lets you throw loads of requests at a URL. It comes bundled with Apache, so if you’re running the LAMP stack, you probably already have it.

The syntax is simple.

ab -n 1000 http://www.google.com/

This will throw a thousand requests at Google and then produce a report on how long it look. You can also use the -c option to set the number of concurrent requests. There are lots more options too – see the Apache docs for full details.

Less is more

Tuesday, June 19th, 2012 | Life, Tech

If you need to view a file on the terminal, the traditional way to do it is using more. More is fine. But less is better.

less filename

If is very similar to more, but has extended capabilities, for example you can go back as well as forward through a file.