1st Class Media is a Midlothian-based web development company, 8 miles South of Edinburgh in Scotland, UK. We like to share ideas, technical or otherwise which can be of use to others or pique the interest of people similarly minded
Tuesday, 24 January 2017
Edinburgh estate agent - cameron stephen and company
Having worked with Cameron and his team for nearly 7 years, they always come across as ambitious but not aggressively so and thus maintain a sense of decorum and integrity which, frankly, is missing with so-called "budget" estate agents. I often catch a glimpse of clients that arrive and are dealt with in an engaging and friendly manner - again something I strongly advocate as the best way to do business. If you are a first-time property buyer in Edinburgh, then I would have no reservation recommending Cameron and his team as your primary port of call - they just know and understand the frustration and lack of confidence that first time buyers experience within the modern property market in Edinburgh.
Give them a call on 0131 555 1234, you'll be surprised how little selling or buying your property can be!
Sunday, 22 January 2017
Healthcare staff + care supplier in Edinburgh
When it comes to providing an experienced view on the supply of healthcare staff No1 Healthcare take a pragmatic view and offer a keen eye on the detail of the type of person you want to have in place. They have a large pool of trained and experienced nursing, care and domestic staff who can provide outstanding coverage for a single shift through to several months cover - whatever suits your needs.
Why not give their team a call on 0131 624 8989 and see what they can offer?
Sunday, 19 July 2015
Structural Engineer in Edinburgh
Accurate structural designs are essential to the protection and long-standing structural reliability of complicated and simple designs in a similar way. We trust on the work of a structural engineer every time we enter a building, cross a bridge, enjoy a pleasure park ride, or run water through a powerhouse. We trust that the engineer had the experience and knowledge to provide practical, safe plans.
Structural engineers are experts in building structures and know how to keep buildings stable and straight without excessive use of materials. They can make use of their expertise to prevent expensive and dangerous mistakes. They will also use engineering formulas connecting to material properties and physics to design structures which will tolerate all the services of that particular structure.
We are fortunate to count the company AED leading Edinburgh Structural Engineers as one of our clients and are using this article to promote the services of this company through our blog.
Sunday, 8 March 2015
Audio Transcription Service - another 1st Class self-promotion!
Audio Transcription is one of those specialist services which we all think is pretty easy to get done, we record something, a conversation, an interview or something else (see below) and it can seamlessly be typed up by someone who can touch type in next to no time.
Pah! (collectively the team yells in my ear) Actually, (and now speaks the educated voice of hearing what is involved) it turns out to be a somewhat more convoluted than that. If you have ever tried to transcribe yourself you realise quite quickly that ("hold on, this is taking bloody ages") that this 15 minute phone call has already taken me an hour to stop and listen, type (badly) and then continue. As a rule of thumb it takes 4-6 hours to type up a single hour of audio recording, and it doesn't stop there - it also depends on the quality of recording (aside: who the hell records a letter underneath a railway announcement tannoy speaker, oh I know, our clients, that's who!), the number of speakers (especially if it's a lively debate with animated speakers and counter-speakers, sometimes silly grins appear on transcriptionists faces as they type, we smile and nod, no other words need to be said - yes, we know) or the dialects. Believe me we've had a fair share of inquiries which have had broad Brummie accents speaking at 200 miles an hour all of which was recorded on a handheld recorder about 12 metres away in the corner of a meeting room ("what do you mean the quality's non too good??")
So, that probably enough for now, shameless self-promotion aside, spare a thought for the hard-working members of our team who turn around audio recording transcription, we do our best but sometimes it can be a challenge!!
Monday, 26 January 2015
Fixing FcgidMaxRequestLen Plesk 11/12 - file upload hell
(side point) I may as well mention at this point, the server we purchase from 1&1 Internet is a Plesk Control Panel which is fine until you want to do major customisation. In the past if you made changes to the core php.ini or vhost.conf file you would find it was overwritten each time a Plesk update was implemented or for whatever reason re-compiled. Latter versions of Plesk have made it easier to manage this by placing safe copies of localised conf files in a new system sub-folder, but still a pain when you don't know where to look!
Older versions of Plesk = /var/www/vhosts/{your-domain}/etc
Plesk 11+ = var/www/vhosts/system{your-domain}
But this is an aside and largely only confined to php.ini changes.
Our local php.ini file which seemed to pickup the changes which were identified within it when running the phpinfo() command showed the custom settings
set into the php environment
So, with these settings in place we proceeded to attempt to upload sound files. No luck, and didn't even get errors so were completely in the dark.
We got an nginx error was identified as a PHP framework issue and that was fixed during which we set the log files to be in the root of the vhost file which, on Plesk 11 + looks like this
So, each upload then started throwing a common line based on a configuration entry which looked like this:
[warn] [client ip address] mod_fcgid: HTTP request length 134220467 (so far) exceeds MaxRequestLen (134217728), referer: name of script running the upload
OK so did more googling and found lots of results for newer builds of apache running with a low limit of 128K per upload, so duly followed these and updated the:
/etc/httpd/conf.d/fcgid.conf and added the recommended lines:
MaxRequestLen 2147483648
FcgidMaxRequestInMem 2147483648
Which covers the earlier version of fastcgi with the MaxRequestLen entry and newer modules with the FcgidMaxRequestInMem entry, both of which were set to around 2Gb.
Did the same with the vhost.conf file located in /var/www/vhosts/system/domain-name/
adding the following block:
<IfModule mod_fcgid.c>
MaxRequestLen 2147483648
FcgidMaxRequestLen 2147483648
</IfModule>
again covering both sets of bases by declaring the values to be in excess of the limit in the error.
Nothing, still getting the upload error with the same old:
[warn] [client ip address] mod_fcgid: HTTP request length 134220467 (so far) exceeds MaxRequestLen (134217728), referer: name of script running the upload
OK so what the hell is going on here? I'm restarting apache and even the nginx and psa services to make sure it's bringing the new configurations online.
Back to the php.ini file, showed the localised settings were all working fine.
Time to get to grips with grep - seeing that the value we were all the same I ran a grep command to see where within the main system settings there was an occurance of this value:
grep -r "134217728" /etc/ which will recursively search for all occurances of the phrase "134217728" in all files.
Lo and behold!
I see a new entry which is located in /etc/httpd/conf/plesk.conf.d/ip_default/ called
domain-name.conf (e.g. abc.com.conf)
Opening this I see that there are two lines within the conf file which read:
<IfModule mod_fcgid.c>
FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/transcription.1stclass.uk.com/etc/php.ini
FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
FcgidMaxRequestLen 134217728
</IfModule>
and a second and apparently duplicate entry:
<IfModule mod_fcgid.c>
FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/transcription.1stclass.uk.com/etc/php.ini
FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX fastcgi
FcgidMaxRequestLen 134217728
</IfModule>
Modifying the red text entries to be 2147483648 and restarting apache
service httpd restart enabled us to upload large files.
So, lesson learned, if you are using Parallels Plesk Control Panel and need to change a commonly used entry, do yourself a favour and use grep to locate localised (or Plesk controlled) versions of module configurations - it's better than ploughing through 100s of Google searches (none of which suggested this at all!!)
Happy Grepping!
Sunday, 11 January 2015
Freight Forwarding and Logistics - another shameless client promotion!
T ward is a company of some standing in the shipping world, having been around the business for over 100 years they provide a wealth of knowledge for freight forwarding and logistics for numerous clients around the world. Being a complete luddite and also nosy in the same measure I felt a little out of my depth when it came to knowing what made freight forwarding a service at all! With Callum and Nigel's help I was suddenly propelled into the complex and hitherto completely unknown world of international shipping and logistics.
When you imagine these monstrous cargo ships coming in from China or Japan you think, "ok one of those gazillion containers probably contains my next TV" but the scope of the shipping exercise is massive and I ended up applauding the Freight Forwarding guys as they deal with numerous elements which comprise the whole process of logistics as well, including:
- Customs clearance
- Haulage and Transportation
- Storage
- Payment of duty
- Freight and related expenses
In summary, if you are looking to ship cargo worldwide, then get in touch with a reputable, experienced and knowledgeable agent such as t ward shipping, they really do know what it's all about, and heaven knows, it's a lot!!
Thursday, 20 November 2014
Sports Retail Management - client branded clothing website
This website is a brand new one for us, working closely with the client we created a combination site which has a public element to it coupled with a fully functional client extranet. The client Sports Retail Management, came to us with a simple remit, allow our local authority clients to log onto the website under their own account and create garment orders. "Is that it?" Well, kind of... It then transpired that some clients have some discounts afforded to them based on the level of purchasing they do.....ok, that's not a problem. Oh and each garment can have several colours and sizes. Yeah that's fine. Except that some sizes have different pricing models.
OK so this project started to look a little more complicated than initially envisaged so we started to look at how the system would work in the hands of the user, we started with a skeleton of the functional elements and imagined (note that) what features might be useful for the Authority users.
Side note: we pride ourselves on (mostly) listening to our clients regarding what they want and adding value to the systems we develop to make them as intuitive and user-friendly as we can. One of the things we have learned is one, don't overthink something - brainstorming something is useful but only come to conclusions if you are sure the end-user will see and use the value of your efforts. A number of times I've seen projects (which we have inherited) with loads of bells and whistles, so many if them in fact that you can't get to grips with the underlying functional purpose of the project. A developer who can see the actual value (rather than perceived value) and then apply this into functionality is worth their weight in gold, every time.
So, back to the story, we sat down with the end user and asked them what they would use. This was an eye opener - it's all too common to hear our client ask for this and that, without really knowing what their client would see as the priority feature.
In this case there was a large degree of overlap, with one or two things which the client in particular wanted which were not mentioned at all during the development specification phase.
So a lesson learned, not in an accusing manger it's just that sometimes you would be best advised speaking with the end user as the client, like you, will only imagine what can be the best features for a site which is heavily used by clients.
There endeth the lesson...
Saturday, 20 September 2014
Doing the backup shuffle - removing backups with PHP and CRONTAB jobs
Now, I run a script (like the one I explained in an earlier post for Scheduled SQL Server Backups ) which like most good ideas for backups, takes them away from the actual server - it never ceases to amaze me how some people consider a backup to the same server as the database as a valid way of performing incremental backups, anyway...so I have the SQL files backed up offsite, fine.
However, the database files I have backed up are becoming quite..chunky in size, one bumping the Gb mark and a few others climbing in size as content and complexity are added. This can cause a problem on the server I save the backups to, as I only pay for a limited amount of disk storage space and to be honest I (and my clients) will be unlikely to want to retrieve or restore a database which is older than a weeks worth of daily backups so I needed a way of easily trimming the list and keeping the backup number at a manageable size.
Getting the plan together
So looking at the specification of what I wanted to do:
- list the files I want to examine
- identify those older than 5 days
- delete them
- send me an email to let me know the task ran ok
- commit the job to Crontab
$dateminusone = date("Y/m/d", strtotime( '-5 days' ) );
$list = glob('*.zip');
usort(
$list,
create_function('$a,$b', 'return filemtime($a) - filemtime($b);')
);
foreach($list as $file)
{
$filemoddate = date('Y/m/d', filemtime($file));
deloldfile($file,$filemoddate,$dateminusone);
}
sendconfirmation("me", "my email address");
breaking it down
$dateminusone = date("Y/m/d", strtotime( '-5 days' ) );
sets a variable to set a time to delete back to:
$list = glob('*.zip');
the PHP5.3 function "glob()" allows us to list files of a certain type in a particular folder
usort( $list, create_function('$a,$b', 'return filemtime($a) - filemtime($b);'));
I used the usort element in the script as I initially echoed the list back to the screen, but it was a handy way of listing the items in date ascending order according the modified time functio: filemtime(). After creating the usort array of files we iterated through the list with the foreach() loop and ran an internal function to delete the file
deloldfile($file,$filemoddate,$dateminusone);
If we look at the function deloldfile() in its glory we can see that it does a quick check on the modified date versus the set date and if it's older, it's deleted:
function deloldfile($file,$mdate,$startdate){
if( $startdate>$mdate ){
unlink($file);
#echo "marked for deleted";
} else {
#echo ":)";
}
}
Once that's done and the loop is complete, we just ping an email to me to tell me that it ran ok
sendconfirmation()
The function which emails me is a simple little SMTP email script which makes it more likely to be sent through an authenticated email account:
function sendconfirmation($name, $address){
$email = 'emailaddress;
$name = 'backup task' ;
$subject = 'SQL backups deleted successfully' ;
$content = '<html><body style="font-family:arial, sans-serif; font-size:12px">The SQL backup delete task ran successfully on :'.date("D dS M,Y h:i a",time())."<br />";
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp_mail_server_name";
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Port = 25;
$mail->Username = "smtp_email_address_account_name";
$mail->Password = "account_password";
$mail->SetFrom($email, $name);
$mail->AddReplyTo($email, $name);
$mail->Subject = $subject;
$mail->MsgHTML($content);
$sendaddress = $address;
$sendname = $name;
$mail->AddAddress($address, $sendname);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
}
}
This uses the excellent SMTP PHPMailer library and I've never had any problems with this script.
Placing it all together and we have a working script which runs perfectly, so how can we automate this? We will create the Linux version of a Scheduled Task through a cron job. As my servers run off Plesk and Centos the UI is presented quite nicely and so long as you do the right set up of the task you should have no problems.
Creating the Cron Job
In Plesk the cron jobs are set up as "scheduled tasks" under tools and settings (10 & 11)
Click on Tools and Settings and then Scheduled Tasks and then set one up as the Root user (I've found problems can occur when running system commands as other users)
Click on Add a Scheduled Task and you should see something quite daunting like this completely unhelpful screen:
A personal word here, I've come to conclusion that Parallels and Plesk vendors do not want any old wannabe to access system things like tasks so they seldom offer any advice for setting them up: if yo mess it up then they have no wish to be held to account.
So setting up a cron job needs a little further explanation:
* means ALL THE TIME
that's the main explanation over. Seriously though, if you place * in all the fields for times the task will run EVERY minute until doomsday (or your server dies whichever is sooner) so you need to give some serious consideration to the frequency you want to execute the task.
For my situation, I wanted to run it once a week, around 11.00am on a Saturday so I have this:
This means that a 1 minute pass 11.00 every month on a Saturday my command will be executed.
So the command (my URL is blurred out) is:
/usr/bin/wget -O - -q http://URL_TO _RUN_FROM/deletebackups.php > /dev/null 2>&1
We want to run a command so we'll fire the WGET command line utility to open a fully declared web page ( A word to the wise, I attempted to set up cron jobs which fire a URL type command and have only ever got this to work well with WGET at the command line)
/usr/bin/wget because in the server these command line utilities tend to reside in the usr/bin folder
There are a number of switches which are available to append to the WGET directive, we are using:
-O - -q
-O : we need to tell the script that it will expect a file to have to interact with
-q : we want to run it in quiet mode, we don't really care what the response is as that is captured by the email alert at the end of the script
http://URL_TO _RUN_FROM/deletebackups.php kinda obvious but a fully qualified domain name and executable script
..and finally, your friend:
> /dev/null 2>&1
If you leave this out and your email address is the root address for your server you will get an email each time this script runs, not a problem if you are running it weekly, but some of my scripts run each 15 mins, I personally can't be bothered with getting emails each time every scheduled task runs!
Add in > /dev/null 2>&1 and this blocks in default email owner function.
Save that job and let it run!
Wednesday, 3 September 2014
Chunky iPad cover for little handies...
Enter "fatframe" - an easy to insert iPad children's cover which when she showed me it in action had me initially horrified and then impressed, horrified as she proceeded to drop it down her stairs ("it's an iPad!!") and then really very impressed when it was fine and none the worse off for it's brief journey.
Fatframe really does seem to have found itself a niche, as we are all acutely aware, iPads are not cheap, and whilst the iPad case itself won't protect against the face being dinged against a table corner, an inadvertent tumble onto the garden path, down the stairs or on a tiled kitchen floor (ahem, personal experience) will give it a little more chance of being saved from pricey screen replacements or, worse case scenarios, a brand new device! Less that 10% the cost of a new iPad, no brainer as far as I'm concerned!
Pop over to the fatframe website and see what they offer - there's a stand for tea time viewing and a forthcoming seat attachment and waterproof cover (don't get me started on that one - iPhone/stand up toilet visit/not enough hands, let's leave it there...)
Wednesday, 9 July 2014
jQuery, the beautiful and the ugly
Even with the "live" or "on" functionality of jQuery I was finding it tough to get a large number of images to pick up the functional click events and transfer those to internal status changes within the array of images which were being looped from the system folders as well as the database. It all got a little too much to handle.
I was faced with a dilemma, do I unpick all the jQuery code I had assembled to rationalise it (it WAS doing what I wanted to do it just wasn't updating internal flags or try something else?
In the end, it was clear that if I reloaded the page following the click event, the internal status flag was then being picked up and the change was visible. So instead of an asynchronous call to the status handler, why didn't I just reload the page?
Well, dear reader, that's what I did - I'm not proud but by heavens it saved me another 4 hours of coding time!
An example is here (snippet)
$(".removefromgallery").live("click",function(){
var imageref = $(this).attr("rel");
var imagefile = $(this).attr("id");
//alert('id = '+ imageref +', image name = '+imgname+', image file = '+imagefile); return false;
{
//return false;
var dataString = 'img='+imagefile;
//alert (dataString);return false;
$.ajax({
type: "GET",
url: "remove.php",
data: dataString,
success: function(response) {
location.reload(true);
});
}
});
The location.reload(true) function simply reloads the current URL in it's entireity (complete with querystring values)
Sometimes, simple does cut it!
Friday, 23 May 2014
Loading Remote Content into Bootstrap Modal
On the surface of the system looked very easy: declare a target in the href and of you go (go to http://getbootstrap.com/javascript/#modals for a summary:
<button class="btn btn-primary" data-toggle="modal" data-target="#modaltoopen">open</button>
This will style up a simple link as a medium sized blue button which when clicked will open a modal window if the following code is enclosed in the body:
<div id="modaltoopen" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
</div>
</div>
</div>
<!-- Small modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
...
</div>
</div>
</div>
OK, so good so far (assuming you've also included the bootstrap.js and css files in the same page.
But what if you wanted to pull in a bunch of data, say if you had a loop for a series of records from a database. In our example we have a bug tracking system which looks a little like this:
so that when the blue button is clicked on we can pull in a template page into a modal dialog to let the user see the content of the bug reported, thus:
Remote Content
Supposedly, pulling in a page is an easy process, and to be honest it is but with a few caveats. If you want to access a URL you should just apply an href into the link and this will in turn grab the page and place it into the modal pop-up.
Something like this:
<a data-toggle="modal" href="loadbug.php?id=<?php echo $ibugid; ?>" data-target="#modeltoopen" class="btn btn-xs btn-info">view info</a>
This works fine, except that identifying the modal popup in the data-target attribute does exactly what it should, it adds the content into the modal pop-up but overwrites everything in the modal:
What this does is effectively grab the content from the remote HTML (or this case PHP) file and replaces the modal content with the HTML. What's wrong with you might ask? Well the problem with this is that we really want to preserve the pretty modal title and close buttons but there doesn't seem to be a real way of dynamically writing this into the script other than performing a hack to the modal.js functionality.
OK so how do we achieve this? You want simple, think simple. If we need to have the modal title and close buttons, do they need to be dynamic? Probably not. In that case why not add them into the remote page which we are calling?
For example the remote HTML from that basic modal looks a little like this:
<p>Bug Reported on {date}</p>
<p>Platform: {app system}</p>
<p>Reported by: {user}</p>
<p>Description:</p>
<p>{details}</p>
but if we wrapped the modal attributes around that we would have:
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<p>Bug Reported on {date}</p>
<p>Platform: {app system}</p>
<p>Reported by: {user}</p>
<p>Description:</p>
<p>{details}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
So ultimately we see that the content we draw into the modal dialog can have the nice features without too much of the hard work!
For more examples of our web development work, drop us a note or get in touch through our website.
SMALL AMEND:
Noticed that once called the modal will keep the first call's data in the modal content div so to get the modal dialog to dump the central body of the remote content each time it's closed, it's best to force a little data removal, thus:
<script>
$(function(){
$('#myModal').on('hidden.bs.modal', function() {
$(this).removeData('bs.modal');
});
});
</script>
All better now!
Sunday, 11 May 2014
500 error with osTicket installation on Parallels Plesk panel
One the funky application bundles we've come across is osTicket. a neat little ticketing system provided by the lovely people over at www.osticket.com. This Open Source system seems to tick all the boxes as far as our needs were concerned for an independent project and seemed to be a doddle when reading through the installation of the version we wanted (v1.8.1.2) so we took a look at the local catalogue version which came with Plesk and thought - that'll do us.
The thing about the bundled applications with Plesk is that they do somewhat "take care" of the installation which bugged me a little bit as I wanted to have little more control over the installation.
So of I headed to get the local version of the catalog (APS) application and started the install. (btw this assumes you've set up the subscription into Plesk and have a domain mapped etc)
Wednesday, 9 April 2014
The Queens Hotel a family Hotel inverkeithing, Fife
Enter the Queens Hotel in Inverkeithing, Fife. This hotel offers the perfect solution for a small meeting through to extended family get togethers, with capacity for around 50 people in its largest function room.
The Queens Hotel prides itself on being a family hotel serving the local community for family needs - it isn't "grand" in the true sense, nor will they charge "grand" prices, but the family who run the hotel recognise the need for a family-friendly venue for getting together. They cater for post-funeral teas and buffets which allows you to time to reflect without the worry of organising catering, venues and drinks - the team at the Queens Hotel are very professional when it comes to this.
So there you have it, small bit of praise for a small family hotel which punches above its weight, run by a dedicated family team for local families in Fife - get in touch with them if you want a cost-effective family venue for your function, whatever it may be.
Monday, 17 March 2014
Is it too late to ask?
OK, so this post is called "is it too late?" It's been spawned from one of my newest findings - how long can it be left when someone's referring to an acronym to ask wtf it stands for?
I often deal with IT companies and Financial Directors (FCO or FD) who are particularly prone to using acrnoyms whenever they can - either it makes them look good or they genuinely are using acronyms to save time (LDAP, SBS, VCIO and more latterly DPA and PCI DSS). The thing about these is that because they are quite short they can be misinterpreted as incorrect full names. My example is DPA (Data Protection Act) which must be a royal pain to long serving organisations such as the Dudley Performing Arts or David Powell Associates, both who may well have been around longer than the Information Commissioners office.
My real concern is a very personal one, known to me as the Golden Minute - when you're in a meeting with new clients who want to impress you with their knowledge of the industry (normally web design and development which has started employing its own set of acronyms, don't get me started on LAMP, MVC or the exciting ones of CRUD, CRON, AJAX or CVS/SVN - more at http://1cm.me/EWBZz ) and then start mixing up their acronyms and creating their own versions which make little or no sense. What would you do? Normally I would interrupt them and correct them gently but if they're in full flow it can be a little uncomfortable to do this so you then adopt the professional approach of "storing" the acronym and then try NEVER to use it when delivering your reply.
No, the bigger issue is how long do you leave it before you can't ask what the heck a WRPM is, I've determined that the lower on the keyboard the acronyms letters exist, the less chance you have of guessing the damn thing. It can be quite an interesting and occasionally humourous game trying to "guess" what the acronym stands for. Tread carefully Reader as you have entered the Golden Minute. What happens now is that if you don't raise your hand and make it clear you want to know what WRPM stands for (it's nothing to do with Linux Distribution either, nice guess!) you have about 2-3 minutes to sit it out and try to guess what it means before you reach the metaphorical Acronym Rubicon - the point of no return. If you don't 'fess up and ask what it stands for, you can't now ask, all credibility will be lost and you will lose boardroom face, no you will need to struggle on manfully and then proceed to dodge all WRPM-related questions. Heaven forbid someone from the other side of the table asks what you think about the issues "with the context of WRPM-linked progress". You will be unable to ask any questions about the acronym now. The worst thing will be now trying to guess frantically around what the full term should be as you will look like a complete numpty.
My father was a soldier training cadets in the radio phonetic alphabet (alpha, bravo etc) and asked one young guy to spell his surname phoentically (Lawson in case you were wondering). So the poor guy did exactly what you shouldn't do, he guessed. The correct phonetical pronunication would be Lima-Alpha-Whisky-Sierra-Oscar-November, clearly the cadet had glanced over this chapter but taken very little on and proceeded to announce, "Sure Sarge, it's...erm.....Lima..?...Alpha....Whisky...(long pause, click of the fingers and boldly announces)...September, October, November...!" Short spell washing some tanks gave him time to think it over...
So the conclusion of this tale is for heavens sake, if you aren't sure what an acronym stands for, it's not a failing to ask - it'll save you time in the long run...
TTFN
Thursday, 6 March 2014
Time savings through auto-posting to social media
If you have spent hours copying messages from one website into another and then having to push the information across to the social media networks, we may have the solution!
Twitter and Facebook are obviously keen to make sure people "stick" with them and create APIs (application programming interfaces) in many scripting languages which can assist with getting your news into their frameworks. We have simply harnessed this in a meaningful way through our CMS (content management system) which will make the whole process straighforward.
For automatic news updates to social media networks, drop us a note and we'll share the love!
Thursday, 17 October 2013
Automatic FTP backups of SQL Server Express
The thing that I wanted (I don't ask for much!) was for cumulative, sequential backup volumes to be created on a daily basis and then pushed out to a remote FTP server which I know is backed up offsite as well (a double backup if you like)
So, what's the principle? Simple really, I run a scheduled task on the Window VPS each night when the database is quiet (normally after 9pm GMT) which is just a .bat file which does the following:
- Exports a backup of the named database (via a .sql command file)
- Moves it into a tmp directory
- Creates a directory for today's date
- Moves the temp file into that
- Dynamically writes an FTP script
- Executes the FTP command
- Tidies up the tmp files
Sounds easy enough, but the internal functions had me thinking a little bit. Let's walk through the process of the files needed:
SQL file export of whole database
Create a text file called export.sql and added this command into it
BACKUP DATABASE [nameofdatabase] TO DISK = N'(pathtothedatabase\nameofdatabase.bak' WITH NOFORMAT, NOINIT, NAME = N' EasyToRememberBackupName', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
nameofdatabase = yeah, the name of your database
pathtothedatabase = full directory structure where you want the backup to be saved to (e.g. D:\SQLBackups\Name\TMP
The TMP bit you need to create to save the initial .bak file into from the SQL dump
EasyToRememberBackupName = This is nothing more than a convenient name to call the backup and won't be used anywhere else anyway, but will be referenced if you restore a database from this in the future. We'll call it SQLbackup.bak for this exercise
Save that file into a dedicated directory (which will be referred to as VolumeRunningTheScriptFrom in the next stage) and create a new empty text file called backup.bat
Now the really fun bit, we've nicked a bit of internal DOS commands coupled it with SQL commands and chucked in a bit of FTP command line code as well to create this beast:
sqlcmd -S .\SQLSERVERLOCALNAME -i "VolumeRunningTheScriptFrom\export.sql"
set string=%date:~-7,2%%date:~-10,2%%date:~-4,4%
echo %string%
md VolumeRunningTheScriptFrom\%string%
VolumeRunningTheScriptFrom\%string%
cd..
move VolumeRunningTheScriptFrom\tmp\SQLbackup.bak VolumeRunningTheScriptFrom\%string%\SQLbackup.bak
cd VolumeRunningTheScriptFrom\%string%\
move VolumeRunningTheScriptFrom\%string%\SQLbackup.bak VolumeRunningTheScriptFrom\%string%\BACKUP_%string%.bak
cd "VolumeRunningTheScriptFrom"
@echo off
del script.txt
echo open FTPserveraddress>>script.txt
echo user FTPuseraccount>>script.txt
echo FTPpassword>>script.txt
echo cd RemoteDirectory>>script.txt
echo bin>>script.txt
echo put VolumeRunningTheScriptFrom\%string%\BACKUP_%string%.bak>>script.txt
echo bye>>script.txt
echo exit>>script.txt
echo cls>>script.txt
ftp -n -s:"VolumeRunningTheScriptFrom\script.txt"
Now that's a mixed bag of code to walk through, let's do it a line at a time:
sqlcmd -S .\SQLSERVERLOCALNAME -i "VolumeRunningTheScriptFrom\export.sql"
From the command line tell the local SQL engine to open the Local SQL Server (in this case SQLSERVERLOCALNAME they typically run as SQLEXPRESS or SQL2008EXPRESS whatever name you gave it when it was set up) and then the FULL path to the .sql file created earlier to execute.
set string=%date:~-7,2%%date:~-10,2%%date:~-4,4%
echo %string%
OK so using a lovely old DOS date function, we are setting a string to be today's date, so if it was 23/11/2013 then the date string would be
23112013
which will make the sequential nature of the backup a whole lot easier to name for uniqueness
md VolumeRunningTheScriptFrom\%string%
VolumeRunningTheScriptFrom\%string%
cd..
Let's make a directory within your backup folder to the value of the date string (23112013) and check its ok, then skip back up to the root of where we are running the script from
move VolumeRunningTheScriptFrom\TMP\SQLbackup.bak VolumeRunningTheScriptFrom\%string%\SQLbackup.bak
OK, so now we want to move the temporary SQL dump from the TMP folder into the newly created datestamp folder
cd VolumeRunningTheScriptFrom\%string%\
move VolumeRunningTheScriptFrom\%string%\SQLbackup.bak VolumeRunningTheScriptFrom\%string%\BACKUP_%string%.bak
So now we want to rename the backup to be specifically renamed to the datestamp. In my case we were running a number of backups into the offsite directory so we wanted to prefix the file with the database name, in this example BACKUP_
So we've basically moved back into the new backup folder for 23112013 and renamed ("move" in DOS terms) the SQLbackup.bak file to a new filename of BACKUP_23112013.bak
cd "VolumeRunningTheScriptFrom"
@echo off
Move back up the folder to the root
del script.txt
Now the funky FTP script to handle the date-specific file. The issue I had with this was that we wanted to keep FTP transferring files from the system from a scheduled task running each evening, but in the past we used a static FTP text file to call from, this was no use when using date-sequential strings, so we are basically creating the script.txt file on the fly, a cunning way of making sure we reference the correct backup for FTP offsite.
First thing though, delete yesterday's script!!
echo open FTPserveraddress>>script.txt
echo user FTPuseraccount>>script.txt
echo FTPpassword>>script.txt
echo cd RemoteDirectory>>script.txt
echo bin>>script.txt
echo put VolumeRunningTheScriptFrom\%string%\BACKUP_%string%.bak>>script.txt
echo bye>>script.txt
echo exit>>script.txt
echo cls>>script.txt
Now we have written all the values into the script.txt file, all that's left is for us to call the script via the system FTP command, silently...
ftp -n -s:"VolumeRunningTheScriptFrom\script.txt"
So, that's the basics in place for the backup, all that's needed now is to schedule this batch file through the Task Scheduler and we're good to run.
I always just run the batch file at the beginning to check it and there's a nice satisfying DOS window which runs through the 0-100% back up process and the FTP transfer which informs you that the files are being pushed offsite.
Please drop me a note if you want the source files, mark{at}1stclassmedia.co.uk
Friday, 28 June 2013
Finding a kitchen designer in Edinburgh
Edinburgh is the centre for many things, festivals for one, museums? Art Galleries aplenty. In fact when it comes to high class design houses, Edinburgh has a huge array to choose from. The same (bear with me here) can be said for Kitchen Designs. OK, you can get an economical kitchen from a large DIY outlet, it'll have factory quality finishes and will require replacing in 12 years or so, but will it be truly original? Enter the real experts, bespoke kitchen designers. Choosing from the number of Kitchen Designers in Edinburgh may seem like a daunting task initially. Opening up a phone book or doing a web search may lead you to the designer, however great designers come by recommendation and referral routes - there simply is nothing quite like a word of mouth recommendation for the best kitchen designer. Once you get an idea who to engage it becomes a whole lot easier to make an educated choice about who to use, particuarly one who will take into account full planning and layout and will stick to your budget.
So how do you find such a good Kitchen Designer, particularly a bespoke kitchen designer in Edinburgh? One of the best ways to find the right person who will provide first class guidance and design services is, ask. Ask everyone, your friends or family who have recently had their kitchens replaced and ask about their experiences. More importantly if you have found a decent looking kitchen designer, go them directly and get some insight into the planning process and get testimonials. Also sit down and have a coffee and a chat - if you believe you can work with the designer, all the better!
Choosing from the sheer volume of kitchen designers you find may actually be quite easy, prepare your list of services you are looking for in your kitchen designer, the type of kitchen design you want, and a budget outline for the work you can afford and present it to them, any designer worth their salt will try their best to make a decision whether you can afford them or if you are looking in the right place. As cost is the primary limitation for a lot of people, decent early on which area of the kitchen you want to focus on, if it's worktops or finishes or just the best quality appliances then be true to yourself, you're investing a lot of money in this, so demand the best.
Preparing your list and then taking the time to ask friends, family and the designer themselves about their experience can make finding a Kitchen Designer in Edinburgh so much easier than you probably expected!
Thursday, 20 June 2013
jQuery Window Handler (target="_blank")
I love jQuery. I make no bones about it - it's been a revelation for many developers who want to utilise code blocks as reusable elements and by golly it does speed up development both client-side and server-side!
However there are occasions when the traditional view on using "legacy" HTML is sometimes the only way we can perceive a solution. Take this example - we had a colleague who was at his wits end as he'd spent ages trying to use the good ole image map for a map of Scotland to make a clickable map for guest houses. All very well and easy to do. Problem was that the code used another jQuery handler to overlay a replacement map of the area clicked to make it look pretty which in turn played havoc with the internal target="_blank" directive.
After much swearing he dropped me a note to see if we could help. We took a look at the code and it all seemed fairly ok and we encountered the same problem, wtf was going on here, we couldn't use the traditional means above nor could we see how the href wasn't being looked at by the jQuery function.
After much looking and wondering (god bless Stack Overflow, by far one of the best troubleshooting websites ever) we pulled together a code block which may suit one or two others who have need of it.
Image Map Code:
<map name="mymap" id="map">
<area coords="6, 234, 17, 235, 35, 205, 37, 22, 44, 163, 56, 152, 76, 122, 82, 115, 80, 91, 66, 83, 28, 183, 25, 137, 22, 151, 7, 160, 7, 179, 16, 181" class="newWindow" href="#" rel="http://www.bbc.co.uk" id="12" shape="poly" alt="altname" title="title" />
</map>
We added the class to the area to make it a little easier to pass into the jQuery function
jQuery:
$('.newWindow').click(function(e){
e.preventDefault();
var url = $(this).attr('rel');
window.open(url, "_blank");
return false;
});
So, basically, breaking down the code the following happens:
$('.newWindow').click(function(e){ //render a new function each time the class newWindow is clicked
e.preventDefault(); //stop any links from working (note this could probably be left out, we kept it in for convenience)
var url = $(this).attr('rel'); //create a variable "url" from the rel value on the area
window.open(url, "_blank"); //good ole JS to handle the window event
return false; //stop other shit from happening
So, in summary, the little function allows image maps to open URLs in a new window by making the existing link a # (null) link and placing the URL into the rel tag. Grabbing the rel tag into the url variable we push that into the window.open event and voila the target="_blank" emulator kicks in.
There are probably numerous ways of doing this but I thought this may help some poor troubled soul out!
Scripts pooled from various links including
http://stackoverflow.com/questions/4813879/window-open-target-self-v-window-location-href
http://stackoverflow.com/questions/970388/jquery-disable-a-link
Tuesday, 4 June 2013
Getting a Landscaper in Edinburgh
Many homeowners love the idea of landscaping their gardens or surrounding land (depending on size) since it is one way of increasing the value of their property. You may have a beautiful home, but an untidy front garden makes it look boring and less homey. By hiring a professional landscaper, you will be able to achieve a perfect design to make a bold statement about who you are, as well as adding value to your property.
One of the many my someone would choose not to hire a profession landscaper is largely down to cost. This is one of those situations where experience speaks volumes and it really does boil down to "are you prepared to spend many weekends getting dirty" against an initial outlay which can pave the way for long term ease of maintenance.
There are many reasons to hire a professional Landscaping Company in Edinburgh. Here are just a few that you should bear in mind:
Unnecessary Expenditure
It's a fact that some landscaping projects can amount to many hundreds. This usually involves professional fees, labour charge, and materials. However, if you compare the cost of trying to undertake the project yourself; hiring machinery, tools and equipment that will basically be used once, making poor choices of plants (and any other features like ponds or rockeries) and the potential for falling behind on the project as well, you'd be better spending a little bit and getting professional service.
Do you really know where to put that thing?
As mentioned above the "unnecessary costs", there is also potential risk for things to go wrong. If you are not great with the planning of proper landscaping projects, then maybe leave it to the experts. There is a real chance that you can do damage to your home or the existing plants, lawns and other parts of your garden. Landscapers can plan and design a beautiful garden for especially for your home, focussing on a larger picture. A full and open discussion will be part of the process.
So, you're an expert huh?
Don't get me wrong, if you've a limited budget or the necessary know-how then perhaps doing the landscaping yourself may be a solution, especially if it only involves basic planting,pruning or moving furniture about. But if it will involve major paving, patio design or building of walls, it's probably best to let the experts do it. Any decent landscaper will know the correct processes, tools or machinery, materials, and how to manage the schedule to maximsie the landscape design for your property.
Having recently completed a website for John Lessels Ltd, a Midlothian Landscaping Company covering Edinburgh and the Lothians, I thought it might be a nice touch to present my thoughts.
Tuesday, 30 April 2013
Railway Sleepers - From Track to Garden
Enter John Lessels Landscaping, my friend Andrew, and probably the rest of christendom, apparently it's not uncommon for treated and untreated railway sleepers to be reused/recycled into chique new garden design. Popping round to my pal Andrew's garden and he points out that his monster lawn is fringed with trimmed down railway sleepers which had been placed upright, like mini- Easter Island men between his patio and his lawn, quite a cool way of clearly demarking the start and end of the patio, but in his case because they dug the patio out a little way and this resulted in an 18" difference in height. It transpired that his landscaper new an Railway Sleepers seller in Edinburgh which turned out to be a couple of hundred poind cheaper that a reinforced dwarf wall which would need to have foundations, supporting brickwork etc to make it hold back even a tiny eighteen inches of lawn (apparently it gets quite mobile when very wet - every day's a school day huh?)
John Lessels, a leading landscaping and garden maintenance company in Midlothian also employ railway sleepers which they use to great effect for making raised beds for people in nursing homes and people with disabilities who can't get down to ground level too well. They thought, if they can't reach the ground, let's bring it up! So with some cheap railway sleepers, they have created a number of raised beds and even a fish pool using railway sleepers as the structural decoration and support for both beds and pond.
So there you have it, my lesson learned, railway sleepers, treated and untreated are particularly good for landscaping and contemporary garden design and layout as they can be shaped and trimmed to not only provide the muscle needed to support any beds or hold back lawns, but also to look really quite nice!



