Save a man page in a text file

If you want to save a man page into a text file, you can do it in that way:

man vmstat | col -bx > vmstat3.txt

The man command displays information about vmstat, then the col command removes backspaces and outputs multiple spaces instead of tabs. Finally the output is redirected to a text file : vmstat3.txt .

Java : Generate an array with numbers


package pl.test.app;

import java.util.Random;

public class App1 {

private static final int MAX_SIZE = 10;
private static final int NUMBER_RANGE = 40;

public static void main(String[] args) {
line();

Random r = new Random();
int[][] tab = new int[MAX_SIZE][MAX_SIZE];
for(int i=0; i<MAX_SIZE; i++)
for(int j=0; j<MAX_SIZE; j++){
tab[i][j] = r.nextInt(NUMBER_RANGE);
}

for(int i=0; i<MAX_SIZE; i++){
System.out.print("| ");
for(int j=0; j<MAX_SIZE; j++){
System.out.print(tab[i][j] + "\t|");
}
System.out.println();
}

line();
}

private static void line() {
System.out.println("---------------------------------------------------------------------------------");
}
}

WinForm application – test automation

Windows Forms, or WinForms, is a graphical class library included in Microsoft .NET Framework, used to create graphically rich applications. It can be used to display data, handle user input or deploy applications. Really extensive documentation is available on one of Microsoft webpage. It is splitted into two logical parts. The first one describes basics, the other presents more advanced topics.

In order to automate test cases on WinForms apps we could use such tools like : a) UI Automation framework, provided by Microsoft, the .NET Framework element Its main goals are : – providing access to most user interface elements on the desktop – enabling the UI manipulation by means other than standard input

b) TestStack.White framework The framework provides a consistent object-oriented API and hides the complexity of Microsoft’s UI Automation on which it is based on. It can be used to automate also Silverlight and SWT Java applications.

If you have any experience about those tools, please share it.

TestNG notes part 1

package a;

import org.testng.annotations.Test;

public class A1 {

@Test(groups = {"grp1"})
public void test1(){ //must be "public"
System.out.println("test1");
}

@Test(groups = {"grp1"})
public void test2(){ //must be "public"
System.out.println("test2");
}

@Test(groups = {"grp2"})
public void test3(){ //must be "public"
System.out.println("test3");
}
}

Prevent auto lock


set wsc = CreateObject("WScript.Shell")
Do
WScript.Sleep (60*1000)
wsc.SendKeys ("{SCROLLLOCK 2}")
Loop


System.out.println("SimulateKeyPress");
System.out.println("Dir: " + System.getProperty("user.dir"));
Robot robot = new Robot();
while (true){
Thread.sleep(60000);
robot.keyPress(KeyEvent.VK_SCROLL_LOCK);
}