Yearly Archives: 2014

Solution: Lenovo Thinkpad w540 black LCD screen (only external monitor works)

I spend ungodly amount of time trying to solve this issue, there were many similar issues reported on Lenovo forums, but no solutions and contacting Lenovo support is akin jumping thru hoops of fire.

The problem began after I plugged my brand new Thinkpad w540 into external monitor and set it to mode “Extended display (monitor + built-in screen). For a while everything worked fine, but then laptop own screen went black – and nothing could revive it. The external monitor worked fine and the maddening part was – when laptop booted – Lenovo logo appeared bright and shiny on laptop own screen, so I knew graphics card was OK. I ran full Lenovo System update, I updated NVidia drivers from Nvida site – nothing helped.

Then I tried to update Intel drivers for laptop’s HD Graphics 4600 card. Intel installer refused to install them because “The driver being installed is not validated for this computer“. To bypass that I

1. Unzipped the installer package into it’s own folder (you can use WinRar to unpack actual EXE or you can download Zip version of the package).
2. Went to Device Manager, right clicked on “HD Graphics 4600 card” driver and selected Update.
3. When prompted I selected “Browse my computer for driver software”
4. Selected “Let me pick from list of Device Drivers”
5. Clicked “Have disk” and browsed for an INF file inside of GRAPHICS folder of the unpacked driver files from Step 1

Installation commenced and lo and behold – laptop’s display sprang to life.

These instructions are specific to this laptop model and videocard, but I imagine they might be helpful in other similar situations. And hopefully Lenovo will take notice and finally update their drivers.

Access nested controls in ASP.NET Page PreInit event (when no Master Page is involved)

There’re situations when you need access ASP.NET web controls very early in page lifecycle, more specifically – in Page PreInit event – and you can, but only top-level controls. But what if you need to access child/nested controls? The example below uses Infragistics WebHierarchicalDataGrid as a child of Infragistics WebSplitter, but this pretty much applies to any such scenario.

Let’s say you have following layout

<ig:WebSplitter ID="WSP" runat="server">
   <Panes>
      <ig:SplitterPane runat="server">
         <Template>

            <ig:WebHierarchicalDataGrid ID="WHG" runat="server">
            </ig:WebHierarchicalDataGrid>

         </Template>
      </ig:SplitterPane>
      <ig:SplitterPane runat="server"></ig:SplitterPane>
   </Panes>
</ig:WebSplitter>

As you can see grid “WHG” is nested withing first pane of splittet “WSP. Let’s see what happens if you try access the controls in PagePreInit event: Continue reading →

Developing first Pebble.js app

    

Pebble Smartwatch has offered SDK to develop watchfaces and watchapps in C language for a while now. But most recently they tried something different: Pebble.JS a project that lets you code for Pebble in JavaScript. Unlike native app – JS code runs on your phone, so it’s not as fast, and Bluetooth communication required to display any data, but there’re numerous advantages as well.

To test it I decided to write a simple app that would use basic, but important features of Pebble.JS: displaying of information card (a la Pebble notifcation), using menu and executing an AJAX call to bring information from the Net.

Enter AutoInsult for Pebble – application that is based on autoinsult.com – it generates a random insult based on style you selected.
Continue reading →

Access jQueryUI dialog buttons after dialog was created

If you’re using jQuery UI Dialog, you know sometimes there’s a need to access dialog’s button objects after the dialog has already been created. This can be easily done via

$(dialogElement).dialog("option").buttons

command. One possible scenario where this can be useful – is executing specific button click function when user clicks [X] in dialog title. Imagine that buttons are set via array and the last object in this array is always something like CANCEL or NO or DISREGARD – and you want to simulate click of that last button whenever user clicks [X]. Using above command it’s pretty straightforward:

$(oDivDialog).dialog({
   //... some dialog parameters
   buttons: arrayOfButtonObjects,
   //... some more parameters
   close: function () {
      var buttons = $(this).dialog("option").buttons;
      buttons[buttons.length - 1].click();
   }
})

Line 5 begins close event which is called on dialog closing.
Line 6 retrieves array of buttons for the dialog
Line 7 calls click() function of the last button in the array

Infragistics WebDataMenu: Manual postback from client-side Click event

There’s a a few possible scenarios when you need to manually to initiate server-side Click event of Infragistics WebDataMenu control. For example in client side click event you do some verification/user confirmation and upon positive confirmation (e.g. user clicks YES) – server-side Click event should kick in.

In a normal flow of event you can use set_cancel(bool) method to allow/disallow natural menu postback e.g.

function Menu_ItemClick(sender, eventArgs) {

   if (confirm('Are you sure?'))
       eventArgs.set_cancel(false)
   else
       eventArgs.set_cancel(true)

}

This works because this dialog stops code execution waiting for the user input. But what if you use something like jQueryUI dialog that relies on callback functions to get user feedback? In this case execution of the code continues immediately so you have to cancel postback right away and instead in the callback of the dialog initiate manual postback e.g

function Menu_ItemClick(sender, eventArgs) {

   $("#dialog").dialog({
      resizable: false,
      height:140,
      modal: true,
      buttons: {
        "Yes": function() {
          $(this).dialog("close");
          __doPostBack(sender.get_id(), 'ItemClick' + eventArgs._getPostArgs());
        },
        "No": function() {
          $(this).dialog("close");
        }
      }
   });  

   eventArgs.set_cancel(true)

}

The example above initiates modal confirmation jQuery UI dialog and immediately cancels menu postback (Line 18). Later if user clicks “Yes” button – dialog is closed and manual menu postback is initiated (Line 10) – it passes menu ID and correct postback argruments which result in server-side Click event of menu control. If user clicks “No” – dialog is closed and nothing else happens.

Solution for NFC not working on Samsung Galaxy phone

This has been bothering me for a while – NFC refused to work on my Samsung Galaxy phone. Service was enabled and running, no errors or warning were displayed, but phone was unable to detect any NFC presence – tags, stickers, point of sale etc.

I was wrecking my mind until I realized that a while back I replaced the original Samsung Battery with a higher capacity generic one to extend battery life. But original Samsung Battery acts as an NFC antenna as well!

As soon as I put original battery in – lo and behold NFC sprang to action.

SAY NO TO FLASH!

Say no to flash Just say no. And tell your kids never to use this piece of junk. And not only because its obsolete and has been replaced by HTML5 long ago. It also promotes bloatware and malware.

I got a prompt from my current Flash player that an update is available. So I ran the update – first it tried to download and install that bloatware of McAfee and only failed because connection to McAfee site failed. But that wasn’t all.

After install finished, I found that my browser was hijacked by “Trovi” malware – start page, search engine etc. And this was done by official installer from Adobe site! Wtf?!

Bye Flash, you won’t be missed.

Reenable (temporary) showModalDialog support in Chrome (for Windows) 37+

You know you shouldn’t use showModalDialog to open modal windows – it’s bad taste and prone to cause issues. Unfortunately many applications (especially Enterprise ones) rely on the method ability to halt code execution until the window closed (e.g. user answers a YES/NO question).

Tough luck, starting version 37 Google Chrome removed support for showModalDialog. Your code suddenly began to act in weird and unpredictable way. You definitely should rework it to use a different approach to dialogs. Fortunately Google gives you a bit more time. You can re-enable showModalDialog support, but only temporarily – until May of 2015. Continue reading →