Tuesday, November 1, 2011

How to use Unix/Linux commands at the Windows command prompt

source: http://www.root777.com/security/how-to-use-unixlinux-commands-at-the-windows-command-prompt/


A lot of us who use Linux at work/school or have always grown up using unix commands for years and more often than not, there might have been instances where a ls command comes more naturally than the dir command at the command prompt in Windows. For the most part, a lot of us work around this drawback using the excellent tool: Cygwin. Cygwin is available for windows users here.The Cygwin tools are ports of the popular GNU development tools for Microsoft Windows. They run thanks to the Cygwin library which provides the UNIX system calls and environment these programs expect.
With these tools installed, it is possible to write Win32 console or GUI applications that make use of the standard Microsoft Win32 API and/or the Cygwin API. As a result, it is possible to easily port many significant Unix programs without the need for extensive changes to the source code. This includes configuring and building most of the available GNU software . Even if the development tools are of little to no use to you, you may have interest in the many standard Unix utilities provided with the package. They can be used both from the bash shell (provided) or from the standard Windows command shell.
While Cygwin would be an obvious choice for many Unix/Linux power users, there is an excellent and a much simpler alternative to using Cygwin. In this article, we will show you how to run your Unix commands right in the windows command prompt.
For this, we will be using CoreUtils. CoreUtils is available through Sourceforge and is available for download here. If you look in here, there are a number of GNUWin32 packages available, the one we would be using is the CoreUtils package. CoreUtils is a collection of basic file, shell and text manipulation utilities of the GNU operating system. These are the core utilities which are expected to exist on every OS. And when I talk about File utilities, they include chgrp, chmod, cp, dd, du, ln, ls, mkdir, mv, rm, touch, vdir among others. A sample of the text utilities include cat, cksum, cut, join, md5sum, shasum, sort, split etc. The shell root commands include echo, chroot, hostname, nice, pathchk, tty, who, whoami and yes su. So it is pretty much the whole nine yards here… The direct link for download of the CoreUtils package available through SourceForge is available here.
Once installed, you will need to add the path to the utilities to your PATH environment variable. Follow the steps below to achieve this
1. Click on Start –> Run and enter sysdm.cpl to bring up the system properties Dialog
2. Click on the Advanced tab –> Environment variables button Path to environment variable
3. In the System Variables pane, scroll down to Path and then click on edit.
4. Under Edit System Variable, in the variable value, at the end of the line , type the following including the semicolon which separates the individual elements in the path variable. ;C:\Program Files\GnuWin32\bin
env variable properties
Congratulations !! You have now added the GNUWin directory to your path and Unix commands can now be executed directly from the command line and run natively on the Win32 command prompt without the need for any emulation layer as shown below using the example of dir vs ls
command prompt comparing dir vs lsDownloads and Sources
1. Download CYGWIN
2. Download CoreUtils

How to Root Nexus S (2.3.6 works) and Nexus S 4G – Tutorial

souce: http://androidadvices.com/how-to-root-nexus-s-and-nexus-s-4g-%E2%80%93-tutorial/


For all those who own Sprint handsets of Nexus S as well as Nexus S 4G, here comes a great news as you can now enjoy the rooting process for your handsets, be it any version of firmware you are on, you can easily root your handsets easily. Basically, the rooting unlocks the device to a whole new level of possibilities which are helpful in further customizing the device which is the best part of the Android devices compared to other devices like Apple or say even Nokia whose operating systems are not so customizable which Android are. For your simplicity, we have come up with the simplest possible procedure to root your device unlike some of the complex and lengthy techniques.
So, let’s check out the same in the due course of this article on how you can easily root you devices. Before proceeding to the rooting procedure, you will have to ensure that you follow the below mentioned pre requisites carefully also most importantly you will have to also note that the rooting procedure will void the warranty, though the warranty can be claimed back once you un root the device. So, let’s proceed and see the instructions below. And also, we take no responsibility for your device and we should not be held responsible for any manner in part or in whole and proceed for the tutorial to root solely at your risk. It’s an unlikely even that you may brick your phone if you follow the instructions which are mentioned below.
Nexus SNexus S 4G
Pre Root Instructions:
  • Warranty will get void once you root Nexus S as well as Nexus S 4G, though warranty can be claimed once you un root your device.
  • In an unlikely event you may lose all the data which is present in your device, so it’s recommended to create a backup of all the data like call log, messages, applications, music, videos and other data which is present in the phone, so that you can restore the same once the rooting process is completed.
  • Ensure that you have the installed the latest framework in your computer or also you can install the latest version of KIES which is dubbed as KIES 2 so as to ensure that all the required drivers are installed successfully.
  • It’s very important to maintain a minimum battery power of 50% so as to facilitate the smoother rooting process or else there is a high possibility that your device may end up turning completely off in the process of rooting.
  • Since the process of rooting will be taking place, all the APN settings with which you access the Internet will be wiped off completely, so ensure that you have noted all the required settings for accessing the internet so that you can configure them again back once the device gets rooted. Also, additionally ensure that you have also backed up the MMS Settings and other settings as in an unlikely event sometimes you may end up losing all the 3G Settings as well as the APN or MMS settings in the process of Rooting the device.
  • Last but not the least follow the below mentioned instructions carefully so as to save your phone from being turned into an expensive paper weight.
Procedure to Root Sprint 4G as well as Nexus S as well as Nexus S 4G:
  • First up you will have to download the Rooting package for Nexus S / Nexus S 4G device to your computer. Please note that after you download the zip file, you will have to unzip the same and in the process of unzipping if it prompts for the password then enter the password as androidadvices.com and nothing else. Kindly make a note of it as it has been found that despite mentioning several times its repeatedly being asked in the comments section.
Extracted files Nexus S Root
  • It’s always recommended to extract the files to the desktop as it will be easier for you to find the same. Now, after extraction of the files, just connect your Nexus S 4G or Nexus S device to the computer with the help of USB cable but ensure that you have enabled the USB Debugging which can be done by going to Settings > applications > Development  and enable USB Debugging. Its highly recommended to not to mount the SD card when you connect your phone with the computer.
Nexus S Debugging
  • Now, next up you will have to open the One click Nexus S 4G folder along with the drivers which should be required to root the device. Also, most importantly the drivers will be in the folder of PDA NET A 300 x64 for the 64 bit windows while for 32 bit windows you will have to select PDA NET A 300 32 bit.
  • After this you will have to click on the Run.exe file as soon as you finish installing the drivers.
  • That’s it you will have to now follow the on screen instructions to root your Nexus S 4G or Nexus S device. Please note that this process takes around 10 minutes which is the maximum time it will take for rooting the device.
Press Key to continue
  • Now, as soon as the rooting is finished you will have to reboot the device after which you will have to open the Android Market Place and then search for the application called the Root Checker and download the same.
ROOTING Path
After successful completion of the download, just tap on the application to open the same after which it will tell you whether the device has been successfully rooted or not, if the device is not rooted then you will have to follow the above procedure to root the same.
Please note that you will have to reconfigure the APN settings after updating the firmware to access the data services and the Internet services as all the Internet APN settings will be reset. You will have to contact your Service provider which is Verizon Wireless to get more info on the APN Settings. Not to forget also configure the MMS Settings. Do let us know if you face any issues while rooting the device as we will see to it that the issues are solved. Just in case if the rooting process is interrupted in the middle then you just need to re follow the whole procedure from the start to root your device.

Thursday, July 28, 2011

How to export HTML table to Excel file

1
2
protected void Button1_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition","attachment;filename=myexcel.xls"); Response.ContentType = "application/ms-excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw); mytable.RenderControl(hw); Response.Write(sw.ToString()); Response.End(); } public override void VerifyRenderingInServerForm(Control control) { }

Reference: Jessica Cao http://forums.asp.net/p/1086952/1625783.aspx

Monday, July 25, 2011

Display records information based on selected item from ComboBox in Access

Option Compare Database

Private Sub Form_Current()
    If Me.NewRecord Then
        Me.NameofTable = ""
    Else
        Me.NameofTable.SetFocus
        Me.NameofTable.Requery
        Me.NameofTable = Me.NameofTable.ItemData(Forms(0).CurrentRecord - 1)
    End If
End Sub

Private Sub NameofTable_Click()
    ' at this point, cbx text = cbx value
    If Me.NewRecord Or Me.NameofTable.ListIndex = -1 Then
         Me.nameoftabledum = Trim(Me.NameofTable)
         DoCmd.RunCommand acCmdSaveRecord
     Else
         If Me.NameofTable.ListIndex <> Forms(0).CurrentRecord - 1 Then
             DoCmd.GoToRecord , , acGoTo, Me.NameofTable.ListIndex + 1
         End If
    End If
End Sub

Private Sub NameofTable_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 46 Then
        If Me.NameofTable.SelLength < Len(Me.NameofTable.Value) Then
            ' delete part of the text
        Else   ' delete record
            Dim m As Integer
            m = Forms(0).CurrentRecord
            DoCmd.RunCommand acCmdDeleteRecord
            Me.NameofTable.Requery
            Forms(0).Requery
            If m > 1 Then m = m - 1
            DoCmd.GoToRecord , , acGoTo, m
         End If
    End If
End Sub


Friday, July 22, 2011

Retrieve RSS feeds and display in ASP.Net VB

Function ProcessRSSItem() As String
        Dim rssURL As String = "http://www.abc.com/rss.rss"

        Dim myRequest As WebRequest = System.Net.WebRequest.Create(rssURL)
        Dim myResponse As WebResponse = myRequest.GetResponse()

        Dim rssStream As Stream = myResponse.GetResponseStream()
        Dim rssDoc As New XmlDocument()
        rssDoc.Load(rssStream)

        Dim nsmg As New XmlNamespaceManager(rssDoc.NameTable)
        nsmg.AddNamespace("dc", "http://purl.org/dc/elements/1.1/")

        Dim rssItems As XmlNodeList = rssDoc.SelectNodes("rss/channel/item")

        Dim title As String = ""
        Dim link As String = ""
        Dim description As String = ""
        Dim i As Integer = 0
        Dim numItems As Integer = 1
        Dim sb As New System.Text.StringBuilder
        Dim rssDetail As XmlNode

        Do Until numItems = 10
            rssDetail = rssItems.Item(i).SelectSingleNode("dc:language", nsmg)
            Console.WriteLine(rssDetail.InnerText.ToString())
            If rssDetail.InnerText.Equals("en-US") Then
                rssDetail = rssItems.Item(i).SelectSingleNode("title")
                If rssDetail.Equals(Nothing) = False Then
                    title = rssDetail.InnerText
                Else
                    title = ""
                End If

                rssDetail = rssItems.Item(i).SelectSingleNode("link")
                If rssDetail.Equals(Nothing) = False Then
                    link = rssDetail.InnerText
                Else
                    link = ""
                End If

                rssDetail = rssItems.Item(i).SelectSingleNode("description")
                If rssDetail.Equals(Nothing) = False Then
                    description = rssDetail.InnerText
                Else
                    description = ""
                End If

                sb.Append("

" + title + "
") sb.Append(description + "

") numItems = i + 1 End If i = i + 1 Loop Return sb.ToString End Function

Wednesday, July 6, 2011

How to display all selected nodes in TreeVirw VB

    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim names As String = ""
        Dim values As String = ""
        For Each parentNodes As TreeNode In trvIndustrySelections.Nodes
            For Each childNodes As TreeNode In parentNodes.Nodes
                If (childNodes.Checked) Then
                    names = childNodes.Text + "; " + names
                    values = childNodes.Name + "; " + values
                End If
            Next
        Next

        txtCurrentSelectNames.Text = names
        txtCurrentSelectValues.Text = values
    End Sub

Sunday, April 24, 2011

How to resize Root Partition on Ubuntu in VMWare Workstation

source: http://www.virtualdojo.net/resize-rootpartition-on-ubuntu-v9-10-workstation/

The Virtual Machine (VM) templates I created for each Operating System (OS) were made with the smallest possible Virtual Hard Drives to conserve space. When I deploy one of these VM templates I almost always run into disk space problems. This is an easy situation to deal with in both the Windows and Linux OS.

Default partitioning with Ubuntu v9.10 will create a primary EXT4 partition for the root file system, and a small extended partition with a linux-swap partition. Partitions must be unmounted and the last partition on the disk in order to resize them. Since you cannot unmount the root partition once you booted from it, you must boot a CD to accomplish this task.

Mount the Ubuntu v9.10 Workstation ISO on the VM and boot. Press the [ESC] key quickly to get the VMware boot menu. Select the “CD-ROM Drive” option and press the [ENTER] key. Select your language then use the “Try Ubuntu without any change to your computer” option to boot the Ubuntu OS completely from CD.

Once you are at the desktop, start the partition editor by clicking “System > Administration > GPartEd” from the top navigation bar of the desktop. We will make all changes to the partition table using the GPartEd utility.

It is highly recommended that you clone or backup the VM before manipulating the partition table. While the potential to lose data exists, you can relax a bit since changes to the partition table will not be made until you click the “Edit > Apply All Operations” option from the GPartEd menu.

We must first turn off Swap and then delete the Swap partition and the Extended partion that it resides in before we can resize the root partition.

Turn off the Swap partition by clicking “Partition > Swap Off” from the GPartEd menu.

Delete the Swap partition by selecting it from the partition list and then clicking “Partition > Delete” from the GPartEd menu. The swap partition does not contain any valuable data and does not need to be backed up.

Delete the Extended partition by selecting it from the partition list and then clicking “Partition > Delete” from the GPartEd menu.

Resize the Root partition by selecting it from the partition list and then clicking “Partition Resize/Move” from the GPartEd menu. Drag the top slider all the way to the right to use all unallocated space. Then type in the amount of space you want to leave to recreate the swap partition into the “Free Space Following (MiB)” field. Be sure that the “Free Space Preceding (MiB)” value is set to “0″. Click the [Resize/Move] button to accept the changes.

Create a new Extended partition by selecting “Unallocated” from the partition list, then click “Partition > New” from the GPartEd menu. Drag the top slider all the way to the right to use the remainder of your unallocated space. Change the “Create As” type to “Extended Partition” (File System will automatically be set to “Extended”) and click the [Add] button to create the new partition.

Create a new Swap partition by selecting “Unallocated” under your “Extended” partition from the partition list and then clicking “Partition > New” from the GPartEd menu. Drag the top slider all the way to the right to use the entire Extended partition for your Swap. Change the “Create As” type to “Logical Partition” and change the “File System” type to “Linux-Swap” then click the [Add] button to create the new partition.

Save changes to the partition table by selecting “Edit > Apply All Operations” from the GPartEd menu. Click the [Apply] button on the confirmation dialog popup to begin applying the changes. Wait a few minutes while the changes are made on the hard drive then shutdown the VM.

Modify the VM settings to unmount the Ubuntu v9.10 Workstation CD then boot the VM. Check your partition table using the GPartEd utility to verify the changes were made then begin consuming your newly allocated storage!