Wednesday, March 21, 2012

CSS: Select ID or class with a slash or quote in it

I recently faced the interesting task of CSS-selecting an ID that looked like this:

\"ws_widget\"

What is that monster? It is an ID with a slash AND a quote in it.

Here is what the CSS rule looks like:

#\\\"ws_widget\\\"{
position:relative;
}

There is a slash to escape the first slash, and another slash to escape the quote.

If you only had slashes in your ID, like the following:

\my_id\

the proper CSS selection would look like this:

#\\my_id\\ {}

Sunday, December 18, 2011

How to add new subscriptions in Google Reader

After the recent changes to Google Reader I wanted to subscribe to a new blog and spent about 10 frustrating minutes looking around the interface to find a subscribe button. I eventually ended up pressing random letters on my keyboard, knowing that one of them would open the subscription dialogue box. It happened to be the letter 'A'.

Today I found out that the subscription link can be found by hovering your mouse over 'Subscriptions', which reveals a downward arrow on the far right, pressing this arrow opens a menu, and at the bottom of this menu there is an 'Add new subscription' link.

Quick instructions: Press 'A' on your keyboard, or hover your mouse over Subscriptions->Press the downward arrow on the far right->Click on the 'Add new subscription' link.

Sunday, October 9, 2011

A Photoshop-like guide (or ruler) for Windows

If you open a window (such as the calculator, Notepad, or Explorer), you can use the window's edge as a guide to align elements (pretty useful in web design if you don't want to use anything fancy).

What makes this technique especially helpful is that while dragging the window, you can press the Ctrl key, then use the arrow keys to shift the guide pixel by pixel.

Friday, July 29, 2011

Solution: Asus Eee PC 1015XP stuck on update

So a new netbook in my possession was stuck on the "Installing update, please do not turn off...". I wanted to restart it but pressing the power button didn't work. What I did was remove the battery, which worked.

Sunday, June 5, 2011

Solution for Perl: JSON AJAX string is broken (corrupted) on space

There seems to be a bug with CGI.pm's param() method when it processes input that doesn't have a 'key', such as JSON input, it breaks it up if you use the default 'keyword' key.

The solution is that in JavaScript change your JSON like this:
var json = JSON.stringify(stuff); //like normal
var key = 'sham='; //this can be any string--followed by the equal sign
var finaloutput = key+json;
finaloutput is the string you'll send to the server.

On the server side, do this:
if(param()) {
  my $json = param('sham'); #sham is the string you chose as the key
}

Things should work correctly from there.

Saturday, March 19, 2011

Perl boolean XOR

Perl's bitwise XOR is ^, but what is the boolean XOR operator? It is just xor:
say (1 xor 0)
The above code returns 1 signifying a true return value.

It is at the bottom of the precedence chart, you'll often have to use parenthesis to make it work correctly.

Friday, February 18, 2011

Can 32-bit programs make use of more than 4 Gigabytes of RAM?

The answer seems to be yes.

I run Windows 7 64-bit. I had 4 Gigabytes of RAM, and since I always have Linux running inside Windows, and since I have disabled the Windows pagefile (performance is much, much better with this disabled. Minimized programs open up in an instant now, even with 20 programs open at the same time), I kept getting the low RAM message. This usually happened when browsing the web and opening many tabs.

I bought a good 1GB RAM stick for $20 on Newegg.com and installed it today. To test whether my 32-bit programs can benefit from the extra RAM, I opened up Google Chrome (a 32-bit program) and started opening a high quality picture in many tabs. After opening it in 20-30 tabs, my RAM usage approached the 5 gigabyte limit and I received the low memory warning.

This proves that somehow Windows 7 can allow 32-bit programs to utilize areas of RAM that theoretically can't be addressed using the 32-bit system.

Therefore regardless of whether the programs you use are 32-bit or 64-bit, as long as you use Windows 7 64-bit, you can make good use of 4GB+ RAM.

Tuesday, February 15, 2011

Notepad++: Change Vertical/Horizontal Split Orientation

  1. Right-click on the dotted border between the two views.
  2. Click on the rotation you want.

Saturday, February 12, 2011

How to attach and send executable files in Gmail

Put the file in a password-protected zip or RAR archive. You can do this with WinRAR, probably 7Zip too.

Then attach and send.

Friday, February 4, 2011

How to type a semicolon in Arabic

Use Shift + P. (i.e. press the P key while holding down the shift key)

My settings for typing Arabic are Saudi Arabia - Arabic 101 Keyboard Layout.

As a side note, to type a comma use Shift + K, rather than Shift + <, since the latter types something that doesn't look like a proper Arabic comma.

Friday, January 7, 2011

How to change Ubuntu keyboard cursor shape

I searched all over the web for an answer to that question yesterday but found nothing. Today I found it by accident while working on the terminal.

In the Edit menu click 'Profile Preferences', then on the 'General' tab choose the cursor shape you want where it says 'Cursor shape:'.

Monday, January 3, 2011

How to extract (decompile) CHM files into HTML

The free 7-Zip program has a very useful 'extract' feature for CHM files. After installing 7-Zip, right click on the CHM file, point to '7-Zip' in the menu, then click one of the 'Extract...' options.

The great thing about decompiling CHM files is that I can now read CHM books inside Google Chrome, rather than inside Microsoft's horrible browser.

A great free desktop search engine

I've been using Locate32 for years without knowing that it has an amazing feature (amazing, of course, by Windows standards.) It has an 'Advanced' tab that lets you search a particular type of file, such as text files, for a particular text string. It depends on the "Name & Location" tab to know which file names to search. If in the "Name & Location" tab you leave the "Named: " text box empty, Locate32 will search every file in its database for your query.

This is highly superior to Google Desktop with its various limitations on what you can do. For example, Locate32 lets you specify a single folder to search for the word you want, using the "Look in: " box in the "Name & Location" tab.

Tuesday, December 28, 2010

Solution for Error: Cannot retrieve repository metadata (repomd.xml) in Fedora 14

I know this is pretty basic: Check if your internet connection is on. If it is not, Linux cannot reach the repository. This is how I fixed the problem.

Monday, October 19, 2009

Monday, May 18, 2009

Difference between str and repr in Python

Both of them convert values to strings, str changes the look of the value, while repr keeps its looks. str converts the data to a reasonable looking format, in other words it translates the data. While repr just takes a picture of the data and draws it again in string format, thus not changing its look.

Thursday, April 9, 2009

Solution for Active Desktop Recovery popping up after every restart [Windows XP]

Go to this registry key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\SafeMode\Components

Change the value of DeskHtmlVersion to zero.

Tuesday, March 31, 2009

Solution for blogger template's "undefined" date

Some templates, especially those imported from wordpress, show the dates in new cool ways which don't always work for blogger.

To solve this, change the Timestamp format in the Settings-->Formatting tab. Changing it to the 4th one solved my problem.

Thursday, March 19, 2009

Wednesday, March 11, 2009