Tuesday, 21 January 2014

Display text blurry or fuzzy in Windows 7

Share |

Windows 7 display is not sharp, especially when reading text

One particular day when I upgraded to a new laptop installed with windows 7 and a new external monitor, I was surprised to find that the screen seemed blurry or basically not sharp,  unlike my trusted windows xp in the past (almost like a soft filter from photoshop was permanently applied). It was giving me an eye-strain at the end of every work day, pretty painful to me compared to my previous laptop.

I picked out 3 possibilities as the cause. Either the screen was at fault, the OS was at fault, or the graphics card was the cause.

Things I tried... Used a hdmi cable instead of vga. Nope.
Tried calibrating my external monitors and even trying another. Nope.
This left the OS and graphics card in question.

Switching the graphics card was a troublesome affair compared to the former, so I digged into the OS settings. In windows 7 Control panel-> Display properties, what I found was a little new feature that was previously unknown to me.

This new animal called "ClearType" claimed to make text sharper and clearer.
Using the tuner however did not really satisfy me.
In the end, I resorted to switching this "new" feature off totally.

Now my text is "sharp" like in windows xp, just the way I like it.
Maybe it is not as smooth, but I rather it stay comfortable for my eyes rather than keeping it pretty.





http://techdows.com/wp-content/uploads/2011/10/ClearType-Text-Tuner-in-Windows-7.png
The harmless looking ClearType feature

Friday, 30 August 2013

Change font size of iframe content with Javascript dynamically (No jquery)

Share |
You want to allow your site visitors to change the font size of your site. You know there are examples aplenty online so it would be done in a jiffy. But alas, there are iframes on your site, and this stubborn content refuses to change no matter how hard you try.

"Give me something that just works!" screams in your mind.

Allow users to change font size

If you just want to know how you can access iframe content through javascript, see below. Many solutions employ the jquery library, but not for our case.

function changeIframeFontSize(size) {

var x=document.getElementsByName("iframeName"); //point 1
var y=(x.contentWindow || x.contentDocument);            //point 2
 
var styleElements=['table','p']; //point 3
var j; var i;                                                                    // the loop index
               
   for (j=0; styleElements[j]; j++) {
if (y.document)                                                                    //point 4
x=y.document.getElementsByTagName(styleElements[j]);       
for(i=0; x[i]; i++)
x[i].style.fontSize=size;                                                  //point 5
}
}

Point 1: getElementsByName gets you the reference to your iframe with attribute name of "iframeName".
Eg. <iframe src="/default.asp" name="iframeName"> </iframe>

Point 2: does the magic of actually allowing you to access the DOM elements of your iframe contents.

Point 3: we create this array here, because we want only selected elements in our iframe content affected. So we populate it with the relevant tags that we want.

Point 4: the for loop basically loops through the all the html tags found with getElementsByTagName (variable x is reused solely for convenience sake), and finally...

Point 5: sets the font size dynamically for each and every element.

You can use the above example to build on the work done here, setting them in the resize and reset methods: http://www.dyn-web.com/code/fontsizer/documentation.php#examples

I will post my implementation if there are requests.

Note: This only works if the iframe content belongs on the same domain, eg not from another external site.

Wednesday, 21 March 2012

Display Facebook events feed on website

Share |
Display Facebook events feed on website - From events created from profile, not the Fan Page

Many wordpress plugins at this point in writing did not seem to offer a solution to me. What I am trying to do here is to simply pull out a Facebook event feed and display them on my wordpress page. Meaning event feeds from Facebook with URL format http://facebook.com/events/123456789123456/ for example.

Many implementations out there work for events created from page events instead, those of URL format https://www.facebook.com/pages/Page-Name/123456789123456?sk=events
(A another version on my issue here: http://www.codeproject.com/Questions/348664/Trouble-with-embedding-facebook-events-on-wordpres)

I tried wordpress plugins like facebook-feed-grabber.0.6.zip and jsl3-facebook-wall-feed.1.3.1.zip but they did not do what I needed simply, which is NOT get feeds from Fan Page events.

My PHP implementation here:
1. Have a Facebook app ready for this (https://developers.facebook.com/apps)
2. Get a copy of the Facebook php sdk and put it in your desired folder (https://github.com/facebook/facebook-php-sdk)
3. Create a php file with these few lines below which will allow you to get the feed from your Facebook public event:

<?php 
require 'fb-sdk/src/facebook.php';
$facebook = new Facebook(array(
    'appId'  => 'REPLACE-WITH-FACEBOOK-APP-ID',
    'secret' => 'REPLACE-WITH-FACEBOOK-APP-SECRET',
));
$pageFeed = $facebook->api('REPLACE-WITH-FACEBOOK-EVENT-ID' . '/feed');
?>


(FACEBOOK-EVENT-ID will be 123 if your event url is http://facebook.com/events/123/ )

4. The $pageFeed is an array containing all your event feed details. You can then for example get your first event name with $pageFeed[data][0][name].
5. You can then manipulate this array as you wish and decorate it with some nice CSS styling
6. Finally, if you are using wordpress, you can use the iframe html tag to include this new php file into your wordpress page.

Captured details from Facebook public event

Tuesday, 13 December 2011

Images not showing in WP-carousel

Share |
Images Are NOT displaying in WP-carousel with Customized Content


I was looking for a simple but elegant image slider in wordpress, and WP-carousel seemed just the right fit for my needs. Simple, elegant, but customizable. I installed and activated this plugin with good hope, but alas I just could not get any image to display in my slider with the Customized Content Item. Whats happening here? Desperately searching in the settings yielded no result.

Adding Customized Content feature - SHOW IMAGES!

Its frustrating when you can't get what seems to be a great plugin to work, and just as frustrating when you finally find out the 'great' solution. As in the image above, when adding images, make the Video URL field BLANK (Can't over-emphasize it).

Leaving the default "http://" is a big no-no. Then will the images show up in the slider... oops...

Small issue, but quite an irritation to the first time user I should say. I definitely vote for this to be changed in their next release. WP-carousel do you hear me?

Found on: WP-carousel 1.1

Monday, 7 November 2011

Repair Mac OS X without installation DVD

Share |
Disk Utility - Repair Mac OS X without CD Drive / DVD

Because I frequently dual boot between Windows XP and my Mac OS, there comes a time when my Mac OS gets corrupted as well (there's no hard proof that dual boot causes this, but I would like to believe so since I have cross OS read/write operations on both).

Very well, start Disk Utility and uh oh, "repair" disk option is not available. I restart, and worse, the Mac OS startup screen just gets stuck at the circle animated wheel forever. Ok, I don't panic, went to do some searching on another pc, and tried starting Mac OS X with the "shift" keyboard button pressed down (this is said to run the "repair" disk option). Still no luck.

I CAN'T find my Mac OS installer DVDs.... I cannot run Disk Utility off it no matter how much it wants me so.

Mac OS had it all along. We just need to get into some command line stuff, and you thought Mac OS did not have this unglamorous side.

1. Restart your Mac and get into Single user mode by holding down Apple key+S all the way through the boot-up till you see the ugly black screen with text
2. After everything finishes loading, type in fsck -yf    (fsck stands for file system check). Remember to press enter after typing that of course.
3. Allow it to run and hopefully, you finally get to see the "Disk X appears to be OK." message.
4. Lastly, type "Reboot" to restart back into Mac OS X

Monday, 19 September 2011

Convert FAT32 to NTFS in MAC without WINDOWS

Share |

How to convert external/internal FAT32 drive partition to NTFS with only a MAC



Long story:
Yes its the all not missed 5 year glitch with the hard disk and its all crashing down on you. Now its time to get my Mac OS back up and running which is the easy part (as usual). It is when you want the windows part as well which is the show stopper. Not sure what your unique case is but for me, I needed to switch my FAT32 partition to NTFS, and I did not have any windows installed with bootcamp to use the DOS command line. My cd-drive was faulty, so I could not use my Installer CD either, and I did not want the trouble of removing my drive physically just to bring it to a PC. Many searches online tell you to use Disk Utility in mac, but I CAN'T find that bl**dy NTFS partitioning option. Are they lying? No 3rd party commercial apps for me either.

Disk Utility with NTFS support


Long story short:
1. Download NTFS support, install, restart: http://www.tuxera.com/mac/ntfs-3g-2009.11.14u1-mac_2009-12-07_170539.dmg

2. Open Disk Utility (in mac of course), and *tada* you will now see the option to partition your drive in NTFS format

On a side note: I also recommend WinClone to conveniently archive a clone of your windows partition, makes it easy to backup and restore without re-installing and setup every time.

Note: Against user feedback on this post, I should point out that I was performing this on a fresh windows installation, so any existing windows data will be lost.

Hello fellow readers,

I have noticed a sustained number of users (in terms of 3 figures) every consecutive month on this post. I am quite curious as to the actual reasons behind you searching for and landing on this post. And more importantly, if i can provide better or more useful information to you.

Do help with a short 3 question survey on how I can better help, or you could provide some feedback.

Link to short survey on my website.
All information captured is strictly anonymous and confidential.




 

Friday, 27 May 2011

Limit file upload according to file type extension with Regular Expressions

Share |
Yes its been a while since my last post. A day job keeps people busy. But nothing keeps me far from the web. The last time I saw some gibberish: /.+$/i 
What the... and its hard to search for too if you don't know that its called Regular Expressions (Doesn't seem all that very regular to me).


So, I was trying to allow users to do a file upload, but yet only restrict them to certain files types. Searching along the correct keywords and doing some quick learning did reveal some tricks. I do not seek to repeat the meaning of every expression here, this can be found easily. Rather, I will highlight a few pointers for those unacquainted.

Basically its a syntax, and the purpose is to do string matching. The combination of characters that you see in the gibberish above are actually rules to when tested upon your string of concern, results in a successful match, or a mismatch.

In the end, you realize that certain keyboard characters like full-stop (.) and the dollar sign ($) each represent a special meaning.

The full-stop: (Matches any single character except line break characters \r and \n. )
The dollar-sign after the full-stop: (.$ will return you a match for the last character in the string, and  ..$ will return you the last 2 characters in the string.)
The backslash: (If you want to actually test for a match of those special characters in your expression itself, and not use them programmatically. Used to escape those characters.)

I know it can seem confusing, but you can easily try it out here http://www.regular-expressions.info/javascriptexample.html for practice.

Finally for myself, I ended up with /\.wav\b|\.aif\b/


The \ escapes the full-stop that I want to match in my expression, and the \b means that I want a match of .wav file extension type at the word boundary of my file name (Assuming file name cannot be .wavRestOfFilename or .aifRestOfFilename). The | means a logical OR, either the left or right expression is accepted.

Therefore, I end up only matching files that end with file extension type of only  .wav or .aif.

Tada!


Quick links:
http://www.regular-expressions.info/reference.html
http://www.roblocher.com/technotes/regexp.aspx