How to read CSV Files in Coldfusion

A very simple bit of code today but useful in so many situations.

First, open the file using <CFFILE>. The file needs to be a physical path to the file as seen by the server.
<cffile action=”read” file=”D:/files/postcodetoregion.csv” variable=”csv”>

Next, loop through the file assigning each line to a variable. The delimiter is the line feed/carriage return
<cfloop index=”i” list=”#csv#” delimiters=”#chr(10)##chr(13)#”>
</cfloop>

Within the loop, each element is accessible using ‘listgetAt’ which will split the variable into an array.
<cfset firstelement= listgetAt(‘#i#’, 1, ‘,’)>
<cfset secondelement= listgetAt(‘#i#’, 2, ‘,’)>

That’s it!

How to increase the 30Mb File Limit in IIS 6

IIS 6.0 has two places controlling file size limits. To edit them, follow this steps..

  1. Open “C:\WINDOWS\system32\inetsrv\urlscan\metabase.xml”
  2. Find the entry for ‘AspBufferingLimit’. Increase it from its default of 4Mb to whatever you choose.
  3. Find the entry for ‘AspMaxRequestEntityAllowed’. Increase it from its default of around 30Mb to your chosen value

Additionally, if you have URLScan installed then you’ll need to update urlscan.ini and change the MaxAllowedContentLength from around 30Mb to whatever you want.

Also, you can edit the ‘Maximum Size of Post Data from 100Mb in Coldfusion to 300Mb

How to use Uploadify with Coldfusion

Uploadify for ColdfusionInstalling Uploadify

This is a simple post on how to use the excellent uploading jQuery, Uploadify, with Coldfusion 6.

You will need to find and download jQuery, swfobject.js and the jQuery-Uploadify.xxx.js library from the uploadify site

Create two files in the downloaded uploadify directory (the same as the default uploadify.css). The first should be called ‘index.cfm’. The next ‘upload.cfm’.

 

 

index.cfm

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Uploadify Example Script</title>
<link href=”uploadify.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript” src=”jquery-1.3.2.min.js”></script>
<script type=”text/javascript” src=”swfobject.js”></script>
<script type=”text/javascript” src=”jquery.uploadify.v2.1.0.min.js”></script>

<input id=”fileInput” name=”fileInput” type=”file” />

<script type=”text/javascript”>// <![CDATA[
$(document).ready(function() {
$(‘#fileInput’).uploadify({
‘uploader’  : ‘uploadify.swf’,
‘script’    : ‘upload.cfm’,
‘cancelImg’ : ‘cancel.png’,
‘auto’      : true,
‘folder’    : ‘/uploads’,
‘sizeLimit’: ‘2004857600’,
‘onError’ : function(a, b, c, d) {
alert(“Event: “+a+”, QueueID: “+b);
alert(“FileInfo: “+c.name+”, “+c.size+”, “+c.creationDate+”, “+c.modificationDate+”, “+c.type);
alert(“Error: “+d.type+”, “+d.info);
}
});
});
// ]]></script>

</html>

upload.cfm

<cfscript>
thisPath = ExpandPath(“*.*”);
thisDirectory = GetDirectoryFromPath(thisPath);
FileDir = thisDirectory & “uploads/”;
</cfscript>

<cfif not DirectoryExists(FileDir)>
<cfdirectory action=”create” directory=”#FileDir#” >
</cfif>

<cffile action=”upload”
filefield=”fileData”
destination=”#FileDir#”
nameconflict=”makeunique”>

Create a folder called ‘uploads’ in the root of your site. Make sure it has read and write permissions (chmod 666). Run index.cfm and you should be away!

Office Etiquette in the UK

Office Etiquette with people sitting around

I’ve worked in a fair few offices. Invariably I’ve been surrounded by the same people, day in and day out. Office etiquette is essential in maintaining a nice healthy atmosphere to help people work in peace and productively. Here is a list of the common offenders to upsetting peoples office karma.

Music playing

Everyone has different tastes in music. But even then there’s a time for some background music to be played and the office isn’t it. Have you ever been somewhere and heard someone play music from their car too loud? Even if it’s a song you like, you invariably think ‘What an idiot’ and your inner peace is shattered for a little while. It’s the same at the office. If you want to listen to music then use headphones at a volume where you can hear people call your name. People having to shout, wave, dance and throw items to get your attention ruins the concentration of everyone around.

Bad habits

These are often quite subconscious but if you’ve ever caught yourself picking your nose, coughing without covering your mouth, scratching where you shouldn’t, chewing gum vacantly or biting your nails then someone is going to be annoyed and lose concentration. If you see someone doing it and you feel uncomfortable or distracted then politely mention it WHEN NO-ONE IS AROUND. People will apologise and say ‘Yeah, my wife tells me that all the time’ if you tell them alone. They’ll get awkward and defensive if made to apologise publicly.

Food

Slightly related is food. If you’re in an environment where people eat at their desks then there’s a certain etiquette here too. Try not to eat smelly foods. Even sandwiches with spicy flavours and cheese can be off-putting. People are often repulsed by the smell of bananas (I know, strange huh?) to the point of distraction. When you’re eating then try to do it quietly. This can be hard with hard fruits such as apples or pears but at least don’t slurp the juices. This is probably worse than eating with your mouth open. When you finish your meal, take any plates away before the smell of what was on them becomes a feature of the office for the afternoon

Mobile Phones

You do not need your phone on anything other than vibrate. If you go away from your desk then take your phone with you. If your phone rings and you aren’t around then people have to endure the entirety of whatever ring tone you happen to have. If this is something loud then all concentration will be lost for everyone within 25 metres while there is a debate on whether to answer it. If you come back and the phone is gone, look in your drawers. A colleague may have ‘helpfully’ hidden the noise as a not-too-subtle hint!

Stories

In general women like to talk about what they do outside of work. Men as a rule don’t. Depending on the constitution of your office will depend on the etiquette here. If you are in a predominantly female office then you may need to be prepared to share what you did last night. If you’re uncomfortable with this then just say what you ate. It’s always a satisfactory answer and if you’re lucky the conversation will swiftly move on to something else before you have to participate further. Alternatively if you’re in a predominantly male office then knowing all the details of what your friends are doing will do nothing but serve to distract.

Dress

Work is not a fashion show. There are no prizes for best dressed. There are also no tips for dressing provocatively. There is always a uniform at work. Even in a casual workplace, there’s a kind of uniform. In my office right now we’re a group of developers and designers. Our uniform is jeans, fashionable/geeky t-shirt or shirt. If you stand out too much or, if you’re lucky enough, been blessed with an attractive figure and wear something revealing then it’s just going to upset colleagues.

I hope this guide helps, especially if you’re new to working in the office workplace.

How to automatically add an image to pdf links

How to automatically add a pdf image using jQueryOne of the things I like to do as standard is to add a nice little pdf logo to any pdf links. This allows users to quickly see that there is something a little bit special on the page and attracts the eye to content. This code will automatically update any pdf links without any further intervention from you. It’s useful if you’re using a CMS with content you don’t control yet want to define the style nicely.

Using jQuery, I add a class to any links with the extension ‘pdf’ using the following code. This can be placed before the </head> tag on your page.

 

// add class of pdf to links that end in pdf and open in a new window

$(document).ready(function() {

$(“a[href$=pdf]”).addClass(“pdf”);

$(‘a[rel=”external”]’).click( function() {

window.open( $(this).attr(‘href’) );

return false;

});

});

Then in the css file for my site I add the following class assignment

.pdf {

background: url(../images/pdf-icon.gif) 100% 50% no-repeat;

padding-right: 28px;

}

We then receive the nice effect below. (You may right click the pdf image and use it for yourself)
PDF Link Download Report Here

Dreamweaver CS5 to add support for Content Management Systems

The new version of Dreamweaver is to be released by Adobe.

Adobe Dreamweaver CS5One of the hot new features to appear in CS5 is support for authoring and testing of content in 3rd party applications such as Joomla, WordPress and Drupal. Increasingly sites are being generated with customisable content in mind and due to the maturity of these systems, they are often used as the basis to build a site around.

Additionally I’m excited by the prospect of Dynamically Related Files. The concept allows a page to be dynamically generated by analysing all the pre-requisite files, grouping them and displaying them as a single page. Since CMS’s are structured affairs and function driven, this will allow developers to rapidly see the effect of their changes without having to go through the file uploading and checking process after each individual change.

The smallest pages in the popular CMS frameworks have multiple links dynamically related files, making file searches difficult at best. You’ll be able to filter particular file types using filters and CS5 will prompt you with related changes should you change a dependant piece of code.

Are Opt-outs legal? (UK Law)

Are opt-outs legal still?

After some research the issue of opt-ins and opt-outs basically comes down to Data Protection laws. Data protection requires that storage of personal information for any purpose requires the consent of the owner.

When creating a checkout process or a registration wall, consent is implicitly implied by the act of filling in information and clicking a submit button of some form. Generally if you want to use an opt-in statement such as ‘Tick this box to receive our promotional emails’ then you need to leave the tickbox blank. This would require an actual action from the user which would then imply consent.

If you provide the same prompt with the tick box pre-filled, you are in danger of breaking data protection laws by gathering user information for a purpose they did not originally intend (e.g…. signed up to download a PDF but unintentionally also signed up for a mailing list).

Information source

Marketing – Twitter to add Promoted Tweets

After four years, TwitterTwitter Promoted Tweets have decided now is the right time to implement advertising into their portfolio.

Promoted Tweets will allow business to buy keywords and display their own tweets when users search for that keyword bringing parallels to Googles own adwords service with the exception that adverts will be limited to 140 characters.

At the moment the adverts are destined to appear in search results only but over time it is anticipated they may start infiltrating twitter streams. Initial rollout will be to 10% of users.

Add Twitter to WordPress

This is a very simple guide to adding a ‘tweet this!‘ link to your WordPress blog

  1. Open your WordPress blog admin section
  2. Click ‘Appearance…Editor’
  3. Find the element you want to change. I’d suggest the header.php or footer.php
  4. Generate an image for your Twitter button.
  5. Where you want to display your ‘tweet this‘ button, add the following code

<a href=”http://twitter.com/home?status=Look at this! <?php the_permalink(); ?>” title=”Tweet this” target=”_blank”><img src=”/images/tweetthis_jpg” alt=”Tweet this!” /></a>

SEO – Google page ranking decided by page speed

It’s official. Google will incorporate page loading times into the page ranking algorithm. Slow pages will get pushed down. Fast pages will be boosted in the rankings.

From Google:

You may have heard that here at Google we’re obsessed with speed, in our products and on the web. As part of that effort, today we’re including a new signal in our search ranking algorithms: site speed. Site speed reflects how quickly a website responds to web requests.

Speeding up websites is important — not just to site owners, but to all Internet users. Faster sites create happy users and we’ve seen in our internal studies that when a site responds slowly, visitors spend less time there. But faster sites don’t just improve user experience; recent data shows that improving site speed also reduces operating costs. Like us, our users place a lot of value in speed — that’s why we’ve decided to take site speed into account in our search rankings. We use a variety of sources to determine the speed of a site relative to other sites.

If you are a site owner, webmaster or a web author, here are some free tools that you can use to evaluate the speed of your site:

Link to the original article