Wednesday, August 20, 2014

Install XBMC in Fedora 20




The following steps describe the process of installing XBMC in Fedora 20.

1. Install xbmc.
# yum install xbmc

2. Run xbmc.
# xbmc

If the following  error occurs. Please install ffmpeg or libvpx.
/usr/lib/xbmc/xbmc.bin: symbol lookup error: /lib/libavcodec.so.55: undefined symbol: vpx_codec_vp9_dx_algo

3. Install ffmpeg and libvpx.
# yum install ffmpeg\*
# yum install libvpx

4. Run xbmc again.
# xbmc

You can see the XBMC GUI display.

5. Setting IMDB as movie scraper.

The following VIDEO teach you how to set IMDB as movie scraper for XBMC.
http://youtu.be/RSOiPvScPyI

You can see it.





Tuesday, August 19, 2014

Explain the UEFI Secure Boot

The Secure Boot technology is defined by UEFI specification. BIOS uses RSA algorithm to check the integration of the booted OS and to verify if the booted OS is released by the OS vendor.  Let's show the algorithm of Secure Boot.

OS vendor signs OS Loader with Private Key:
{PublicKey, PrivateKey} = GenerateKeyPair ()
Digest = Hash (OsLoaderCode)
Signature = Encrypt (Digest, PrivateKey)
OsLoader = {OsLoaderCode, Signature}

BIOS Vendor enrolls signature into BIOS:
Db = {header, SigList, ...}
SigList = {Sig, ...}
Sig = {..., Cert}
Cert = {..., PublicKey}

BIOS verifies OS Loader before starting it.
Digest = Hash (OsLoaderBody)
Digest2 = Decrypt (Signature, PublicKey)
if (Digest == Digest2) {
  The OsLoader is verified successfully.
  Start the OsLoader.
}


Monday, August 18, 2014

How to backup iPad or iPhone in USB disk drive on Windows?

We always backup iPad or iPhone with iTunes on Windows. The backup data are stored in C drive. The backup path is for example.

C:\Users\[USER_NAME]\AppData\Roaming\Apple Computer\MobileSync

A problem is that there is often not enough space in the C drive. It seems that there is not an easy way to change the backup path to our USB disk drive. We can use the mklink command before running iTunes to solve the problem. For example,

mklink /j "C:\Users\[USER_NAME]\AppData\Roaming\Apple Computer\MobileSync" "F:\iPad Backup\MobileSync"

The F drive is a USB disk drive. We create a link of MobileSync under "Apple Computer" directory. It links to our MobileSync in the USB disk drive. When we run iTunes to backup, the data are really stored in F drive, not in C drive, even though iTunes only recognizes the path, "Apple Computer\MobileSync".

Monday, April 14, 2014

PyQt addToolBarBreak () - Create Two Toolbars

We can use addToolBarBreak () to create two toolbars. One is followed by another with a line break. Here is an example of PyQt.

import sys
from PyQt4 import QtGui

class MyMainWindow (QtGui.QMainWindow):
   
    def __init__ (self):
        super (MyMainWindow, self).__init__ ()
       
        Toolbar1 = self.addToolBar ("")
        self.addToolBarBreak ()
        Toolbar2 = self.addToolBar ("")
       
        Cb = QtGui.QComboBox ()
        Toolbar1.addWidget (Cb)
        Cb = QtGui.QComboBox ()
        Toolbar1.addWidget (Cb)

        Cb = QtGui.QComboBox ()
        Toolbar2.addWidget (Cb)
        Cb = QtGui.QComboBox ()
        Toolbar2.addWidget (Cb)
       
        self.setGeometry (300, 300, 300, 200)
        self.setWindowTitle ('Multiple Toolbars')
        self.show ()
       
def main():
    App = QtGui.QApplication (sys.argv)
    MainWindow = MyMainWindow ()
    sys.exit (App.exec_ ())

if __name__ == '__main__':
    main()



We can also use addToolBarBreak () to create multiple toolbars.

Thursday, April 3, 2014

PyQt QTextEdit - Get the current line number when/where the mouse is pressed.

Here is an easy way to get the current line number in QTextEdit when/where you press mouse. This way doesn't derive QTextEdit or install event filter. This way just delegates mouseReleaseEvent to your event handler.

import sys
from PyQt4 import QtCore, QtGui

class MainWindow (QtGui.QMainWindow):

    def __init__ (self, parent=None):
        super (MainWindow, self).__init__(parent)

        self.BuildEditor ()
        self.setCentralWidget(self._Editor)
        self.setWindowTitle("Get line number in QTextEdit when mouse is pressed.")

    def BuildEditor (self):
        self._Editor = QtGui.QTextEdit ()
        self._Editor.setReadOnly (True)
        self._Editor.mouseReleaseEvent = self.MyMouseReleaseEvent
        
        Font = QtGui.QFont ()
        Font.setFamily ('Courier')
        Font.setFixedPitch (True)
        Font.setPointSize (10)
        self._Editor.setFont (Font)

        Text = "aaaaaaaaaaaaaaaaaaaaaaa\n"
        Text += "bbbbbbbbbbbbbbbbbbbbbbb\n"
        Text += "ccccccccccccccccccccccc\n"
        Text += "ddddddddddddddddddddddd\n"
        self._Editor.setPlainText (Text)
       
    def MyMouseReleaseEvent (self, Event):
        print ("Release the mouse.")
        Pos = Event.pos()
        print ("Pos = (%d, %d)" % (Pos.x (), Pos.y ())) 
        Cursor = self._Editor.cursorForPosition (Pos)
        X = Cursor.columnNumber();
        Y = Cursor.blockNumber();        
        print ("Cursor = (%d, %d)" % (X, Y))    
        
if __name__ == '__main__':
    App = QtGui.QApplication (sys.argv)
    Window = MainWindow ()
    Window.resize (640, 512)
    Window.show ()
    sys.exit (App.exec_())

Wednesday, March 5, 2014

How to connect to Internet with PPPoE for Fedora 20

You want to connect network through PPPoE to get fixed IP address provided by ISP. Because Fedora 20 doesn't have a GUI to setup PPPoE setting, you must to manually specify it.

1. Find your network interface name.

ifconfig

You find that p3p1, for example, is your interface name. It is different with eth0 for the old Fedora version for some reasons.

2. Setup PPPOE settings.

pppoe-setup

Please specify your network interface to p3p1. Please remember to specify DNS otherwise Web Browser cannot work. You can refer the page for the details. http://blog.xuite.net/michaelr/linux/69281107

3. Connect PPPOE.

/sbin/ifup ppp0

Or

adsl-start
4. Check if the PPPoE is workable.

/sbin/pppoe-status

5. Disconnect PPPoE.

/sbin/ifdown ppp0

It is danger to use Python shutil.rmtree () to remove a symbolic link directory.

It is danger to use Python shutil.rmtree () to remove a symbolic link directory in Windows because the function recursively remove files under a given directory. We should replace it with.

os.system ("rd \"%s\"" % Dir)