PHP from_time() – a human readable time span phrase

I’m sure this has been done many times before, but I wanted something to turn a date time string like ‘2 days and 9 hours ago’ to give the last deployment time on a little git deploy tool I’m working on in my spare time.

Here’s the code…

Office Communicator Custom Status Editor v1.5.3 Released!

ocs-custom-status-screenshot

This releases address the issue where it would not run unless as an administrator. The problem is it modifies the system registry, and places files for communicator to find which require elevated privileges.

If you had User Access Control (UAC) enabled on Vista or 7, the program wouldn’t work as expected. Now it’s fixed, so permission is requested properly.

Also, I threw together a portable version of Office Communicator Custom Status Editor so an installer is no longer needed. This weighs in at less than 35kb.

Hope it helps another couple of thousand people have custom status or custom presences on Microsoft Office Communicator 2007 R2.

Communicator Status Editor Update: Offline support!

Office Communicator Status Editor v1.5.2

Along with updating the website, I’ve updated the Office Communicator Custom Status Editor to now work offline.

Previously, if you didn’t have internet access when starting up Communicator, the custom statuses would have failed. Now that’s now longer a problem.

That’s the only new feature of the program, but it’s a biggy – Also included now is a better installer and a slightly improved UI.

Download: Office Communicator Custom Status Editor (12101)

Joining text in SQL

A handy function for concatenating cells in SQL.
[sql]
CREATE OR REPLACE function join
(
p_cursor sys_refcursor,
p_del varchar2 := ‘; ‘
) return varchar2
is
l_value varchar2(32767);
l_result varchar2(32767);
begin
loop
fetch p_cursor into l_value;
exit when p_cursor%notfound;
if l_result is not null then
l_result := l_result || p_del;
end if;
l_result := l_result || l_value;
end loop;
close p_cursor;
return l_result;
end join;
/

SHOW ERRORS;
[/sql]

Listbox Select All for Multiple/Multiselect

Need a simple way to select all or none of the options?

This code is for ASP.NET!

This function needs to be placed once near the top of the page:

[js]
<script type="text/javascript">
/* jak’s select all code */
function lbselectall(listboxname, all) {
sb = document.getElementById(listboxname);
for (var i = 0; i < sb.options.length; i++) {
sb.options[i].selected = all;
}
}
</script>
[/js]

Then for each ListBox, simply put this snippit of HTML below it and edit ListBox1 to reflect the name of the listbox!

[html]
<a href="javascript:lbselectall(‘<%=ListBox1.ClientID %>’, true)">all</a>
<a href="javascript:lbselectall(‘<%=ListBox1.ClientID %>’, false)">none</a>
[/html]

For a full example, look at this code:

[html]
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple">
<asp:ListItem>one</asp:ListItem>
<asp:ListItem>two</asp:ListItem>
<asp:ListItem>three</asp:ListItem>
<asp:ListItem>four</asp:ListItem>
</asp:ListBox><br />
<a href="javascript:lbselectall(‘<%=ListBox1.ClientID %>’, true)">all</a>
<a href="javascript:lbselectall(‘<%=ListBox1.ClientID %>’, false)">none</a>
[/html]

Hope that help

Really basic form validation

As I know this will help someone, here’s a simple way to use form validation.

One important bit: The function to go in the <head>.

[code lang=”js”]

[/code]

And make sure you text boxes have an "ALT" attribute, like this for example:
<input type="text" name="fname" id="fname" alt="First Name" />
Important! Only put an ALT attribute for the required inputs!

Finally, tuck this little bit into your <form> tag you want to use:
<form name="contactform" onsubmit="return(checkForm(this));" method="..  >