PHP – Generate/Create strong passwords, uuid, random string

Very often the need to create passwords or some other ‘unique’ string be it a captcha or for use as unique identifier (UUID).

Here are a few functions I’ve used and refined over the years, 2 types, for password/random string generation and UUID generation.

Generating random strings is pretty simple as it’ll be a password.

However for a UUID there is always the slim chance it’s not unique.
Continue reading

Signs of poor PHP ‘products’

If you are a professional developer (or aspiring) you will inevitably get asked to customise or even better “extend” existing wares.

If it’s a product you are familiar with great! If not I heartilly reccomend spending a little time investigating prior to accepting a job ( ultimatley if they are happy to give

access to their code, if not atleast tell you what’s been used so you cam repliocate it to play with briefly). I know this sounds like a lot of work wich ultimatley – if you

don’t accept the job – you have done for free, but it will save you masses of grief, tears and late nights if you do.

So, I have a few pointers to ‘be aware of’ while evaluating the job and to (generally) identify crappy PHP products/solutions quickly…

Continue reading

Firefox horizontal jump between pages!

For a very long time I have always been annoyed by Firefox…

Have you ever witnessed the ‘horizontal jump’ cause by your content being taller then the browser size? And the effect is when you go between pages that are bigger and within you experiance a jump.

For ages I thought it was some problem with my own CSS, but today I discovered it’s because of the vertical scrollbar in Firefox. The above affect doesnt happen in IE as it always shows the scrollbar.

The CSS to make Firefox always show the vertical scrollbar is as follow:

html { overflow: -moz-scrollbars-vertical; }
html { overflow-x: auto; }

Dinner in Rick Stein’s – The Seafood Restaurant

Laura and I recently had a weekend break in Cornwall, and since we were there we decided to visit Rick Stein’s The Seafood Restaurant.

It had recently undergone a refurbishment – in fact this was it’s second weekend open – and from the outside and the dining room itself it looked very very nice.

As it was it’s opening weekend I could only get a table for 10PM, but I decided as we were staying down near St. Ives that it would have been too late for driving back… so we were able to get swapped to a lunchtime.

We had a choice of menus there was the A la Carte menu and a special Lunch menu – as it was it’s opening month. After looking through both – we could have eaten anything – we went for the ‘special’ menu.

So… upon arriving we were greeted by friendly staff, it was very busy for lunch-time, but the staff were appeared to be equally attentive to all diners. We were not rushed to order food so we had time to choose our food… and re-choose several times! We love seafood so could have eaten anything from the menu.

Our starters were; Seafood Chowder and Quinells of Gournard.

For mains… I has Singapore chili stir-fried whole crab, while Laura had Roasted Turbot with Sauce Vierge.

To finish we had, Apple Tart Tatin and the Chocolate Fondant.


My Rating (each out of 10):???????? ????? ???????????????? ????? ????????
Food 9 | Service 9 | Atmosphere 9 | Value for money 9 | Overall 9

SEO/SEM and the quality of your web traffic…

The people we (web designers/developers) create work for are always really interested in web traffic – LOTS of web traffic. But there is one thing that many web designers/developers and even our clients don’t consider, is the quality of traffic.

We (developers & clients alike) love counting page-views and unique visits but from my point of view, if the traffic you are attracting is poor, who cares if you get thousands of visits a day!

How can we determine the ‘quality’ of web traffic?

  1. Length of their visit…
  2. If you sell a service/product what your ‘conversion rate’ is…
  3. How many bookmark/’add-to-favorite’ your website.
  4. How many people visit your website by directly typing in your web address.

Continue reading

Choosing a SEO/SEM friendly domain name…

NOTE: SEO is the acronym for: ’search engine optimisation. Which is the process of making your web pages more search engine ‘friendly’ by optimising the code and content.

Choosing the correct domain name for your site generally has a big impact in terms of how it affects your positions in the search engines and your overall traffic.

THERE ARE 3 CRITICAL FACTORS, YOUR DOMAIN NAME…

  • … should contain key words.
  • … should be as short as possible – easy to remember & easy to type in.
  • … can be better off as a .com over say a .net, org etc …
  • … consider localisation of the domain… i.e. if you want it to do well in the UK .co.uk etc etc…

Continue reading

Creating good passwords…

Recently I was reviewing the security practices for my users…

I like to get them to change their windows login regularly as it’s used via LDAP etc etc in some cases for loggin into web applications…

Anyway… all the passwords I keep getting from them are very poor, and so I put some guide-lines together for them and thought it’d be fun to share.

I suggest – actually force them – to include characters from all 5 of these rows in passwords…

0123456789
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
@#$%^&*()-_+=
~`[]{}|\:;’<>,.?/

Doing this will increase the time it takes to get cracked… Now… if you want a really really great password do the above and include an alt-character or two! Here is a table of them:

ALT-Characters

Music from your iPod…

If like me you manually add to your iPod, then it can be a real pain when iTunes decides it doesn’t want to recognise your iPod anymore, or you decide to get a new one or just want to get a song off there!

I recently came across EphPod (Win/Linux)…. and since I also have a MacBook Pro found iLinkPod.

I am not going to describe how to use it as I did find a good tutorial here. If you insist … here is a very quick ‘How-To’ for EphPod: find the music you want using the search boxes at the top, or the grid at the bottom for individual songs, and then Right Click and select ‘Copy Songs to Directory’, or alternatively press Ctrl + Alt + C. Holding Ctrl while selecting will allow you to choose more than one song/album/whatever at once.

Dynamically sorting by a column in a Stored Procedure (SQL Server)

Have you ever needed to build a stored procedure that would take the name of a column as a parameter, and return the results ordered by that column?

So have I, so after researching it for a couple of days, and none of the forums had any good solutions; All that he was able to find was a reference from Microsoft that said that the only way to do it was to build your SQL statement dynamically as a string in the stored procedure and EXEC it (not very good, considering it wouldn’t be able to leverage the T-SQL code optimiser – you’d be as well building it in your given language). I spent some time working on this and came up with a much better solution. There is a way to accomplish dynamic column sorting, while still leveraging a fully compiled and optimised stored procedure.

Microsoft says that you can’t use a variable for the column in an ORDER BY statement, and most attempts gave us a “can’t convert this value to an int” error. There is a way to make it work, though.

Consider a table:

ID int,
FirstName nvarchar(20),
LastName nvarchar(20),
ApplyDate datetime

We want to call a stored procedure, passing the name of the column that we want the records to be sorted by:

GetApplications(@SortField nvarchar(20))

Here’s what the T-SQL stored procedure definition looks like:

create proc GetApplications
@SortField nvarchar(20)
as
select * from Applications
order by
case @SortField
when 'FirstName' then cast (FirstName as sql_variant)
when 'LastName' then cast (LastName as sql_variant)
when 'ApplyDate' then cast (ApplyDate as sql_variant)
else cast (ID as sql_variant)
end

That’s it! Be sure to put the ELSE clause in there as a catch-all, so that you handle columns that don’t exist or typos in the value passed into the stored procedure.

You also need to cast all the values to sql_variant so that the ORDER BY clause won’t get confused about the type of the column that we’re sorting by, and try to force our values into an int.

This is tried and tested SQL Server 2000, and it works just fine. No promises for expermmenting with older/newer versions!

I’m always looking to improve my own SQL (SQL Server, MySQL are my main databases but always keen to learn new things too!) knowledge… so contact me if you have other hints or tips!

iMovie ’08 and iDVD…

OK, so I’ve been using my Mac for a while now… and I must admit it has grown on me hugely over the time I have used it – I was sceptical about using a Mac, but I do slightly prefere it now. Due to software I use for development I’ll always be a dual user just some things I need the PC for – anwayway… I’m here to talk about iMovie ’08.

I’ve done some video editing in the past on the PC, and Mac using professional stuff… however I was viewing my growing pile of MiniDV tapes for my camcorder and decided I should get them to video/dvd. Not wanting to spend hours/days editing I decided to try iMovie. I’ve never used it so I went in cold and was surprised and very happy with my end product – between iMovie and iDVD that is.

First step was to import my video, which was very easy and ‘quick’ though i did have to watch it play in realtime as it imported – perhaps there is a way to do it quicker?

After that was done, it was pretty simple to move my clips to edit them and compose them … it is very simple and as a result there is obviously a loss of control if you are used to Final Cut or similar on the PC… but if it’s just to get that holiday footage tided up and onto dvd then it’s probably more than sufficient.

After some resizing of clips, I became adventurous and – gasp – added titles and transitions (though not too much of these as I decided they were a bit corny) … next I added some music to liven it up.

So to create my wee video of a recent trip to Dubai, took (excluding importing time) just a little over an hour to compose, and a matter of moments in iDVD.

Burning the DVD in iDVD was quick and painless too… pick a theme, drop the movie in, give it a title and click a button and that was it really.

I was paranoid about quality… video on a computer in my past experiance was never that great. So I tentativley shoved it in the DVD player and was very happy with the resulting video. If anyone knows a good FREE resoource to upload video too I may upload some later.

One of the odd things in iMove is there is no need to save, but it does indeed save as you go – I quit a few times to test it!

iMovie

Dinner at Gordon Ramsay at Claridges Hotel, London (Review)

Recently we have had the pleasure of dinning at Gordon Ramsay at Claridges Hotel in London.

There were 4 of us dining, Laura, my parents and I.

We started the evening in Claridges off with a cocktail or 2 in the lobby/lounge. Now being Claridges you expect it to be posh, but by having this expectation it was just as I envisaged… it was posh, but in a subtle and relaxed way. The cocktails are very nice… and considering the venue I think reasonably priced – I enjoyed my pre-meal Singapore Sling and the others had a simple G&T. The nibbles provided were a good indication of things to come… they were simple but elegant and one (the toasted cheese) unusual but turned into my favorite very quickly!

We moved through into the dining room and it was again tastefully decorated, and not oppressive as it can be in some other similar establishments. The general atmosphere was calming and the lighting was subtle but still enough to see the plates!

Before our starters arrived we were given a plate of canapés – which were delicious, there was a selection of bite-sized spring rolls, fish cakes and breads. We were then given a tomato and cucmber soup drizzled with olive oil – very refreshing and cleansing before our meal.
For our starters 3 of us had the Fois Gras, one was a Mosaic of foie gras and Goosnargh duck with Red Pippin apple and walnut salad, toasted brioche and the other was more traditional – Roasted duck foie gras with macerated cherries, pickled ginger, cauliflower and almond cream (I had this, but there were nicer things on the menu which I would have enjoyed more, but it was still very very nice!), and Laura’s starter was Ravioli of Dorset blue lobster and salmon poached in a lemongrass bisque, basil vinaigrette.

For mains, Laura had the Pan-fried Mediterranean stonebass with Cromer crab and celeriac cannelloni, summer vegetable blanquette, lemon thyme velouté which was delicious, my Mum had a steak (not very adventurous, but it was a very nice piece of meat!) while my Dad and I both had the Roasted John Dory and sautéed langoustines with violet artichokes, pink fir potatoes, carrot purée and a light fennel cream. I was very happy with my main – however I am probably being greedy and think there could have been another bit of fish and one more langoustine. Laura was delighted with her meal and portion wise was ample. My Mum & Dad both also enjoyed their respective meals.

After this we were given a peach soup with rasperry sorbet mouse then it was onto desert, Laura and I both had the passion fruit creme brule – it was divine, my mum had a hot chocolate sponge while my dad opted for the huge selection of cheese from their trolley – the wedged returned to him were ample too!

The wine list was like vast and ranged from £23 per bottle to over £2,000!!!

In summary, the food was very well presented, portions good (but on the edge of small) but it was quality not quantaty. Will we return? Probably! But it would generally be for a special occasion, and we’d also plunge for a room at £300+ for the night too – you might as well go the whole hog! The staff were second to none, very friendly, happy to talk and treat you with class…

My Rating (each out of 10):
Food 9 | Service 10 | Atmosphere 9 | Value for money 8 | Overall 9

Brian M McGarvie talks about … life and experiences in IT … and personal adventures and experiences and other odd things!

Get Adobe Flash player
%d bloggers like this: