Getting non-Aero toolbars for Thunderbird 5 on Windows 7
Thunderbird 5 brings a custom chrome on Windows Vista/7 that uses translucent Aero decorations on toolbars and menubars. Here is how to restore solid backgrounds if you don't like it.
Put the following into chrome\userChrome.css
in your Thunderbird profile directory:
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
window {
background-color: -moz-dialog !important;
}
(Re-)start Thunderbird afterwards.
If you need more info on where the userChrome.css
is suppose...
Check whether an element is visible or hidden with Javascript
jQuery
You can say:
$(element).is(':visible')
and
$(element).is(':hidden')
jQuery considers an element to be visible if it consumes space in the document. For most purposes, this is exactly what you want.
Native DOM API
Emulate jQuery's implementation :
element.offsetWidth > 0 && element.offsetHeight > 0;
jQuery > 3
Query 3 slightly modifies the meaning of :visible (and therefore of :hidden).
Emulate jQuery'...
Mark up text in Balsamiq Mockups
When you edit text in Balsamiq Mockups, you can define inline styles like this:
| Bold | Some *bold* text
|
| Italics | Some _italic_ text
|
| Blue underlined hyperlink | Some [linked] text
|
Note that most Balsamiq widgets display with a bold font by default, so you won't usually see a difference when a piece of text is explicitly marked up as bold.
Matching elements on complex web pages with Webrat
XPath matchers can be combined with CSS-selector matchers. This is really useful if not, for example, the content of an element should be matched but the element itself like in the following example. Here a form is used to display data as default value in its input elements. This can be the case in web applications in which data should be edited easily without additional clicks.
Using StaticMatic for static pages
Update: Staticmatic will not be further developed. They suggest to switch to middleman.
If you need to make a static web page and find yourself missing all your Rails comforts, take a look at StaticMatic.
This works like an extremely stripped down version of Rails, giving you
- HAML
- SASS
- helpers
- partials
When done, everything is simply compiled to s...
Execution of shell code in Ruby scripts
Deprecated ways to execute shell code in Ruby
This is just a reference for legacy code. For new code, always use capture3
.
%x{ } or backticks – quick and easy
Returns the standard output of running the given command in a subshell. This is an alias for `...`, and you can use string interpolation.
Example:
name = 'ls'
result = `which #{name}`
It does not escape anything you inject in the string, so be aware of possible security vulnerabilities...
Center a float horizontally
This card shows you how to center a float horizontally in CSS. Also: find out what techniques are available for your use case and browser requirements in the card linked below.
Note: We have card with all CSS centering options. You probably want to head over there and get an overview over what techniques are available for your use case and browser requirements.
If you cannot use display: inline-block
, centering a float ...
Print-Friendly Images and Logos with CSS
The trick is this: send a low-resolution version of your image to the screen, and a high-resolution version to the printer.
Playing audio in a browser
If you want to play music or sounds from a browser, your choice is to use either Flash or the new <audio>
tag in HTML5. Each method has issues, but depending on your requirements you might not care about all of them.
Flash
- Works in all desktop browsers, even Internet Explorer. Does not work on iPads or iPhones.
- Requires you to embed a Flash component into your page which will later play the audio for you.
- Can play MP3s or Wave files. Cannot play OGG Vorbis audio.
- Cannot reliably seek to a given position when playing VBR-enco...
Apprise - The attractive alert alternative for jQuery
An alert alternative for jQuery that looks good. Apprise is a very simple, fast, attractive, and unobtrusive way to communicate with your users. Also, this gives you complete control over style, content, position, and functionality. Apprise is, more or less, for the developer who wants an attractive alert or dialog box without having to download a massive UI framework.
Use CSS attribute selectors with Capybara
You can use CSS attribute selectors in your step definitions like this:
Then /^the page should have a meta description "([^"]+)"$/ do |description|
page.should have_css("meta[name=\"description\"][content=\"#{description}\"]")
end
Note that you need to always quote attribute values or you will get a Nokogiri parsing error like this:
unexpected 'foo' after 'equal' (Nokogiri::CSS::SyntaxError)
Opera: How to use outlining for better layout debugging
I prefer using Opera's "User mode" to toggle an outlining of HTML elements quickly. This helps greatly when you want to see the actual dimensions of elements, e.g. for floating elements inside containers, instead of opening up the Dragonfly inspector every time.
Navigate to View → Style → "Manage Modes..." and tick the checkboxes like in the attached image. Then, switch to the User Mode by pressing the shortcut (Shift+G for the 9.2-compatible layout or for the default layout with enabled "single-key shortcuts") and select "Outline" from...
Imperative vs Declarative Scenarios in User Stories
Bryan talked about the differences between imperative and declarative scenarios. In my opinion, both styles have benefits and should be used appropriately based on the situation. The majority of examples on rspec's story runner currently on the web, including mine, are of the imperative type. Since the declarative type has many advantages I thought it would be worth while to present some examples and contrast the differences between the two styles.
Different CSS for IE using Sass
At times, it might be unavoidable to have different CSS rules for Internet Explorer than for sane browsers. Using Sass, this can be achieved in a relatively non-hackish way without CSS hacks.
Step 1
Move your current Sass file into a partial. Let's assume it was called screen.sass
. Rename it _screen.sass
.
Step 2
Create two new Sass files:
Call this one screen.sass
:
$ie = false
@import screen
Call this one screen_for_ie.sass
:
$ie = true
@import screen
Step 3
Change y...
PhantomJS: Headless WebKit with JavaScript API
PhantomJS is a minimalistic headless WebKit.
It has fast and native support for various web standards:
DOM handling, CSS selector, JSON, Canvas, and SVG.
PhantomJS can be fully scripted using JavaScript. It is an optimal solution for headless testing of web-based applications, site scraping, pages capture, SVG renderer, PDF converter and many other usages.
Hide Thunderbird's buttons in message headers area
I don't like those buttons inside the header area of a message that Thunderbird 3 put there. Though the CompactHeader addon is often claimed to be a solution it does way too much for me -- I like the headers the way they are, just not the buttons.
This is a bit of a hack but works very well for me (keeps the date and "other actions" menu on the right, see the screenshot below):
- Open up your profile directory (
~/.thunderbird/<profile_name>/
) - Create a
chrome
directory inside it. - Put the attached
userChrome.css
file into the ...
Customize your Bash prompt
The shell variable PS1
holds your bash prompt. You might want to change it to serve your needs best. Here is how to:
General
- non-printing escape sequences in your prompt have to be inclosed in
\[\e[
and\]
so your shell can correctly count its prompt's length - we recommend to highlight your prompt on production machines
- you can also [show different root prompts for each user](https://makandracards.com/makandra/9569-get-the-username-w...
CSS3 Pie: Element not properly redrawn
Pie sometimes does not properly redraw elements upon changes. This often happens when the change comes from somewhere further up the DOM.
Consider something like:
<ul>
<li class="active"><div class="content">Active element</div></li>
<li class="inactive"><div class="content">Inactive element</div></li>
</ul>
with CSS
li .content {
-webkit-box-shadow: #666 0px 2px 3px;
-moz-box-shadow: #666 0px 2px 3px;
box-shadow: #666 0px 2px 3px;
behavior: url(/PIE.htc);
back...
Speed up response time in development after a Sass change
When working with large Sass files you will notice that the first request after a change to a Sass file takes quite some time. This is because the CSS files are being generated from the Sass files the moment the application answers your request (Sass looks at the files and recompiles if the timestamp changed); it takes even longer when you build sprites with the Lemonade gem.
To avoid this, have Sass watch the files for changes and compile them into CSS files immediately. Th...
Prevent floating sibling elements from wrapping in CSS
When you style multiple adjacent block elements with float: left
, they will be rendered next to each other similar to inline elements. Also like inline elements, they will wrap at the horizontal end of the parent container.
If you want to keep floating elements from wrapping, nest them in a really wide container:
<div class="tabs">
<div class="really_wide_container">
<div class="tab">...</div>
<div class="tab">...</div>
<div class="tab">...</div>
</div>
</div>
This is the [Sass](http://sass-la...
Remove quotes from Sass mixin arguments
When calling a Sass mixins, you usually don't need to quote arguments:
+tint_article(#f21)
However, when a CSS property consists of multiple parts (like background
or box-shadow
), the Sass parser will trip up:
+box_shadow(0 1px 2px #000) // this will blow up
The solution is to quote the argument like this:
+box_shadow('0 1px 2px #000')
As the author of the box-shadow
mixin you now need to unquote this string, so the quotes don't appear in the resulting CSS. E.g. the following version of the box-shadow
mixin will...
Check that an element is hidden via CSS with Spreewald
If you have content inside a page that is hidden by CSS, the following will work with Selenium, but not when using the Rack::Test driver. The Selenium driver correctly only considers text that is actually visible to a user.
Then I should not see "foobear"
This is because the Rack::Test driver does not know if an element is visible, and only looks at the DOM.
Spreewald offers steps to check that an element is hidden by CSS:
Then "foo" should be hidden
You can also check that an el...
Using Firebug Lite to inspect HTML in Internet Explorer and other browsers
You know Firebug as a Firefox extension but there is also a "Lite" version which runs purely off JavaScript.
Though all major browsers offer inspection tools you may like the Firebug style. Also, for me this is a lot better than the IE8 developer tools -- and it works in older versions of IE, too.
Get the bookmarklet over at http://getfirebug.com/firebuglite#Stable. It usually loads the JavaScript code from a remote server but you can also download it to have it run locally. If adding the bookmarklet does not work in IE, add a new book...
Styling and scaling for mobile devices
If you want your application to display properly on iPad, iPhone or Android there are two things to do:
Define a stylesheet for mobile devices
Using the media
attribute on stylesheet
HTML tags allows you to have a CSS for mobile browsers:
<!--[if !IE]><!-->
<%= stylesheet_link_tag 'mobile', :media => 'only screen and (max-device-width: 1024px)' %>
<!--<![endif]-->
Here I chose 1024 pixels as the maximum device width to include the iPad. If you want to target only mobile phones, pick 960 to include high-end Android d...