Author Archive

ReloadCSS Stylesheet Reloader – make development a bit easier

Tuesday, January 27th, 2009
ReloadCSS Bookmarklet: Reload CSS

The ReloadCSS source: Source


A while back I ran into an annoying problem. I was working on a couple of projects that were Java/JSF/JSP based. We were using Eclipse with Tomcat to run the project. The annoying bit was that whenever I made a change to a stylesheet, it would take several seconds to a minute before Eclipse updated the working deployment. Despite refreshing the browser repeatedly, a simple change just wouldn’t refresh immediately.

Also, if the remote dev servers for the database were running slow, each page refresh would take a while depending on what the application was trying to do.

My continuing interest in jQuery as a primary javascript development platform led me to a quick temporary solution. I wanted to make a JS bookmarklet that would dynamically reload all of the stylesheets on the page. I’ve since updated it a bit to make it more robust.

I’ve set this up as a code demo. You can add the bookmarklet to your browser by dragging the link to your toolbar in Firefox, or adding it as a favorite in IE. Safari is a little trickier, but basically just add it as a bookmark and it should work.

When you are on a page you are working on, hit the Reload CSS bookmarklet. This will insert a “Reload CSS” button floating in the top-right of the browser window. Every time you click this it will reload all stylesheets loaded via <link> tags. Sorry, it doesn’t load stylesheets with @import right now.

Each <link> tag href attribute gets a counter incremented as #num. This tricks the browser into updating the CSS.

The bookmarklet checks for jQuery in the DOM, then loads in v1.3.1. If you already have jQuery loaded, it isn’t loaded again. The script itself is then loaded from from my code stash here. When I make updates, they’ll automatically be updated. Also, feel free to copy the code itself if you want to use it or host it locally.

This has been tested and verified working in Firefox 3 and Safari on Mac OS and Windows. This is where I do my primary development and was my only concern when developing this.

Feedback is really appreciated, and hopefully this will help someone out.

ReloadCSS Bookmarklet: Reload CSS

The ReloadCSS source: Source

Introducing Fathomer

Thursday, January 15th, 2009

Project Page: http://code.google.com/p/fathomer/

I started working on this late last week after brainstorming with a friend. We wanted a way to dynamically promote some one’s Twitter account to users who are most likely to already be Twitter followers themselves. Imagine you are working at a large company with lots of traffic (like us) and want to promote your company’s Twitter account to your users, but don’t want to have to explain to the 95% of non-Twitter users just what the hell you’re talking about. The idea is that you can grow your community much easier if users are already on Twitter. As more of your general audience join Twitter themselves, they are introduced to the promo. Fathomer tries to work along the principal of gradual discovery of features.

If you are a Twitter user, you are most likely seeing Fathomer on this site. Its the orange badge in the top-right of the page.

Fathomer is a highly customizable tool that detects if a visitor to your site is a Twitter user and shows a badge, or ad, with your message and a link to your Twitter account.

It works by detecting if a user has visited the account settings page on Twitter, which is a URL you can only access once you have been logged in to the service. The user does not have to enter any personal account information, nor do you. You can configure Fathomer in many ways:


  1. Custom message – A default is used if none is set.

  2. Specify your account name. This is the only required piece of information and is used for display purposes only.

  3. Custom CSS and badge html – A complete default badge comes installed. Its possible to customize the CSS and even make your own html for the badge.

  4. Change detection url – You can change the Twitter url that is being checked if you need to.

  5. Target badge placement – By default, the badge loads in the top-right corner of the browser. However this can be changed to whatever load in whatever html element you want.


I’m also thinking about some improvements to the detection methods that could increase the precision of the targeted promotion. If there’s enough interest in Fathomer to warrant improvements, they’ll get added in. I’m also interested in adding some conversion metrics, but that takes Fathomer from being a simple and easy to install tool to being a larger project. If it grows, so will its capabilities.

You can visit the project page at http://code.google.com/p/fathomer/ or you can install Fathomer directly by adding the following script to your page somewhere and configuring the username and/or message.

All feedback is requested and appreciated!

<script type="text/javascript" src="http://fathomer.googlecode.com/files/fathomer-latest-min.js"></script>
<script type="text/javascript">
// Required. Your account name.
fathomer.account = 'yourAccountName';

// Optional. The message that is displayed.
//fathomer.message = 'Sample override message.';

// Optional. Can specify a specific element to attach to. ID, class, or css selector
//fathomer.target = '';

// Optional. Turn off default css if you have your own styles.
//fathomer.loadcss = false;

// Optional. Can be changed to a different Twitter url to check the visited history state.
//fathomer.urlcheck = '';

// Optional. If a custom html structure is needed, it can be loaded using standard jquery methods in altbadge. Properties are accessed/set via fathomer.var, e.g. fathomer.message.
//fathomer.altbadge = function(){};

fathomer.init();

</script>

Quick tip to save a lot of memory on your iPhone

Saturday, January 10th, 2009

There’s a great app called FreeMemory that quickly frees up a lot of memory. It’s definitely worth the $0.99.

The last update adds a great feature that let’s you see all of the processes running on your phone.

Last night I started noticing that sometimes MobileSafari stays running as a background process. This only seems to occur if you close Safari with a web page open.

In these screenshots, you can see what I mean. The quick tip to save a lot of memory is to close any open pages before you quit Safari. I didn’t use the free memory button on this. I just closed the page between uses in Safari

Twitter “protects” API user status call… but doesn’t

Friday, January 9th, 2009

John Resig alerting about the authentication change

UPDATE 2/24/09: Twitter has changed their API and this technique no longer works.

For the last week or so, there’s been a lot of commentary about how you could detect if a Twitter user was visiting your site based on the response of a public, non-authenticated API call. It was documented at Ajaxian.

John Resig was one of the first to notice earlier today that Twitter has placed the API call in question behind http authentication. Indeed, the link he provides to Venture Hacks issues a login alert when you visit the page.

However, this does absolutely nothing to prevent a 3rd party from still accessing this information. Twitter is likely to fix this soon, but here’s how to use it in the mean time.

Basically, the API url that is now issuing the authentication requirement was this:

http://twitter.com/statuses/user_timeline.json&count=1&hasTwitter&suppress_response_codes


By simply changing the query string slightly, you bypass authentication and retrieve the user’s status data again if they are logged in. This works without the “/?callback=” part, but this is needed to have have Twitter wrap the json object so that it can be used in the browser, ala jsonp.

http://twitter.com/statuses/user_timeline/?callback=usrobj


If you use jQuery, the simple bit of code that returns this is:

$.ajax({
dataType: 'jsonp',
data: '',
jsonp: 'callback',
url: 'http://twitter.com/statuses/user_timeline/',
success: function(jsondata) {
alert(jsondata.toSource());
},
});


To use this to determine if a visitor is logged into Twitter or not, use the methods described in the Ajaxian article and just change the link. Happy hacking!

Javascript – RGB to Hexadecimal Color Converter

Wednesday, January 7th, 2009

While working on a side project today, I found the need for an RGB to hex color code converter in javascript. There are a number out there within a couple of easy Google searches, but I wasn’t happy with any of the ones that I found.

Every example I found other people had posted over the years involves using a string using 0-9, a-f and then using character matching and some math shifting to return a hex conversion. This irked me because javascript is perfectly capable of doing these conversions with native methods.

So what you will run into from time to time is that some browsers like Firefox and Safari return the css color value of an element as an RGB format, like RGB(204,0,0). Other browsers, namely Internet Explorer, return the hex code, like #cc0000.

What I wanted was a reusable method that will convert an RGB value to the equivalent hex number. It also had to be flexible enough to not be abused if I pass in a hex or non-RGB value. This helps it play nicely across different browsers. Its using native javascript “parseInt” and “toString” methods to do the converting. So enough chit-chat, here’s the damn code. =)

rgbhex = function(rgbval){
var s = rgbval.match(/rgb\s*\x28((?:25[0-5])|(?:2[0-4]\d)|(?:[01]?\d?\d))\s*,\s*((?:25[0-5])|(?:2[0-4]\d)|(?:[01]?\d?\d))\s*,\s*((?:25[0-5])|(?:2[0-4]\d)|(?:[01]?\d?\d))\s*\x29/);

var d='',e;
if(s){ s=s.splice(1); }
	if(s && s.length==3){
		d='';
		for(i in s){
			e=parseInt(s[i],10).toString(16);
			e == "0" ? d+="00":d+=e;
		} return '#'+d;
	}else{ return rgbval; }
}

The Double-class/Double-ID CSS Hack for IE6 & IE7

Tuesday, December 9th, 2008

I haven’t seen this CSS hack for Internet Explorer before. I encountered this by accident today while trying to work out an IE6 display error. My preliminary Google searches and few hours of research didn’t find this documented anywhere, but I highly doubt I’m the first one to encounter this. In any event, I’m tentatively calling this the “Double-class” IE hack. It lets you target IE6 specifically, or IE6 and IE7 both. I haven’t found a way to specifically target IE7 using this.

In a nutshell, if you want to target IE6 use two class periods:

..className{ /* styles here */ }

To target IE7 and IE6 both, double-declare the class name:

..className, .className{ /* styles here */ }

Or, an alternate way to do this and target both IE6 and IE7 is this:

., .className{ /* styles here */ }

This also works with IDs:

.#classID{ /* styles here */ } /* IE6 Only */

., #classID{ /* styles here */ } /* IE6 and IE7 */

Firefox 3 – 2 days, 4 tabs, 1gb+ RAM in use

Friday, December 5th, 2008

I don’t normally restart my work box that often. Its a pain to wait for all of the services to get up and running (apache(php), tomcat(java), Ecliplse, 4 browsers, etc). I usually have to kill Firefox towards the end of the day and restart it to make it speedy again. I didn’t restart it for the last 2 days and thought I would document the first time I’ve ever seen FF3 use over 1gb of RAM with only 4 tabs open. Hopefully the next v3.1 update will help fix some of the apparent memory leaks.

firefox 3 using over 1gb of ram

firefox 3 using over 1gb of ram

Tried Using ChaCha? Me Neither.

Friday, December 5th, 2008

Over Thanksgiving weekend, I found out my younger sister “works” for ChaCha. She showed me the interface and told me about how it works.

The site only started getting over 500k monthly visitors since August, according to Compete.com.
She can usually sit there for up to 2 hours waiting on a question to come through from a user. The problem isn’t scalability, its finding customers who actually want to use the darn thing.

She made a little over $20 for the entire month of November. Their internal message boards are filled to the brim with hundreds of other workers who complain about never getting questions. The reason ChaCha stopped accepting new workers a few months ago seems to be that they outstripped the supply of people asking questions.

An important policy that seriously restricts the usefulness of ChaCha’s answers is that its workers are restricted to the sites they get their answers from. They are not allowed to use 3rd party search engines, such as Google or Yahoo. They are also restricted from using Wikipedia and almost any kind of message board.

ChaCha has an internal directory of human-categorized approved links across a number of directories, ala Yahoo’s early attempts to create a categorized view of the web by employing librarians to index sites. That was the 1st gen business model that pretty much failed for Yahoo.

I ran a series of questions by her and the answers she could find were a combination of inaccurate, incomplete, or occasionally right.

After having seen ChaCha from the inside, more or less, I can’t say there’s anything there that shows me it has any value to the user. Go hit Google, Yahoo, or even Live.com. You’ll get better results.

Fix for “The Adobe UI font could not be loaded”

Wednesday, October 15th, 2008

If you encounter this error message when opening Adobe Photoshop CS2 in Windows XP, “The Adobe UI font could not be loaded” here’s a quick fix that worked for me. CS2 was doing this for months to me.

Search your system for a file called ADMUI3.fon. Copy this file into the Required folder in CS2. For example, “C:\Program Files\Adobe\Adobe Photoshop CS2\Required folder”.

Restart Photoshop and there’s a good chance it’ll be fixed.

11 Places to Get Started with iPhone App Development

Wednesday, October 8th, 2008

The goal of this list is to provide a starting point for people looking to get involved with iPhone application development. I’ve tried putting the most recent, pertinent, and/or useful towards the top of the list.



The Apple iPhone Dev Center, but you have to sign up to enter: http://developer.apple.com/iphone/

iPhone Developer Central. Lots of tutorials: http://www.iphonedevcentral.org/

Forums @ iPhone Developer Central. Very active community: http://www.iphonedevsdk.com/forum/

A thorough, step-by-step tutorial to make an RSS reader: http://theappleblog.com/2008/08/04/tutorial-build-a-simple-rss-reader-for-iphone/



How to setup your dev environment on your Mac: http://www.jeroenvanwissen.nl/lead-story/2008/10/08/howto-iphone-application-development-environment.html



Slide your view around when editing UITextFields so that they never get trapped under the onscreen keyboard: http://cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html

Glassy Scrolling with UITableView: http://www.fieryrobot.com/blog/2008/10/01/glassy-scrolling-with-uitableview/

Using frameworks in iPhone applications: http://blog.omnigroup.com/2008/10/01/using-frameworks-in-iphone-applications/

A very short and older quick-guide to the Interface Builder: http://forum.insanelymac.com/index.php?showtopic=96104

Older tutorial to making a simple Hello World touch app: http://ihatetheiphonesdk.blogspot.com/2008/04/reason-2-interface-builder-is-buggy-and.html

Another older tut written with a beta-build of the SDK, still thorough and useful: http://www.iphonesdkarticles.com/2008/07/first-iphone-application.html