~ Mayank Johri’s Tips ~

October 15, 2009

Convert Virtualbox vdi to VMware vmdk Files

Filed under: Tips — mayankjohri @ 10:57 am
Tags: ,

QEMU-IMG can be used to convert virtualbox vdi file to vmware vmdk file

qemu-img.exe convert -O vmdk virtualbox.vdi vmware.vmdk

October 12, 2009

demo code for wx.TaskBarIcon

Filed under: Python, Tips — mayankjohri @ 3:08 pm
Tags:

Below is the demo code for wx.TaskBarIcon,

import wx
class sysTrayDemo(wx.Frame):
    def __init__(self, parent, id, title):
        pass
        wx.Frame.__init__(self, parent, -1, title, size = (800, 600),
                         style=wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE)
        # FIXME: substitute your icon file here.
        icon = wx.Icon('systray.ico', wx.BITMAP_TYPE_ICO)
        self.SetIcon(icon)
        if wx.Platform == '__WXMSW__':
            # setup a taskbar icon, and catch some events from it
            self.tbicon = wx.TaskBarIcon()
            self.tbicon.SetIcon(icon, "SysTray Demo")
            wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnTaskBarActivate)
            wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.OnTaskBarMenu)
            wx.EVT_MENU(self.tbicon, self.TBMENU_RESTORE, self.OnTaskBarActivate)
            wx.EVT_MENU(self.tbicon, self.TBMENU_CLOSE, self.OnTaskBarClose)
        wx.EVT_ICONIZE(self, self.OnIconify)
        return
    def OnIconify(self, evt):
        self.Hide()
        return
    def OnTaskBarActivate(self, evt):
        if self.IsIconized():
            self.Iconize(False)
        if not self.IsShown():
            self.Show(True)
        self.Raise()
        return
    def OnCloseWindow(self, event):
        if hasattr(self, "tbicon"):
            del self.tbicon
        self.Destroy()
    TBMENU_RESTORE = 1000
    TBMENU_CLOSE   = 1001
    def OnTaskBarMenu(self, evt):
        menu = wx.Menu()
        menu.Append(self.TBMENU_RESTORE, "Restore SysTray Demo")
        menu.Append(self.TBMENU_CLOSE,   "Close")
        self.tbicon.PopupMenu(menu)
        menu.Destroy()
    #---------------------------------------------
    def OnTaskBarClose(self, evt):
        self.Close()
        # because of the way wx.TaskBarIcon.PopupMenu is implemented we have to
        # prod the main idle handler a bit to get the window to actually close
        wx.GetApp().ProcessIdle()
class MyApp(wx.App):
    def OnInit(self):
        self.redirect=True
        frame = sysTrayDemo(None, -1, "SysTray Demo")
        frame.Show(True)
        return True
def main():
    app = MyApp()
    app.MainLoop()
if __name__ == '__main__':
    main()

December 10, 2008

TIPS: Linux : Compress a directory

Filed under: Linux, Tips — mayankjohri @ 3:22 pm
Tags: ,

The following command can be used to compress entire directory in a file :

tar cjf <FileName>.tar.bz2 <DirectoryPath>

December 1, 2008

Tips: Convert flv to mpg or avi

Filed under: Tips — mayankjohri @ 12:36 am
Tags: ,

Following converts video.flv into video.mpg file:

CODE
ffmpeg -i video.flv -ab 56 -ar 22050 -b 500 -s 320x240 video.mpg

and following converts  video.flv into video.AVI with MP3 Audio:

CODE
ffmpeg -i I_test.flv -ab 56 -ar 22050 -b 500 -s 320x240 -vcodec xvid -acodec mp3 video.avi

November 11, 2008

TIPS: DELTREE in Windows XP

Filed under: Tips, Windows — mayankjohri @ 1:43 pm
Tags: ,

deltree can be simulated using the following .cmd file:

  1. Create an empty file deltree.cmd in %windir%\system32 folder
  2. Add the following content to the file, and save the file.

@echo off
del /S /F /Q %1
rd /S /Q %1

October 20, 2008

Switching back to Linux when Gnome-RDP in full screen

Filed under: Linux, Tips — mayankjohri @ 8:02 pm
Tags: ,

Ctrl+Alt+Enter will return you from full-screen mode.

You can use the same set of keystrokes to enter into the full-screen mode.

October 7, 2008

checking ext3 filesystem using fsck

Filed under: Linux, Tips — mayankjohri @ 3:13 pm
Tags: ,

use the following command for checking ext3 filesystem using fsck

fsck -c <drive>

<drive>: path of drive which you like to get scanned,

NOTE: IT Is aways advice to unmount the partition which needs to be scanned.

September 22, 2008

Disable “Use the web service to find the appropriate program”

Filed under: Tips, Windows — mayankjohri @ 8:03 pm
Tags: ,

Create the following DWORD key NoInternetOpenWith = 1 at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

September 18, 2008

Tips: Linux: Mount NTFS Share

Filed under: Linux, Tips — mayankjohri @ 2:02 pm
Tags: ,

 

mount -t cifs //<IPAddressOfRemoteMachine>/<Share> -o username=myntaccount,password=mypassword /mnt/ntfs

September 17, 2008

FAQ: App-V: How to use the custom Exclusion List while Sequencing

Steps to create the custom exclusion list.

  1. Launch the AppV sequencer.
  2. Goto Tools -> Options
  3. Select “Exclusion Items” tab
  4. Add new exclusion items using “New Button”
  5. When all the exclusion items are added then press “Save As Default” button
  6. Copy the default.sprj file from “C:\Program Files\Microsoft Application Virtualization Sequencer\” or the folder where the sequencer was installed to some network share from where it can be accessed later.

Using the custom exclusion list

  1. Copy the saved default.sprj file to “C:\Program Files\Microsoft Application Virtualization Sequencer\” before launching the Sequencer.
  2. When launched the sequencer will take the exclusion list from the default.sft file.

September 12, 2008

Imaging WinXP using Knoppix

Filed under: Tips, Windows — mayankjohri @ 1:22 pm
Tags: ,
  1. Boot from knoppix
  2. Repartition your drive
    1. Base Partition – This is were your winXP is installed
    2. Image Partition – this is were your image of windows xp will be copied
  3. mount the  image partition: mount /dev/sda2 /media/img
  4. Use the command to create the img: ntfsclone -s -o /media/img/winxp.img /dev/sda1
  5. use the command to restore the img: ntfsclone  –restore-image -O /dev/sda1  /media/img/winxp.img
  6. Enjoy

Note: It is a good idea to have ext3 as filesystem for your image partition so that the image file is not deleted accidentally and also it overwrites the FAT32 2GB filesize limit.

September 8, 2008

TIPS: dbus: UUID file ‘/var/lib/dbus/machine-id’ contains invalid hex data

Filed under: Linux, Tips — mayankjohri @ 3:00 pm
Tags: ,

Whenever you get the above error then it can be resolved by executing the following command

dbus-uuidgen > /var/lib/dbus/machine-id

TIPS: dpkg Error: dpkg: too many errors, stopping

Filed under: Tips — mayankjohri @ 12:47 pm
Tags: ,

apt-get and dpkg are great package management tools but there might be a time that you can face the following error:

dpkg: too many errors, stopping

also when you try `apt-get upgrade` or `apt-get dist-upgrade` you will be adviced that the previous application installation was not successful thus they should execute `dpkg –configure -a` and it returns the above error.

To resolve the issue run the following command

dpkg --configure -a --abort-after=99999

July 30, 2008

MAC OS Keys

Filed under: MAC OS, Tips — mayankjohri @ 1:33 am
Tags: ,

Startup
Keystroke Description
Press X during startup Force Mac OS X startup
Press Option-Command-Shift-Delete
during startup Bypass primary startup volume and seek a different startup volume (such as a CD or external disk)
Press C during startup Start up from a CD that has a system folder
Press N during startup Attempt to start up from a compatible network server (NetBoot)
Press R during startup Force PowerBook screen reset
Press T during startup Start up in FireWire Target Disk mode
Press Shift during startup start up in Safe Boot mode and temporarily disable login items and non-essential kernel extension files (Mac OS X 10.2 and later)
Press Command-V during startup Start up in Verbose mode.
Press Command-S during startup Start up in Single-User mode (command line)

July 8, 2008

creating windows service using pyinstaller

Filed under: Python, Tips — mayankjohri @ 7:45 pm
Tags: ,

copied from http://www.nabble.com/windows-service-sample-using-pyInstaller-td16626208.html

# Usage: 
# service.exe install
# service.exe start
# service.exe stop
# service.exe remove

# you can see output of this program running python site-packages\win32\lib\win32traceutil 

import win32service

import win32serviceutil
import win32event
import win32evtlogutil
import win32traceutil
import servicemanager
import winerror
import time
import sys

class aservice(win32serviceutil.ServiceFramework):

    _svc_name_ = "aservice"
    _svc_display_name_ = "aservice - It Does nothing"
    _svc_deps_ = ["EventLog"]

    def __init__(self,args):
        win32serviceutil.ServiceFramework.__init__(self,args)

        self.hWaitStop=win32event.CreateEvent(None, 0, 0, None)
    self.isAlive=True

    def SvcStop(self):

        # tell Service Manager we are trying to stop (required)
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)


    # write a message in the SM (optional)
        # import servicemanager
        # servicemanager.LogInfoMsg("aservice - Recieved stop signal")

    # set the event to call
        win32event.SetEvent(self.hWaitStop)


    self.isAlive=False

    def SvcDoRun(self):
        import servicemanager
        # Write a 'started' event to the event log... (not required)
       
#
win32evtlogutil.ReportEvent(self._svc_name_,servicemanager.PYS_SERVICE_STARTED,0,
servicemanager.EVENTLOG_INFORMATION_TYPE,(self._svc_name_, ''))


        # methode 1: wait for beeing stopped ... 
        # win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

        # methode 2: wait for beeing stopped ...
        self.timeout=1000  # In milliseconds (update every second) 


        while self.isAlive:

            # wait for service stop signal, if timeout, loop again
            rc=win32event.WaitForSingleObject(self.hWaitStop, self.timeout) 

            print "looping"


        # and write a 'stopped' event to the event log (not required)
       
#
win32evtlogutil.ReportEvent(self._svc_name_,servicemanager.PYS_SERVICE_STOPPED,0,
servicemanager.EVENTLOG_INFORMATION_TYPE,(self._svc_name_, ''))


        self.ReportServiceStatus(win32service.SERVICE_STOPPED)

    return

if __name__ == '__main__':

    # if called without argvs, let's run !

    if len(sys.argv) == 1:
        try:

        evtsrc_dll = os.path.abspath(servicemanager.__file__)
        servicemanager.PrepareToHostSingle(aservice)
        servicemanager.Initialize('aservice', evtsrc_dll)
            servicemanager.StartServiceCtrlDispatcher()

        except win32service.error, details:
            if details[0] == winerror.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT:
                win32serviceutil.usage()
    else:
        win32serviceutil.HandleCommandLine(aservice)

July 5, 2008

Get the windows service state using Python

Filed under: Python, Tips, Windows — mayankjohri @ 10:55 pm
Tags: ,

following code can be used to find if any service is installed and if so then return the state of the service.

import wmi

class servicePython():
    def __init__(self, serviceName):
        self.c = wmi.WMI ()
        self.serviceName = serviceName

    def setServiceName(self, serviceName):
        self.serviceName = serviceName

    def getStatus(self):   
        srv = c.Win32_Service (name=self.serviceName)
        if srv != []:
            return c.Status
        return False

June 10, 2008

TIPS: WX.Python.Grid: Removing the selected Rows

Filed under: Python, Tips — mayankjohri @ 1:27 pm
lst = None
no = self.grid_ShareDetails.GetNumberRows()
lst = sorted(self.grid_ShareDetails.GetSelectedRows())
lst.reverse()
for l in lst:    
    self.grid_ShareDetails.DeleteRows(l,1)

May 29, 2008

Tips : wx.Python : Close button not working.

Filed under: Python, Tips — mayankjohri @ 4:33 pm

If the close button does not work then add the following entries

self.Bind(wx.EVT_CLOSE, self.quit)

under the __init__ function and create a new function as

def quit(self, event):
self.Destroy()

April 15, 2008

Disable the “Use the Web service to find the correct program” Dialog

Filed under: Tips, Windows — mayankjohri @ 8:23 pm

Create the following DWORD key NoInternetOpenWith = 1 at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer

March 3, 2008

A nice Defrag Utility

Filed under: Tips, Windows — mayankjohri @ 9:21 pm
Tags:

Today i came across a nice  defrag utility which is free and have most of the features, One can download it from http://www.defraggler.com/.

Next Page »

Blog at WordPress.com.