Blog

Working too hard…?

For the first time ever, this week I have just crashed out from working too hard. Mostly from doing too much web design. So there you go, it’s not a surprise, but there really is such a thing as too much php. A shock, I know.

The error probably lies in the fact that my programme for the last week or so has been: get up at 6, do an hours web development, cycle 6 miles to placement, work in clinic as a medical student from 8 until 5, cycle 6 miles up hill home, and work until 11 on websites. At weekends that can just read, get up at 8am, work until 12 at night. Burning the candle at both ends (queue sample illustration).

Anyway, I’m taking some time out, and did a search for relaxing websites. This one is surprisingly relaxing, humour aside. Something just great about clicking, and watching someone else go through stress!

The next one is cool. Pretty sure its not lifesize, but its a bit like swimming with a blue whale anyway. That said, not sure how relaxing actually being face to face with a whale would be.

Finally the cheesy God one. But it is so refreshing to be reminded there is a place of safety to escape to.

Gonna relax, eat some nice food and read Clive Cussler books. And maybe take life a little easier in future…

A php twitter feed

I just made a new site – over at allaboutchris.co.uk (probably plugged that enough now), and I wanted to put on a personal twitter feed. But I didn’t fancy using the javascript plug in straight from twitter, for three reasons.

  1. I don’t like javascript.
  2. The javascript one has an annoying second or two pause whilst it searches for the feed, then suddenly appears, whereas my php has caching.
  3. The javascript one is invisible to search engines.

So, I got busy, and worked out how to do it. Then MaFt wanted to copy my code, so I thought, let’s help the whole world! The tutorial begins below:

This is all possible due to the joys of SimplePie a sexy little php number for parsing and caching rss feeds. Download it here.

So, to incorporate the twitter rss feed, first visit your twitter page, scroll down and click the “rss feed of “name”‘s tweets” link. Copy the address bar, which should read something like “http://twitter.com/statuses/user_timeline/18453541.rss”. That’s your personal RSS feed. Exciting, eh?

Now, at the start of your index.php page, put the following code:

<?php
include_once('php/simplepie.inc');
$twits = new SimplePie('http://punkonacross.blogspot.com/rss.xml');
include_once('php/twitter.php');
?>

First line includes the simplepie gubbins.
Second line turns the feed into a variable
Third line is what we are going to write now.

Go create twitter.php, and put the following text in:

//change the 0 and 3 to select tweets. 
//This is the first three. If you wanted the second three, choose (3,6)
foreach ($twits->get_items(0,3) as $blogitem):

$blogcopy = $blogitem->get_description();
$blogdate = $blogitem
->get_date('U');
$bloglink = $blogitem->get_link();

//sort out description

//lose the "bigonroad: " at the beginning - change to whatever your twitter username is
$lookfor = '/bigonroad: /';
$putback = '';
$blogcopy = preg_replace($lookfor, $putback, $blogcopy);


//make links links
$search = array('|(http://[^ ]+)|', '/(^|[^a-z0-9_])@([a-z0-9_]+)/i');
$replace = array('$1', '$1@$2');
$blogcopy = preg_replace($search, $replace, $blogcopy);

//make hashes links
$blogcopy = preg_replace('/(^|[^a-z0-9_])#([a-z0-9_]+)/i', '$1#$2', $blogcopy);

//sort out date
date_default_timezone_set('UTC');
$timenow = date('U');

//change blogdate to text
$difference = ($timenow - $blogdate);
if ( $difference < 1200) {$blogdate = "a few minutes ago";}
if ( ($difference < 2700) && ($difference >= 1200) ) {$blogdate = "about half an hour ago";}
if ( ($difference < 5400) && ($difference
>= 2700)) {$blogdate = "an hourish ago";}
if ( ($difference < 86400)
&& ($difference >= 5400)) {$blogdate = "a few hours ago";}
if ( ($difference < 172800)
&& ($difference >= 86400)) {$blogdate = "some time yesterday";}
if ( ($difference < 604800)
&& ($difference >= 172800)) {$blogdate = "days ago";}
if ( ($difference >= 604800)) {$blogdate = "ages ago";}


//print blog
echo '
'.$blogcopy.'
';
echo ''.$blogdate.'';

endforeach;

Not gonna explain it all – you have a brain. But basically, it gets the feed, works out what all the bits are, and adds s to the links – only “@link”s are automatically links in the rss feed, it doesn’t change “http://link.com”s and “#link”s for some reason.


Then it turns 08:10:20.10 08/10/09 into “a few minutes ago”. Feel free to delete that if you would rather have standard dates, or use other settings from the php date() function. If you want to add more stuff like “about 11 days ago”, just work out how many seconds 11 days is (950400), and put that into the equations.

And there you go, voila! See it in action here (okay, just one more plug).

Any questions, just comment!

Ah, that’s tweet!

The last few weeks, to my surprise, Facebook has no longer been my home. The thing I run to eagerly to check is Twitter. And when confronted by others, generally with the question “What’s so good about twitter?”, often quoting the ‘fact’ that 40% of tweets are mindless babble.

And I don’t know how to answer them, it’s kind of like asking what’s so good about staying in contact with your wife all day through text. It’s not so much that its good, but like texting, its soon as normal a part of your interactions as talking, or as writing a letter used to be.

That study probably achieves the opposite of your initial impression. First of all you think “Man, that’s a lot of pointless babble!”. And then you think, “How much of my normal everyday conversation probably comes under their definition of babble?”. The study includes things like “having chips for tea” as mindless babbles. I know that the majority of my texts, calls and conversations follow a what-did-you-have-for-lunch/where-are-you? pattern, which means probably about 85% of my words in those avenues are ‘babble’. After analysing the poorness of your own ability to converse, you are left thinking “Wow, twitter is actually considerably more succinct than ALL my other forms of communication!”

So there you go. Follow me on twitter, because I’m less likely to babble than if you meet, call, text or communicate in any other way with me!

Pretentious, moi?

I finally succumbed to that I’m-a-web-designer-and-I-have-a-personal-portfolio-site thing, and I’ve made a new site – its all about me, and found, unsurprisingly, at allaboutchris.co.uk. Shocking eh?

I would have liked chrislowry.com, but someone else already has that, and anyway, if I’m gonna have an ego site, I might as well make it blatant.

Give it a visit – feedback appreciated!

A new start

It seems very easy to let time slip away. I have such a wide variety of interests, including music, walking, painting, graphics, photography, web design, medicine, God and charity work. Fitting this all in, with socialising as well is not really very achievable, most of the time.

However, maybe today will be the start of something new?

An update, and finances…

Hey there. Been a fairly long time since the last update. First of all

New Housemate

Marian has moved in, which is exciting for all of us. That now means there are 4 of us (plus two dogs and two chickens). Please pray she settles in okay, and is happy.

Finances

We have been discussing the best way to deal with our finances as a community. We aim to live a life of community, as exampled in Acts 2, and thus the subject of money has to come up at some point.

42 They devoted themselves to the apostles’ teaching and to the fellowship, to the breaking of bread and to prayer. 43 Everyone was filled with awe, and many wonders and miraculous signs were done by the apostles.

44 All the believers were together and had everything in common. 45 Selling their possessions and goods, they gave to anyone as he had need. 46 Every day they continued to meet together in the temple courts. They broke bread in their homes and ate together with glad and sincere hearts, 47 praising God and enjoying the favor of all the people.

And the Lord added to their number daily those who were being saved.

The difficult question, is how to have “everything in common”? We are looking at everything from pooling all our money, outgoings and debts, to just being more open about finances. Prayer appreciated, as well as any opinions/discussions on the subject…

Names Not Numbers

Myself and my wife now help run a charity – called Names not Numbers. Please check out our new website! See it at: www.names-not-numbers.co.uk

That’s about it for now.
Thanks for reading!