Archive for September, 2007

CSS – How to Select Multiple Descendants

Wednesday, September 12th, 2007

Here’s the story. I had some HTML like this I wanted to style.

<div class="readonly">
   <input name="greg" value="" />
   <textarea name="greg2"></textarea>
</div>

I want to make both input elements and textarea elements have a light
gray background and a dark gray text color.

Thus I figured this CSS would work:

div.readonly input, textarea {
background-color:#eee;
color:gray;
}

But alas that applied the rule to ALL textareas!

It turns out the correct way to do this is:

div.readonly input, div.readonly textarea {
background-color:#eee;
color:gray;
}

Thus the moral is you must fully qualify all descendant selectors for a rule.

My search terms:

  1. css multiple descendants
  2. css + “more than one descendant”
  3. CSS select multiple descendants
  4. CSS selector tutorial

Better Searches Using Google Custom Search Feature

Friday, September 7th, 2007

I made three new custom search engines to help readers research key issues mentioned on this site. Basically each one is limited to search only within the top 3-10 forums, blogs, and support pages for the topic.

These will save a lot of time since you can now do just one search, instead of having to search every forum every time you have a question.

Here they are. Let me know how they work. I’m also adding them to the Helpful Resources sidebar so you’ll always have an easy link to them.

  1. Ubuntu Search (Searching *.ubuntuforums.org, *.ubuntu.com/ )
  2. GoldMine Search (Searching *.frontrange.com, *.contactreview.net, *.castellcomputers.com, *.thegmblog.com)
  3. QuickBooks Search (Searching *.quickbooksgroups.com, *.intuit.com )

Let me know if you have more resources, or blogs I can add to any of these search engines.

Python Code Snippet – Making an Infinite List

Thursday, September 6th, 2007

Here’s a piece of code I’ve found useful. It makes any list infinite. There’s a bit more explanation and some examples in the function’s doc string below. (And I’ve given you some doc tests for free!)

def list_get_cycle(index,alist):
    """Returns the value in the index position of the alist or if the index is
    out of range, the value in the index position if the alist were placed
    end to end infinitely in both directions.
    i.e., it makes the list into a circle/cycle
    >>> list_get_cycle(0,[0,1,2,3,4])
    0
    >>> list_get_cycle(2,[0,1,2,3,4])
    2
    >>> list_get_cycle(4,[0,1,2,3,4])
    4
    >>> list_get_cycle(-2,[0,1,2,3,4])
    3
    >>> list_get_cycle(5,[0,1,2,3,4])
    0
    >>> list_get_cycle(8,[0,1,2,3,4])
    3
    >>> list_get_cycle(-8,[0,1,2,3,4])
    2
    """
    return alist[index%len(alist)]

if __name__=='__main__':
    import doctest
    doctest.testmod()

I find this useful when I want to cycle through values. Yeah, it is pretty trivial though.

One example of where I use this code is in this bracket matching Python utility. (Click edit on that page to see the code.) I have a list of colors, and for each bracket level found, I want to make it a different color. Since there could be infinite levels, but I only have a finite number of colors, this code comes in handy.

Bonus task: Can you modify this code so it works with any iterables, not just lists? You win a free Answer My Searches t-shirt*.

* If I ever decided to sell t-shirts which doesn’t seem likely right now. I mean who would want it?

Mini Searches with Answers

Wednesday, September 5th, 2007

These are links associated with recent searches I’ve done. They’re not difficult enough to warrant to their own posts but still super useful.

Google Account Authentication
Google provides a way for users to share selected google data (gmail, calendar, etc) with 3rd party applications. So it turns out Facebook doesn’t need to ask for your Gmail password. Keep this service in mind when building your next social webapp.

Implementing Dynamic, Infinite Scroll with Ajax, JavaScript, and XML
How to make your content scroll infinitly like Google Reader does with blog feeds.

krank – Google Code
Maybe an instand CRUD website for your database. But what database systems does it support? Why is it in Java?

pefile – Google Code
A portable executable file is what win32 executables are, and what many DLL’s are. This Python program will parse out any portable executable file and tell you all about it.

ASPN : Python Cookbook : Python FTP Client
A useful Python FTP client? It’s worth a try, the FTP library in Python will confuse the Jeebus out of you, so don’t start there.

Here is how to fix the issue where IE puts list style images too close to the items in a list (ul or ol)
It also fixes the issue where IE puts the images too high with respect to the item. The basic concept is too use a background image for each li, position it correctly, and set list-style-image to none.

Screengrab! :: Firefox Add-ons
Firefox extension to save/capture a whole webpage as a screenshot even it scrolls off the page.

snissa.com: Shoot the Web
Another Firefox extension to save/capture a whole webpage as a screenshot even it scrolls off the page.

Save As Image :: Firefox Add-ons
Yet another Firefox extension to save/capture a whole webpage as a screenshot even it scrolls off the page. Does anyone have a preference on these?

Name that Color – Chirag Mehta : chir.ag
This guy is neat, you choose, or type in a hex color and you get its name such as Mauve, codfish yellow, etc. I can’t quite think of a use for this, but I’m sure there is one. Oh perhaps someone could integrate this with Firebug?

CoScripter
A Firefox extension to record your actions on a page, convert them to natural langauge, and share them as replayable scripts. This could be quite handy for helping relatives.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,