Forcing Firefox to Show Image After Disabling Showing Images

I guess I didn’t know that if you disable Firefox to show images, images still show if you use a Data URI string, base-64 encoded. For example, let’s take a look at the following HTML:

<html>
<head>
<title>Test</title>
</head>
<body>
<img src="data:image/gif;base64,R0lGODlhuwAsAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgMHAv8DcwKrK7wAAAAAA/wRAfQJHjQRR
owqRBgD/AAI2bRNnvw5j0BAQEBJWnBZoJhSGDhwdHBk6XhdLfiFUHhpcmB9xLxqmDidDXyVkHSMl
JidtqSty0it6JCyVFiyiFzEyMi6wGDk5OUFQazdowDttmjCAPzeXHkJCQUdITENyzUCIN0x9qEuE
tkiN3keTUk6Zwk2rNEq1J1BRUlVcUlJbblV1s1ehYFxcXV6HqFiAs2KRsljBLl1bWWVlZGefzl6a
4mtrinGX3WiycXC/D2jNNm9vbnaQyXaixYBhN3l8eXp6mYOOlXeq5oW9PX+41XjAgH7aEH3iSoQA
AIFxWISEAIaw54S8N4bMjI+EXYmIho+TqYulvIen2IytvZSx2pG764jsEZNoK5KQjZSYm5SUnJWU
1pDLPpvmOpbamppPM5mTfZqZkpycmZ2c15qylaHOY6abVqGfvKS7zaHkpKwIDa8OE66uqqqq566y
xq3Hg63G2a3ur7g1ObRKGbVWHLZ+MbR9UbS2uLTL37TafrkRFbopKbpmI726tLq9vbq5zcLB8L7R
m7r6vcIPGsUYIsk3IsY8QshKMcVNUcdqasZ7SsKAMryQXMiUPMa9zsrMzMDN1sulR86qpcy4pc7D
Ss3HwNDMxdIVJNdEJtZYPdhrStl0edSnfNHAttTQVtXVatPQyNbX2uMWC9saK9w0E+FMWNpZY91s
st1+LNx7VtyzcdqzydzXWeUBAeAnOOtiNudkxuhryOxzC+iBieaMzOmOHN+MWuamque0tuTl5fAP
CewuwOlFFe5IyeRWBPNY0Ox90PClheyqHvDGg+nQtO/v7/cAAPhSGPdSGP9sGviPavCVN+yjY/qz
IfWxWPK9bfXAofPELfLLSPTUMvPR0/neQfrcZPrmdPn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wVMV/X93kaARizUASegz4050OyhinzVn4gWFz3oAEsAAa6BwVCoAhzUBGGQAzgkAmMUA3I
oHDKFgzx8A2dcBG98HTR5mGL8AZAuAgkRnnNEynRJ3Ka4koksXKeB3c7RwfHgT6BsQb34E2TknMg
WH7UtRE8wAAicANGYAVPAANQUQjEcAzegAzVwAi20IbOgHTjQA05yFv5UId2mIAKCAEQCBN7GIHd
1hEHEAZrEBgTMkA2pilgIfh8dKACGZABH3AsFhEH0EAM3RAOulcN8ZCJ/3YMx4AI6GWHd5iHejgb
fagSqHAAj2BUH1GELBEHhVAIhmAIjjCLtDiLnoheRFh5J7aLvNiLvviLwBiMwjiMxFiMHBEQADs=" />
<img src="TrayItems.gif" />
<img src="http://www.shinylight.com/wp-content/themes/Wiking/images/button_rss.png" />
</body>
</html>

Which outputs:

You can see for yourself here, which is the HTML page.

Now, let’s disable showing of images in Firefox – Uncheck “Load images automatically”:

Refresh the page and see that you get:

Strange that they haven’t blocked this as well. This happens in Firefox 3.6 for Windows. I tested it in Safari 4.0.4 on Windows and it none of them showed when images are disabled.

Convert Relative URLs to Absolute

I put this ColdFusion UDF together the other day to turn relative URLs to Absolute. Code is pretty straightforward.

<cffunction name="URLRelativeToAbsolute" returntype="string"
  hint="Converts relative URLs in an element and converts to absolute. It includes the http:// protocol prefix.">  
 
  <cfargument name="content" type="string" required="true" hint="HTML content that will be scanned and replaced." />
 
  <cfargument name="domain" type="string" required="true" hint="Add domain name to relative links." />
 
  <cfset var local = StructNew() /> 
 
  <!--- The following regexp handles the following elements: link, a, img, script, form, frame. --->
  <cfset local.contentFixed = REReplaceNoCase( Arguments.content, "(href|src|action)=""/?((\./)|(\.\./)+|)(?=[^http])", "\1=""http://" & domain & "/", "all" ) />  
 
  <!--- The following regexp handles the url() attribute of the background CSS property. --->
  <cfset local.contentFixed = REReplaceNoCase( local.contentFixed, "url\((\s)?(')?/?((\./)|(\.\./)+|)(?=[^http])", "url(\2http://" & domain & "/", "all" ) />  
 
  <cfreturn local.contentFixed />    
 
</cffunction>

Usage:

<cfsavecontent variable="htmlContent">
<textarea name="data" rows="20" cols="60">
  <style>
    body { 
      background-image:url('stars.png');
      background-image:url('../stars.png');
      background-image:url('/stars.png');
      background-image:url('/../../../stars.png');
    }
  </style>
  <a href="../../../images/shiny.jpg">Shiny</a>
  <a href="http://www.google.com">This should not be touched</a>
  <img border="0" src="/images/cool.png" /> 
  <link rel="index" href="../../index.asp">
  <form method="POST" action="cgi/processing.cgi"></form>  
</textarea>
</cfsavecontent>
 
<cfoutput>
 
  #htmlContent#
  #URLRelativeToAbsolute( htmlContent, "www.shinylight.com" )#
 
</cfoutput>

Result:

Temporary Stored Procedure

They can be handy sometimes if you want to modularize your code for the life-time of a routine. To create a temp stored procedure, all you do is use the # sign before the name of the sproc. Same concept as a temp table. Only the owner can execute it and its life is that of the session. Here’s an example that uses the Northwind db.

CREATE PROCEDURE #GetCustomers 
(
  @companyName VARCHAR(50)
)
AS
BEGIN
  SELECT * FROM Customers
  WHERE  CompanyName LIKE '%' + @companyName + '%'
END

To use it:

EXEC #GetCustomers 'The'

You can find the temp sproc in the tempdb:

If you want more information on the temp sproc, you can query the system view under the tempdb:

SELECT * FROM tempdb.sys.objects
WHERE [object_id] = OBJECT_ID('tempdb.dbo.#GetCustomers')

Your next question maybe if you can create temp user defined functions? The answer is a big juicy delicious, “NO!” (at least as of SQL Server 2008 Enterprise).

Search As You Type

Just upgraded recently from WindowsXP to Windows7. One feature I used a lot forever (since Win95 I think), was the search as you type (this is what I call it anyways). It’s when you have an Explorer window open (let’s say in this case c:\ ) and you type “W” – it moves the cursor to directory that starts with the letter “W.” You can type “Win” quickly and it will go to the first directory that starts with those keywords in case you have directories that start with “Win.”

So after I configured the UI settings on Win7 to the way I saw fit, I realized that this feature was gone. It would automatically start searching for text in all files recursively – very annoying. I asked how to turn this feature off in many forums and do what I wanted to do and no one knew.

I finally figured it out. It was a setting that I turned on accidentally. (D’oh!)

Explorer Window -> Organize -> Folder Options -> View Tab -> When typing
into list view -> Select the typed item in the view

That wasn’t checked. I suppose I did it instinctively without thinking. In WindowsXP, the area is used to trigger Advanced File Sharing, and I guess I didn’t realize this in Windows7. Also, I don’t think in XP this is an option you can control because it just works.

Windows7 Options

WindowsXP Options

Reasons I’m Not a Fan of Google Chrome OS

I’m assuming you’ve seen what Chrome OS can do. Just Google “Chrome OS,” because it’s everywhere.

I would give Chrome OS an 8.0 / 10.0 for computer beginners, like the grandmas of the world. It’s gets a 2.0 / 10.0 for techies. Why? Three reasons.

  • Needs too many resources for what it delivers.
  • Cannot run executables, not even virtually/sandboxed.
  • Needs the cloud for storage.

Kind of annoying that I can’t just run it on any old laptop / netbook. System requirements are too demanding for what it promises and it seems it’s needed just to have that 2-4 second boot-up time, which honestly it doesn’t mean much to me. There’s never a time where I’m in such a hurry that I need my computer that fast, because I’m either doing something else, or I just use my phone.

I some people really care about boot-up time? I’d rather wait 10 more seconds and have the ability to run .EXE files and have it run on old PC’s. For a minimalist device, I have my table PC or iPhone already that can do all that stuff, and I don’t have to worry about malware on the iPhone. I don’t think techies have to worry to much about malware since they’re careful about getting them in the first place and have good Anti-viruses.

Lastly, an Internet connection is not ubiquitous yet. I’m on the subway a lot where there’s no WIFI and sometimes I travel to places without an Internet connection. I want to be able to at least read my latest documents without connecting to the cloud.

The OS is still in the works, so I suppose maybe they’ll address some of these features in the future.

CTRL+TAB in Eclipse

By default, CTRL+Tab (forward switching of windows) and CTRL+SHIFT+TAB (previous switching of windows) aren’t set in Eclipse to switch between editors windows. There are other Eclipse, non-standard defaults like CTRL+F6 for forward switching. To set these shortcuts, do the following:

  1. Run Eclipse
  2. Window -> Preferences
  3. General -> Keys
  4. Search for: Next Editor
  5. Put the cursor in the “Binding” textbox and delete that hotkey. Then, press and hold CTRL+TAB
  6. Hit Apply.
  7. Search for: Previous Editor
  8. Put the cursor in the “Binding” textbox and delete that hotkey. Then, press and hold CTRL+SHIFT+TAB
  9. Hit Apply and OK.

Apply similar steps for Ctrl+Shift+Tab.

Console2 Alternative to CMD

You know what, I tried PowerShell and I guess I never got used to it. I’ve been using DOS for the longest time that I prefer its simplicity when navigating through files. As far as scripting with it – forget it – it’s very cryptic and limiting, not to mention awkward. That’s why for scripting now I’m using Python. Nonetheless though, I sometimes need a playing field to run the scripts for, or running console utilities. That’s where Console2 comes in.

Console2 is a great tool that provides tabbing (you can tab through multiple consoles) and several ways to customize the UI. Here’s an example:



I prefer this configuration:


How I Have It Setup



Download Console2:

I have the Console2 open up when I hit CTR+\ via AutoHotkey. Here’s the snippet for this to happen in AutoHotkey. I have this run when Window starts (it must stay in memory).

^\::Run C:\dan-local\dos-win\Console.exe

Change the CMD prompt by creating a PROMPT system variable:




Download the Console2 Config File

Other Tips


Autocomplete
Good tip about command console = CTRL+I
can select files in the current directory, kinda like autofill-in
you can also put in parts of the file and it autoputs it for you

Rename tab
CTRL+R

New Tab with default transparency
CTRL+F1

New Tab with lighter transparency
CTRL+F2

Switch to NEXT adjacent tab
CTRL+TAB

Switch to Previous adjacent tab
CTRL+SHIFT+TAB

CTRL+[NUMBER]
Goes to the tab instance. To make it easier, it’s best if you rename your tabs,

[INSTANCE NAME].[NAME OF TAB]

So for example,

1.Batch File
2.wget list
3.ftp the files

Base Tag Not Supported In Hotmail

It’s interesting how the <base> works in various clients. I thought all major web clients would support it, but apparently it is not the case.

Let’s look at how some email clients process this tag:

Yahoo.com! Web Mail

Base tags are modified by their mail server and relative URLs are changed to absolute. So it works.

Gmail Web Mail

Base tags are modified by their mail server and relative URLs are changed to absolute. So it works.

Gmail Account via Thunderbird

Base tags are shown and its functionality is intact. URLs remain relative. So it works.

iMS Account via Outlook 2007

Base tags are shown and its functionality is intact. URLs remain relative. So it works. More info on iMS.

ShinyLight Account via iPhone

Can’t see the HTML, but all URLs worked.

Hotmail

Unfortunately, this is the ugly duckling. Hotmail servers remove the base tag and leave your relative links as relative. Big FAIL.

Get Latest File

In my last post, I made a quick script that checks for the date. It was very limiting, since it used the dir command. This one uses several date/time Python modules and is more capable.

import os, os.path, stat, time
from datetime import date, timedelta, datetime
 
# Reference
# http://docs.python.org/library/datetime.html
# http://docs.python.org/library/time.html
 
def getFileDate( filenamePath ):    
 
  used = os.stat( filenamePath ).st_mtime      
  year, day, month, hour, minute, second = time.localtime(used)[:6]
  objDateTime = datetime(year, day, month, hour, minute, second)
 
  return objDateTime
 
  # Ways to reference this DateTime Object
  # objDateTime.strftime("%Y-%m-%d %I:%M %p")
  # objDateTime.year
  # objDateTime.month
 
 
def isDaysOldFromNow( filenamepath, days ):
 
  # Checks how old a file is. Is it older than "days" [variable] days?
  inTimeRange = False  
  timeDeltaDiff = ( datetime.now()-getFileDate( filenamepath ) ).days
 
  # Check if the file's date is days old or less:
  if ( timeDeltaDiff >= days ):
    inTimeRange = True  
 
  return inTimeRange
 
fname = "C:/temp/decision2.pdf"  
 
# Set this variable to check if the file is this days old
howOld = 3
 
 
if ( isDaysOldFromNow( fname, howOld ) ):
  print fname, "is more than", howOld, "days old"
else:
  print fname, "is NOT more than", howOld, "days old"

Output: