Archive for the 'Boise Office' Category
Not a hard task, but I very much like doing things using the most efficient and straightforward means.
Get the jar from sourceforge, then add it to your favorite Coldfusion class path.
<cfset oFile = CreateObject("java","java.io.FileReader") />
<cfset oFile.init(ExpandPath("some.csv")) />
<cfset oReader = CreateObject("java","au.com.bytecode.opencsv.CSVReader") />
<cfset oReader.init(oFile,",") />
<cfset arrCSV = oReader.readAll() />
<cfdump var="#aData#" />
Here’s two AS2 Flash prototypes that I use all the time. The search proto is probably from that genius sephiroth but I can’t remember since it’s been a while. The shuffle prototype is from kingdavid.
Array Search Prototype
Array.prototype.search = function(needle, from, strict)
{
if(from == undefined || from >= this.length) from = 0;
strict = strict == undefined ? false : strict;
for(var a = from; a < this.length; a++)
{
if(this[a] == needle)
{
if(strict)
{
if(this[a].__proto__ == needle.__proto__)
{
return a;
}
} else {
return a;
}
}
}
return -1;
};
Array Shuffle Prototype
Array.prototype.shuffle = function() {
var myArray = new Array(); for (i=0; i<this.length; i++) { var control = true; while (control) { j = int(random(this.length)); if (myArray[j] == undefined) { myArray[j] = this[i]; control = false; } } } return myArray; };
I have a project I’m working on at the moment that has an incrementing series {1,2,3,n=n+1,…n} and I need to convert that into a repeating series like so {1,2,3,3,1,2,3,3,etc}. This is in coldfusion and the obvious solution is as follows:
<cfloop from="1" to="20" index="n">
<!--- gives us 1,2,3,0,1,2,3,0 --->
<cfset iCount = n MOD 4 />
<!--- manually set to 3 if iCount=0 --->
<cfif iCount EQ 0>
<cfset iCount = 3 />
</cfif>
<cfoutput>#iCount#<br></cfoutput>
</cfloop>
Well that’s great. It’s simple and probably runs fast (In production I’m only actually running from 1 to 20ish). I believe I’ve mentioned that I’m stubborn and LOVE clever solutions. We’re already running some math functions so I don’t feel bad calling it more.
Random pseudo code I’m making up as I go:
n = {1,2,3,4,...n=n+1}
n = (n-1) % 4
// 0,1,2,3, 0,1,2,3
n = n+1
// 1,2,3,4 1,2,3,4
// In binary...
// 0001 0010 0011 0100
k = n SRL 2
// 0000 0000 0000 0001
// 0,0,0,1, 0,0,0,1
n = n - k
// 1,2,3,3, 1,2,3,3
Bitwise operations ftw. There is probably some other solution involving BitAnd BitXOr.
<cfloop from="0" to="20" index="k">
<cfoutput>
#((k MOD 4)+1) - BitSHRN((k MOD 4)+1,2)#
</cfoutput>
</cfloop>
Here’s something I wasn’t aware of, if an associated array is populated by a named key, the length is not increased.
var someArray = new Array();
someArray['someKey'] = "someValue";
alert(someArray.length); // expected 1, got blank
alert(someArray['someKey']); // "someValue"
This is a problem if you’re trying to loop the array by jQuery.each(arr, function).
// Same array population
$.each(someArray, function(k,v) {
alert(k + "|" + v);
});
This will not do anything as jQuery loops by the array length. Given the way our array is set, this WILL work:
// Same array population
for(var k in someArray) {
alert(k + "|" + someArray[k]);
}
If we change our array to ditch the named key…
var someArray = new Array();
someArray.push("someValue");
$.each(someArray, function(k,v) {
alert(k + "|" + v);
});
That will work, but that isn’t how I want to do it. This is where I was spacing another method, creating an object instead of an array.
var someArray = new Object();
someArray['someKey'] = "someValue";
$.each(someArray, function(k,v) {
alert(k + "|" + v);
});
Ah ha! That’s how to rock it.
jQuery.each docs
Currently coding a site that is going to required international characters. I’m being very diligent in my data validation, so I want to lock the characters down with regular expressions. There isn’t any one metacharacter to encapsulate them all. So looking at a unicode table one can grab a range of characters.
[\u0041-\u005A] Matches A-Z
[\u0061-\u007A] Matches a-z
[\u00C0-\u0233] Matches À-ȳ
Could just put (adding digits) [\d\w\u00C0-\u0233]
Are you wanting to sell your products & services online?
We are eCommerce specialists and can create a secure, usable website for whatever needs that you have from just a few items to a huge inventory of cross-related products. We have several shopping cart solutions and can customize or even create a wholly new eCommerce solution for you.
Also, as an Authorize.Net reseller, I can get you set up with an Authorize.Net account at a discount rate and give you more options and security than other credit card processors. Contact me (Aaron) today and I’ll get you started!
In the infinite hell that is developing for Internet Explorer 6, I have gotten rather good at creating CSS that doesn’t use browser specific code (holly hack, asterisk, conditional logic, !important, child nodes, etc). There are a few exceptions in the instance of actual bugs, not just loose interpretations of the W3C standards.
PNGs in IE6. [The Fix]
I suppose I need not only apply the fix to IE6, since Firefox won’t break, but I think the fewer superfluous attributes applied to an element, the better.
* { behavior: url(iepngfix.htc); }
I die a little inside every time I have to add a hack like that.
Disappearing Background Images
Doesn’t appear consistently, but consistently annoys. I use background images for list item bullets. In IE6 the background images will appear until the page loads, then disappear save the first bullet (sometimes). If you can scroll the window enough to move the bu
We’ve launched our design portfolio, complete with project descriptions and plenty of eye candy! Check it out!
Finally, a Website for our Boise office! Long under the oppressive yokes of the Seattle tyranny, our Boise team has risen from the ashes like the Phoenix reborn! Ok, ok, it’s not that bad — we’ve just been waiting to have some time between projects to actually build something for our Boise team here. We’ve been here downtown since July 2007 but have been so swamped with everything that well…you know.
So, this is where we take out our Bible ( or Richard Dawkins book) and say the pledge:
I, <Peak Boise Employee>, do solemnly swear to regularly add blog posts to our wonderful website on the World Wide Web and do solemnly uphold the valued principles of Peak Systems as we write…and to write stuff that interesting enough to not bore our readers to sleep!
Ok, so this is our first blog post. Many to follow!




