ppk cookie plugin, http://www.quirksmode.org/js/cookies.html
jQuery BBQ, back button & query, http://benalman.com/news/2010/04/cooking-bbq-the-original-recipe/
jQuery urlInternal plugin, http://benalman.com/projects/jquery-urlinternal-plugin/

Tagged with:
 

https://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions

Good stuff for conducting a phone screen

Tagged with:
 

Awesome Browser and OS detection in javascript.

var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera",
versionSearch: "Version"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]

};
BrowserDetect.init();

Tagged with:
 

cglib: Auto Code Generation tool
Objenesis: Instantiate a new object of a particular class, even without public constructor.
EasyMock: Great tool for unit test, just specify the output yourself.

Tagged with:
 

For those private fields and methods, it’s a common practice, and seems only way to test using reflection.

Here’s a good reference: http://en.wikibooks.org/wiki/Java_Programming/Reflection/Accessing_Private_Features_with_Reflection

Tagged with:
 

EasyMock is a good resource for mocking up objects in unit testing.

Tagged with:
 

Checking the progress of the http client transferring bytes, we could override the write/writeTo method in the Entity Class, which basic do the real reading and writing bytes.


import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.httpclient.methods.RequestEntity;

public class CountingMultipartRequestEntity implements RequestEntity {
private final RequestEntity delegate;

private final ProgressListener listener;

public CountingMultipartRequestEntity(final RequestEntity entity,
final ProgressListener listener) {
super();
this.delegate = entity;
this.listener = listener;
}

public long getContentLength() {
return this.delegate.getContentLength();
}

public String getContentType() {
return this.delegate.getContentType();
}

public boolean isRepeatable() {
return this.delegate.isRepeatable();
}

public void writeRequest(final OutputStream out) throws IOException {
this.delegate.writeRequest(new CountingOutputStream(out, this.listener));
}

public static interface ProgressListener {
void transferred(long num);
}

public static class CountingOutputStream extends FilterOutputStream {

private final ProgressListener listener;

private long transferred;

public CountingOutputStream(final OutputStream out,
final ProgressListener listener) {
super(out);
this.listener = listener;
this.transferred = 0;
}

public void write(byte[] b, int off, int len) throws IOException {
out.write(b, off, len);
this.transferred += len;
this.listener.transferred(this.transferred);
}

public void write(int b) throws IOException {
out.write(b);
this.transferred++;
this.listener.transferred(this.transferred);
}
}
}

Reference: http://stackoverflow.com/questions/254719/file-upload-with-java-with-progress-bar

 

http://blogs.technet.com/b/alexshev/archive/2008/02/10/from-msi-to-wix.aspx

Tagged with:
 

http://www.javascripttoolbox.com/jquery/cheatsheet/

Tagged with:
 

From Original Post:

http://mattkruse.com/2009/06/11/flash-of-content-with-jquery-slideupslidedown/

This is an old issue, but I never looked into it in enough detail to solve it until now.
When using slideUp() and slideDown() in jQuery (and any other animations that animate height) there is often a “flash of content” when the animation starts or stops in IE.
Here are the details you might want to know:
IE 6/7 mishandles a style like “overflow:hidden;height:0px;” (which should show nothing) and instead show the entire contents of the object. But ONLY in quirks mode. This is a bug.
When doing a hide animation, jQuery animates to 0, and when doing show, it starts at 0
So when the value of 0 is set inside the animation, the entire content is flashed visibly on the screen, this causing annoyance and potential epileptic seizures.
A ticket was filed with jQuery 2 years ago about this issue: http://dev.jquery.com/ticket/1726
Unfortunately, they changed it to “wontfix” and instead declared that FX animations are not supported in IE6/7 in quirksmode. I consider this to be pretty lazy on the part of the developers, and I’ve seen this attitude several times with regards to problems that are not so obviously solved or outlying cases. It’s disappointing.
I started a thread in the jQuery Dev group about this, so we’ll see if anything comes of it.
Meanwhile, inserting this fix into the page solves the problem:
jQuery.fx.prototype.originalCustom = jQuery.fx.prototype.custom;
jQuery.fx.prototype.custom = function(from,to,unit) {
if (this.prop==’height’) {
to = to || 1;
from = from || 1;
}
this.originalCustom(from,to,unit);
}
It’s simple – when the to or from value in the animation is 0, and we’re animating ‘height’, then just go to/from 1 instead. Problem solved.
Hope that helps out at some point in the future when your content is flashing and you can’t figure out why…

Tagged with: