crossz

Archive for the ‘software’ Category

Proxy addon/softwares

In software on December 6, 2009 at 4:48 am

Software:

  1. anchorfree.com hotspot shield

addon:

  1. MM3-ProxySwitch

  2. gladder

What’s Good About Jython?

In python, software on November 27, 2007 at 6:31 pm

Overview

In this article I introduce features of the Jython programming
language, illustrated with a small working example. I argue the
benefits of marrying Java with the Python scripting language, and then
speculate why developers
have been slow to adopt this innovative technology.

What is Jython?

Jython is an implementation of
Python that is
written in pure Java.
This means that Jython offers all that any other implementation of
Python offers (see next section), but also provides access to the whole
range of Java library classes (such as Swing, JDBC, Java Cryptography,
Java Speech API, and so on). It also makes it very easy to write Python
code that integrates existing Java components. Conversely, it is easy
to write Jython components that can later be reused and integrated into
other Java-based systems. The benefit to the Java developer is rapid
application development without sacrificing functionality, robustness,
or the commercial respect afforded by Java.

Why Python?

Python is a general-purpose, object-oriented, scripting language. It
is a highly regarded language that is gaining in popularity because it
offers high productivity and therefore competitive advantage. It also
has a simple syntax that gives rise to readable (and maintainable)
programs.

The language itself contains most of the constructs and features
that you might expect, such as objects, functions (methods), procedural
loop constructs, and exception handling. The main feature for a C or
Java programmer is, arguably, the ease with which one can create and
manipulate lists and sequences of values. This, coupled with idioms of
functional programming such as mapping and filtering, make for a very
powerful core language.

A Jython Example

As I stated earlier, Jython is an implementation of Python that is
written in pure Java. This is such a powerful idea that I’m surprised
how little Jython has been recognised and adopted. Let me illustrate
the marriage of the two languages with a little example. Afterwards, we
can compare the equivalent source codes for Java and Jython. (If you
would like to try out the example for yourself and you do not already
have an installation of Jython, you can download it from the website at
www.jython.org.)

I will explain the example in terms of a session with the
interactive shell, so that you understand not only how the source code
works, but also how you might work with the Jython interpreter.

So let’s start up Jython’s interactive shell by typing ‘jython’ at the command line.
You should see something like the following:

C:\My Jython>jythonJython 2.0 on java1.4.0 (JIT: null)Type "copyright", "credits" or "license" for more information.>>>

Now type the following at the >>> prompt:

import javax.swing as swing

Jython accepts the import, and simply displays the next prompt,
waiting for another line of input:

C:\My Jython>jythonJython 2.0 on java1.4.0 (JIT: null)Type "copyright", "credits" or "license" for more information.>>> import javax.swing as swing>>>

The import statement allows us to use the shorter package name
’swing’ as the name of the javax.swing package. We can now create an
instance of a JFrame, give it a title, make it visible, and assign it
to a variable, f, all in one line:

f=swing.JFrame(title="My Frame", visible=1)

There are several features of Jython that allow this line to be so
short. Firstly, we don’t need to declare variables before using them.
(This can be a mixed blessing, as Jython is more willing to accept
typos.) Secondly, we don’t use the Java keyword new for
creating an instance of a class. Thirdly, properties can be set on a
JavaBean at the time of its creation by passing them as keyword
arguments. Here, we are setting two properties: the name of the JFrame,
and its visibility. Note that Python does not have a Boolean type, as
in Java, so we must supply the visibility value as 0 (false) or 1
(true).

At this point, the JFrame is visible, so you can read its title, but it has no size.
To make the window bigger, you resize it by setting the size property of the object f:

f.size=(300,300)

There is quite a lot going on in this short line. Firstly, the dot
notation (‘f.size’), combined with assignment, is a short hand for
setting the
value of a JavaBean property. We could have called the setSize() method directly on f (as in f.setSize(300,300)), but using the dot notation for setting property values can lead to more concise code.
Note that we did not explicitly create an instance of the java.awt.Dimension class
before assigning it to the size property. Jython knows to expect a java.awt.Dimension object, and
therefore passes the tuple (300, 300) as an argument to the constructor of the Dimension class to
create a new Dimension object. The newly created Dimension object is then set as the value of the
size property.

Our frame still doesn’t do anything, so let’s first create, and then add, a button:

b=swing.JButton("Push Me")f.contentPane.add(b)

You’ll need to redraw the frame before the button becomes visible
on-screen. You can do this manually by resizing the frame with the
mouse, or programmatically by calling

f.repaint()

Now let’s make the button print a message whenever it is pressed. First, we define a function that prints a message:

def printMessage(event):   print 'Ouch!'

Next, we associate that function with the button b.

b.actionPerformed=printMessage

And that’s it! If you press the button, the console says ‘Ouch!’.

We illustrate the differences between Java and Jython code for this example by listing the source
code for each.

First, the Java source code:

import javax.swing.JFrame;import javax.swing.JButton;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;

public class MyExampleimplements ActionListener {

    public void actionPerformed(ActionEvent e) {        System.out.println("Ouch!");    }

    public static void main(String[] args) {        JFrame frame = new JFrame("My Frame");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setSize(300,300);        JButton button = new JButton("Push Me!");        frame.getContentPane().add(button);        ActionListener listener = new MyExample();        button.addActionListener(listener);        frame.setVisible(true);    }}

And now the Jython source code:

import javax.swing as swing

def printMessage(event):    print "Ouch!"

if __name__== "__main__":    frame=swing.JFrame(title="My Frame", size=(300,300))    frame.defaultCloseOperation=swing.JFrame.EXIT_ON_CLOSE;    button=swing.JButton("Push Me!", actionPerformed=printMessage)    frame.contentPane.add(button)    frame.visible=1

You can see how much shorter the Jython code is, even for such a
simple example. Think of the implications for the cost of code
development and maintenance!

If you have tried out this example for yourself, or already used
Jython, you will have noticed another great feature of the language -
the immediate feedback you get from the interpreter. Many programmers
criticize interpreted languages for executing slowly, but when it comes
to speed of code development the interpreter wins hands-down over a
compiler. The interactive nature of an interpreter means that you
detect some errors much earlier than you would with an
edit-compile-test loop. And if you can both interpret and compile code
(as with Jython) then you get the best of both approaches.

Jython Reuse From Java

The example above has shown how you can access Java classes from
Jython. Now I should explain how you can use Jython code from Java.

The answer really is quite simple. Since Jython is an implementation
of Python in Java, it needs to compile the Python functions that you
write down to Java bytecode before it can run them. Normally it avoids
a lengthy compilation step by doing the compilation ‘on the fly’, but
you can also compile your Jython classes down to Java .class files or
.jar archives that you can place on the classpath of your ‘master’
application.

You perform the compilation by using the jythonc compiler provided
with Jython. This compiler first generates Java source files from the
Jython code, then compiles them using a standard Java compiler. If you
generate .class files, then you need to remember to put the jython.jar
runtime on the Java classpath when you run the master application, as
the Java source files that jythonc generates have dependencies on the
Jython runtime. If you generate a jar file using jythonc, however,
there are options to include files from the Jython runtime within the
jar.

For example, if the Jython source code for the example given above is
contained in the file MyExample.py, then it can be jar’ed up with
the following command:

jythonc -c -j myjar.jar MyExample.py

This creates a jar file containing the compiled Java version of the Jython
code we wrote as well as files from the Jython runtime.

The jar file also contains a manifest, which makes the jar executable. You can run the jar by typing:

java -jar myjar.jar

Why Isn’t Everybody Using Jython?

This is the hard part! Jython is an incredibly powerful tool, and I
think there are many developers out there who would love to use it,
if only they could. It’s one of those few languages that delights
the developer, because the language is so powerful and you get results
quickly. However, it is still very much a ‘niche’ language,
used only by forward-thinking organisations and entrepreneurs.

Here are some of the possible reasons for the low adoption rate of Jython:

Two Technologies, One Developer
It won’t have escaped your notice that to understand a Jython program
(or to be more precise a Jython program that uses Java classes)
you need a solid understanding of both Java and Python. This places
demands on the skills of the developer at a time when most managers
prefer to simplify code development by choosing the technology that
is the common denominator across their applications.
Learning Curve and Project Pressures
Most developers come to Jython from Java, so have to learn about Python.
They probably have to learn Python before being able to convince colleagues
and managers that Jython will save time in the long run. And the time to
learn a new language in the midst of project pressures and approaching
deadlines is simply not available. It?s a vicious circle that needs to be
broken, and I’m confident that for many, an investment in Jython will pay off.
Old Habits Die Hard
If you’re a Java developer, you are probably quite satisfied developing Java.
It’s a good, well established, programming language and you?re familiar with
the idioms, patterns and style of the language that make it elegant.
Why should you change? Well, I think you should at least consider using Jython,
because firstly, Python, too, is a good programming language with a strong
following. Secondly, a good developer should always be on the look-out for
ways of becoming more productive, and I believe Jython is a good candidate.
Lastly, technologies in the IT sector are always changing, so you should
constantly re-evaluate your technology choices to be sure that you use
your chosen technologies for the right reason, instead of ‘choosing’ them
by default because “that’s what you do”.
Perception of an “Experimental Technology”
Jython is not an “Experimental Technology” -
It is industrial-strength and stable. If you’re not confident enough to
use it for your main application straight away, then use it for writing
test scripts and developing prototypes. Often, developers will begin with
the intention of writing a prototype in Jython and later migrating to Java,
only to find later that the migration is not necessary.
Jython is Slow
To say that Jython is unsuitable for your application because it is
an interpreted language and therefore too slow is almost certainly false.
There are very few applications these days for which execution speed is
such a major concern. And if you do find a bottleneck in your code you
can always migrate that section of code to Java as necessary. As a
developer, you should be more concerned about the speed of development
than the speed of execution, and in this respect, Jython is fast!

Conclusion

Jython is a technology that marries two disparate technologies,
Java and Python, seamlessly and to great effect.
Unfortunately, I believe it has largely been overlooked by developers.
Jython has much to offer, particularly to the Java developer community,
and offers the potential to speed up conventional Java development.

Related Reading:

It has taken a while, but there are now a couple of good books about Jython on the market:


cover
Jython Essentials by Samuele Pedroni & Noel Rappin. Published by O’Reilly, 2002.

See listing at Amazon.com
or Amazon.co.uk


cover
Jython for Java Programmers by Robert Bill. Published by New Riders, 2002.

See listing at Amazon.com
or Amazon.co.uk

Powered by ScribeFire.

What’s Good About Jython?

In python, software on November 27, 2007 at 6:31 pm

Overview

In this article I introduce features of the Jython programming
language, illustrated with a small working example. I argue the
benefits of marrying Java with the Python scripting language, and then
speculate why developers
have been slow to adopt this innovative technology.

What is Jython?

Jython is an implementation of
Python that is
written in pure Java.
This means that Jython offers all that any other implementation of
Python offers (see next section), but also provides access to the whole
range of Java library classes (such as Swing, JDBC, Java Cryptography,
Java Speech API, and so on). It also makes it very easy to write Python
code that integrates existing Java components. Conversely, it is easy
to write Jython components that can later be reused and integrated into
other Java-based systems. The benefit to the Java developer is rapid
application development without sacrificing functionality, robustness,
or the commercial respect afforded by Java.

Why Python?

Python is a general-purpose, object-oriented, scripting language. It
is a highly regarded language that is gaining in popularity because it
offers high productivity and therefore competitive advantage. It also
has a simple syntax that gives rise to readable (and maintainable)
programs.

The language itself contains most of the constructs and features
that you might expect, such as objects, functions (methods), procedural
loop constructs, and exception handling. The main feature for a C or
Java programmer is, arguably, the ease with which one can create and
manipulate lists and sequences of values. This, coupled with idioms of
functional programming such as mapping and filtering, make for a very
powerful core language.

A Jython Example

As I stated earlier, Jython is an implementation of Python that is
written in pure Java. This is such a powerful idea that I’m surprised
how little Jython has been recognised and adopted. Let me illustrate
the marriage of the two languages with a little example. Afterwards, we
can compare the equivalent source codes for Java and Jython. (If you
would like to try out the example for yourself and you do not already
have an installation of Jython, you can download it from the website at
www.jython.org.)

I will explain the example in terms of a session with the
interactive shell, so that you understand not only how the source code
works, but also how you might work with the Jython interpreter.

So let’s start up Jython’s interactive shell by typing ‘jython’ at the command line.
You should see something like the following:

C:\My Jython>jythonJython 2.0 on java1.4.0 (JIT: null)Type "copyright", "credits" or "license" for more information.>>>

Now type the following at the >>> prompt:

import javax.swing as swing

Jython accepts the import, and simply displays the next prompt,
waiting for another line of input:

C:\My Jython>jythonJython 2.0 on java1.4.0 (JIT: null)Type "copyright", "credits" or "license" for more information.>>> import javax.swing as swing>>>

The import statement allows us to use the shorter package name
’swing’ as the name of the javax.swing package. We can now create an
instance of a JFrame, give it a title, make it visible, and assign it
to a variable, f, all in one line:

f=swing.JFrame(title="My Frame", visible=1)

There are several features of Jython that allow this line to be so
short. Firstly, we don’t need to declare variables before using them.
(This can be a mixed blessing, as Jython is more willing to accept
typos.) Secondly, we don’t use the Java keyword new for
creating an instance of a class. Thirdly, properties can be set on a
JavaBean at the time of its creation by passing them as keyword
arguments. Here, we are setting two properties: the name of the JFrame,
and its visibility. Note that Python does not have a Boolean type, as
in Java, so we must supply the visibility value as 0 (false) or 1
(true).

At this point, the JFrame is visible, so you can read its title, but it has no size.
To make the window bigger, you resize it by setting the size property of the object f:

f.size=(300,300)

There is quite a lot going on in this short line. Firstly, the dot
notation (‘f.size’), combined with assignment, is a short hand for
setting the
value of a JavaBean property. We could have called the setSize() method directly on f (as in f.setSize(300,300)), but using the dot notation for setting property values can lead to more concise code.
Note that we did not explicitly create an instance of the java.awt.Dimension class
before assigning it to the size property. Jython knows to expect a java.awt.Dimension object, and
therefore passes the tuple (300, 300) as an argument to the constructor of the Dimension class to
create a new Dimension object. The newly created Dimension object is then set as the value of the
size property.

Our frame still doesn’t do anything, so let’s first create, and then add, a button:

b=swing.JButton("Push Me")f.contentPane.add(b)

You’ll need to redraw the frame before the button becomes visible
on-screen. You can do this manually by resizing the frame with the
mouse, or programmatically by calling

f.repaint()

Now let’s make the button print a message whenever it is pressed. First, we define a function that prints a message:

def printMessage(event):   print 'Ouch!'

Next, we associate that function with the button b.

b.actionPerformed=printMessage

And that’s it! If you press the button, the console says ‘Ouch!’.

We illustrate the differences between Java and Jython code for this example by listing the source
code for each.

First, the Java source code:

import javax.swing.JFrame;import javax.swing.JButton;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;

public class MyExampleimplements ActionListener {

    public void actionPerformed(ActionEvent e) {        System.out.println("Ouch!");    }

    public static void main(String[] args) {        JFrame frame = new JFrame("My Frame");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setSize(300,300);        JButton button = new JButton("Push Me!");        frame.getContentPane().add(button);        ActionListener listener = new MyExample();        button.addActionListener(listener);        frame.setVisible(true);    }}

And now the Jython source code:

import javax.swing as swing

def printMessage(event):    print "Ouch!"

if __name__== "__main__":    frame=swing.JFrame(title="My Frame", size=(300,300))    frame.defaultCloseOperation=swing.JFrame.EXIT_ON_CLOSE;    button=swing.JButton("Push Me!", actionPerformed=printMessage)    frame.contentPane.add(button)    frame.visible=1

You can see how much shorter the Jython code is, even for such a
simple example. Think of the implications for the cost of code
development and maintenance!

If you have tried out this example for yourself, or already used
Jython, you will have noticed another great feature of the language -
the immediate feedback you get from the interpreter. Many programmers
criticize interpreted languages for executing slowly, but when it comes
to speed of code development the interpreter wins hands-down over a
compiler. The interactive nature of an interpreter means that you
detect some errors much earlier than you would with an
edit-compile-test loop. And if you can both interpret and compile code
(as with Jython) then you get the best of both approaches.

Jython Reuse From Java

The example above has shown how you can access Java classes from
Jython. Now I should explain how you can use Jython code from Java.

The answer really is quite simple. Since Jython is an implementation
of Python in Java, it needs to compile the Python functions that you
write down to Java bytecode before it can run them. Normally it avoids
a lengthy compilation step by doing the compilation ‘on the fly’, but
you can also compile your Jython classes down to Java .class files or
.jar archives that you can place on the classpath of your ‘master’
application.

You perform the compilation by using the jythonc compiler provided
with Jython. This compiler first generates Java source files from the
Jython code, then compiles them using a standard Java compiler. If you
generate .class files, then you need to remember to put the jython.jar
runtime on the Java classpath when you run the master application, as
the Java source files that jythonc generates have dependencies on the
Jython runtime. If you generate a jar file using jythonc, however,
there are options to include files from the Jython runtime within the
jar.

For example, if the Jython source code for the example given above is
contained in the file MyExample.py, then it can be jar’ed up with
the following command:

jythonc -c -j myjar.jar MyExample.py

This creates a jar file containing the compiled Java version of the Jython
code we wrote as well as files from the Jython runtime.

The jar file also contains a manifest, which makes the jar executable. You can run the jar by typing:

java -jar myjar.jar

Why Isn’t Everybody Using Jython?

This is the hard part! Jython is an incredibly powerful tool, and I
think there are many developers out there who would love to use it,
if only they could. It’s one of those few languages that delights
the developer, because the language is so powerful and you get results
quickly. However, it is still very much a ‘niche’ language,
used only by forward-thinking organisations and entrepreneurs.

Here are some of the possible reasons for the low adoption rate of Jython:

Two Technologies, One Developer
It won’t have escaped your notice that to understand a Jython program
(or to be more precise a Jython program that uses Java classes)
you need a solid understanding of both Java and Python. This places
demands on the skills of the developer at a time when most managers
prefer to simplify code development by choosing the technology that
is the common denominator across their applications.
Learning Curve and Project Pressures
Most developers come to Jython from Java, so have to learn about Python.
They probably have to learn Python before being able to convince colleagues
and managers that Jython will save time in the long run. And the time to
learn a new language in the midst of project pressures and approaching
deadlines is simply not available. It?s a vicious circle that needs to be
broken, and I’m confident that for many, an investment in Jython will pay off.
Old Habits Die Hard
If you’re a Java developer, you are probably quite satisfied developing Java.
It’s a good, well established, programming language and you?re familiar with
the idioms, patterns and style of the language that make it elegant.
Why should you change? Well, I think you should at least consider using Jython,
because firstly, Python, too, is a good programming language with a strong
following. Secondly, a good developer should always be on the look-out for
ways of becoming more productive, and I believe Jython is a good candidate.
Lastly, technologies in the IT sector are always changing, so you should
constantly re-evaluate your technology choices to be sure that you use
your chosen technologies for the right reason, instead of ‘choosing’ them
by default because “that’s what you do”.
Perception of an “Experimental Technology”
Jython is not an “Experimental Technology” -
It is industrial-strength and stable. If you’re not confident enough to
use it for your main application straight away, then use it for writing
test scripts and developing prototypes. Often, developers will begin with
the intention of writing a prototype in Jython and later migrating to Java,
only to find later that the migration is not necessary.
Jython is Slow
To say that Jython is unsuitable for your application because it is
an interpreted language and therefore too slow is almost certainly false.
There are very few applications these days for which execution speed is
such a major concern. And if you do find a bottleneck in your code you
can always migrate that section of code to Java as necessary. As a
developer, you should be more concerned about the speed of development
than the speed of execution, and in this respect, Jython is fast!

Conclusion

Jython is a technology that marries two disparate technologies,
Java and Python, seamlessly and to great effect.
Unfortunately, I believe it has largely been overlooked by developers.
Jython has much to offer, particularly to the Java developer community,
and offers the potential to speed up conventional Java development.

Related Reading:

It has taken a while, but there are now a couple of good books about Jython on the market:


cover
Jython Essentials by Samuele Pedroni & Noel Rappin. Published by O’Reilly, 2002.

See listing at Amazon.com
or Amazon.co.uk


cover
Jython for Java Programmers by Robert Bill. Published by New Riders, 2002.

See listing at Amazon.com
or Amazon.co.uk

Powered by ScribeFire.

Mozilla Labs Blog » Blog Archive » Prism

In software on November 21, 2007 at 10:47 am

Personal computing is currently in a state of transition. While traditionally users have interacted mostly with desktop applications, more and more of them are using web applications. But the latter often fit awkwardly into the document-centric interface of web browsers. And they are surrounded with controls–like back and forward buttons and a location bar–that have nothing to do with interacting with the application itself.

Transition550

Mozilla Labs is launching a series of experiments to bridge the divide in the user experience between web applications and desktop apps and to explore new usability models as the line between traditional desktop and new web applications continues to blur.

Unlike Adobe AIR and Microsoft Silverlight, we’re not building a proprietary platform to replace the web. We think the web is a powerful and open platform for this sort of innovation, so our goal is to identify and facilitate the development of enhancements that bring the advantages of desktop apps to the web platform.

The first of these experiments is based on Webrunner, which we’ve moved into the Mozilla Labs code repository and renamed to Prism.

Prism

Prismlogo400

Prism is an application that lets users split web applications out of their browser and run them directly on their desktop.

Refracting550

Prism lets users add their favorite web apps to their desktop environment:

Startmenu550

When invoked, these applications run in their own window:

Googlecalendar550

They are accessible with Control-Tab, Command-Tab, and Exposé, just like desktop apps. And users can still access these same applications from any web browser when they are away from their own computers.

The Best of Both Worlds

Prism isn’t a new platform, it’s simply the web platform integrated into the desktop experience. Web developers don’t have to target it separately, because any application that can run in a modern standards-compliant web browser can run in Prism. Prism is built on Firefox, so it supports rich internet technologies like HTML, JavaScript, CSS, and <canvas> and runs on Windows, Mac OS X, and Linux.

And while Prism focuses on how web apps can integrate into the desktop experience, we’re also working to increase the capabilities of those apps by adding functionality to the Web itself, such as providing support for offline data storage and access to 3D graphics hardware.

Comparison550

The User Experience

We’re also thinking about how to better integrate Prism with Firefox, enabling one-click “make this a desktop app” functionality that preserves a user’s preferences, saved passwords, cookies, add-ons, and customizations. Ideally you shouldn’t even have to download Prism, it should just be built into your browser.

Prismui

We’re working on an extension for Firefox that provides some of this functionality. For more information about the user experience we hope to achieve in Prism, see Alex Faaborg’s blog post. For some of the technical details and new features found in Prism, see Mark Finkle’s blog post.

Getting Started with Prism

We have an early prototype for this working today on Windows, with work continuing on Mac and Linux (for which we should have builds available soon).

To try out the prototype, download and install it: Download Prism for Windows.

Then start Prism. It will display an Install Web Application dialog.

Prism08500

Enter the URL of the application you want to use in Prism (e.g. mail.google.com), a name for the application (e.g. Gmail), and pick where you’d like to create shortcuts to the application.

Then press the OK button. Prism will create shortcuts to the application in the locations you specified and then start the application.

How to Get Involved

Prism is just the first of many experiments we hope to conduct around improving the usability of web applications. It’s open source, like everything we do, and we’re interested in hearing from and working with anyone interested in further developing this concept.

  • Discuss, debate and add to the design in the forum. Report bugs in Bugzilla.
  • Get the source code, extend it, fix bugs and/or submit patches.

    The project lead for Prism is Mark Finkle and contributors include Cesar Oliveira, Wladimir Palant, Sylvain Pasche, Alex Faaborg, and Myk Melez.

Blogged with Flock

Welcome to Firebug 1.0

In JavaScript, software on November 18, 2007 at 12:30 pm

Blogged with Flock

lyx+beamer for presentation

In latex, linux, software on November 9, 2007 at 7:58 pm

lyx, very powerful latex tool, whose author is the person who started KDE project.

However lyx is not so clever, for instance, when you installed ‘latex-beamer’, it can not find the relative document class and style files. You must go to TOOLS->RECONFIGURE to find the new installed stuff.

Latex is famous for the feature of no worries about layout while concentrating on the contents you are writing.
Beamer is a kinda plugin to enable you concentrate on the contents of your presentation. Here I attached the template of latex-beamer.

latexbeamer.pdf

lyx+beamer for presentation

In latex, linux, software on November 9, 2007 at 7:58 pm

lyx, very powerful latex tool, whose author is the person who started KDE project.

However lyx is not so clever, for instance, when you installed ‘latex-beamer’, it can not find the relative document class and style files. You must go to TOOLS->RECONFIGURE to find the new installed stuff.

Latex is famous for the feature of no worries about layout while concentrating on the contents you are writing.
Beamer is a kinda plugin to enable you concentrate on the contents of your presentation. Here I attached the template of latex-beamer.

latexbeamer.pdf

The art of using manuals

In linux, software on November 9, 2007 at 12:53 am

Detailed and proper documentation of source code and programs is the milestone of Unix culture, as we may read in “The art of Unix Programming” by Eric Steven Raymond. The first application on Unix was the platform to prepare documents. The platform was used by Bell Labs to prepare patent documents. Effective work with documentation and searching for needed information is the key feature when working on unix-like systems.

1. Local documentation


1.1. man

Usually the first and most basic information source about a given program are man pages. The name stands for the English word manual. Man pages are divided into eight parts:

  1. General Commands
  2. System Calls
  3. Subroutines
  4. Special Files
  5. File Formats
  6. Games
  7. Macros and Conventions
  8. Maintenence Commands

Each page is divided into the following sections:

  • head with command name and section’s number
  • command name and sometimes the names of other commands described on the same page
  • all the parameters used by the command
  • short program description
  • detailed information about each parameter

Depending on the command and operating system you can also meet the following sections:

  • environmental variables
  • diagnostics
  • bugs and restrictions
  • authors
  • copyrights
  • config files

To display the man page of a given command you should type man command_name. If the command is described in more than one section you should give the section’s number also. E.g. the first man section includes the open command description while the second section includes the description of the general command open. To see the documentation of the general command you should type man 2 open. When a man page is open you can navigate using your cursor. To get back to the console you should type :q; to find a phrase below you may use /the phrase; to find a phrase above, use ?the phrase; to repeat the last seach, use n. The man command has two interesting parameters that can be used to search the right man section. When you use the command with -a it displays all the pages for a given command, one after another. When you use the command with -w it displays only the number of the section where a given command is described.

$ man -w open

/usr/share/man/cat2/open.0

/usr/share/man/cat3p/open.0 

All sections are divided into sub-catalogues and, as in the example above, the open command appears in the second and third section of man (the example is from OpenBSD 4.1).

To search through man pages you may use two commands: whatis and apropos.

Whatis is used to give a short explanation of programs and command tasks.

$ whatis ls mkdir cat man df

ls (1)               - list directory contents

mkdir (1)            - make directories

cat (1)              - concatenate files and print on the standard output

man (1)              - an interface to the on-line reference manuals

man (7)              - macros to format man pages

df (1)               - report file system disk space usage 

The apropos command finds a given phrase in the man pages.

$ apropos 'list directory'

dir (1)              - list directory contents

ls (1)               - list directory contents

vdir (1)             - list directory contents 

We can make queries more sophisticated:

$ apropos ext3 | grep create

mke2fs (8)           - create an ext2/ext3 filesystem

mkfs.ext2 (8)        - create an ext2/ext3 filesystem

mkfs.ext3 (8)        - create an ext2/ext3 filesystem 

In the example above I’ve searched through the man pages which might contain information about creating the file system ext3. Since the query apropos ext3 gave a lot of information on output I’ve filtered the output using the grep command. Of course, there’s no restriction on using regular expressions here. Man includes two commands that you may use instead of whatis and apropos. These are -f and -k. There’s a possibility of printing out the man pages that we are interested in — you may use the parameter -t for this.

$ man -t ls > ls.ps 

A PostScript file was created. With the parameter -T, a DeVice Independent (DVI) file would be created.

$ man -T ls > ls.dvi 


1.2. info

Info is a program to view GNU Texinfo format documentation. This kind of formatting is used by the Free Software Foundation. It enables hyper-textual navigation in documents. You may find more about this command in its man page (man info) or using the command info info. You may start viewing the documentation with the command info. The following keys are used to navigate:


n next page
p previous page
u page up
l last visited node

Texinfo documentation has a tree-like structure.


1.3. /usr/share/doc

The /usr/share/doc/ localisation is the place where you find the documentation in formats other than man and info. Ubuntu users for example may find the book “Dive into Python” there. In Debian Etch there’s a How To documents collection (unfortunately part of them is quite out of date) and in an OpenBSD system you may find “System Manager’s Manual“. The aforementioned books are available during the installation process, where you can choose the misc41.tgz installation set.


2. Documentation on the Internet

The Internet offers many sources of help and documentation. We may find Wikipedia pages (more or less official ones), forums, discussion groups, etc. It would be reasonable to start our search with the system’s description, available on the polishlinux.org web page. I’d like to present a couple of web pages about unix-like systems administration.


2.1 developerWorks

This page was created by the IT market giant IBM. There you may find many articles about unix-like systems administration (on different experience levels), for example articles about software creation. All the articles are free of charge and are available online and in a PDF version. In the case of some of the articles, free of charge registration is required.


2.2. Big Admin

Admin’s vortal. It is devoted mainly to Solaris. Articles are free of charge and registration is not required.


2.3. OnLamp, Linuxdevcenter

These pages are connected with O’Reilly and O’Reilly Network. On OnLamp you can find articles about Linux, BSD and programming languages like PHP, Python and Perl. The registration is required only if you want to add comments. You pay only for the access to e-books.


2.4. Linux Documentation Project

The Linux Documentation Project is an inititative to create documentation sets for Linux distributions. There you can find many manuals and HOWTO documents, etc. All the documents are distribution-unspecific, free of charge and available in different formats.

Blogged with Flock

The art of using manuals

In linux, software on November 9, 2007 at 12:53 am

Detailed and proper documentation of source code and programs is the milestone of Unix culture, as we may read in “The art of Unix Programming” by Eric Steven Raymond. The first application on Unix was the platform to prepare documents. The platform was used by Bell Labs to prepare patent documents. Effective work with documentation and searching for needed information is the key feature when working on unix-like systems.

1. Local documentation


1.1. man

Usually the first and most basic information source about a given program are man pages. The name stands for the English word manual. Man pages are divided into eight parts:

  1. General Commands
  2. System Calls
  3. Subroutines
  4. Special Files
  5. File Formats
  6. Games
  7. Macros and Conventions
  8. Maintenence Commands

Each page is divided into the following sections:

  • head with command name and section’s number
  • command name and sometimes the names of other commands described on the same page
  • all the parameters used by the command
  • short program description
  • detailed information about each parameter

Depending on the command and operating system you can also meet the following sections:

  • environmental variables
  • diagnostics
  • bugs and restrictions
  • authors
  • copyrights
  • config files

To display the man page of a given command you should type man command_name. If the command is described in more than one section you should give the section’s number also. E.g. the first man section includes the open command description while the second section includes the description of the general command open. To see the documentation of the general command you should type man 2 open. When a man page is open you can navigate using your cursor. To get back to the console you should type :q; to find a phrase below you may use /the phrase; to find a phrase above, use ?the phrase; to repeat the last seach, use n. The man command has two interesting parameters that can be used to search the right man section. When you use the command with -a it displays all the pages for a given command, one after another. When you use the command with -w it displays only the number of the section where a given command is described.

$ man -w open

/usr/share/man/cat2/open.0

/usr/share/man/cat3p/open.0 

All sections are divided into sub-catalogues and, as in the example above, the open command appears in the second and third section of man (the example is from OpenBSD 4.1).

To search through man pages you may use two commands: whatis and apropos.

Whatis is used to give a short explanation of programs and command tasks.

$ whatis ls mkdir cat man df

ls (1)               - list directory contents

mkdir (1)            - make directories

cat (1)              - concatenate files and print on the standard output

man (1)              - an interface to the on-line reference manuals

man (7)              - macros to format man pages

df (1)               - report file system disk space usage 

The apropos command finds a given phrase in the man pages.

$ apropos 'list directory'

dir (1)              - list directory contents

ls (1)               - list directory contents

vdir (1)             - list directory contents 

We can make queries more sophisticated:

$ apropos ext3 | grep create

mke2fs (8)           - create an ext2/ext3 filesystem

mkfs.ext2 (8)        - create an ext2/ext3 filesystem

mkfs.ext3 (8)        - create an ext2/ext3 filesystem 

In the example above I’ve searched through the man pages which might contain information about creating the file system ext3. Since the query apropos ext3 gave a lot of information on output I’ve filtered the output using the grep command. Of course, there’s no restriction on using regular expressions here. Man includes two commands that you may use instead of whatis and apropos. These are -f and -k. There’s a possibility of printing out the man pages that we are interested in — you may use the parameter -t for this.

$ man -t ls > ls.ps 

A PostScript file was created. With the parameter -T, a DeVice Independent (DVI) file would be created.

$ man -T ls > ls.dvi 


1.2. info

Info is a program to view GNU Texinfo format documentation. This kind of formatting is used by the Free Software Foundation. It enables hyper-textual navigation in documents. You may find more about this command in its man page (man info) or using the command info info. You may start viewing the documentation with the command info. The following keys are used to navigate:


n next page
p previous page
u page up
l last visited node

Texinfo documentation has a tree-like structure.


1.3. /usr/share/doc

The /usr/share/doc/ localisation is the place where you find the documentation in formats other than man and info. Ubuntu users for example may find the book “Dive into Python” there. In Debian Etch there’s a How To documents collection (unfortunately part of them is quite out of date) and in an OpenBSD system you may find “System Manager’s Manual“. The aforementioned books are available during the installation process, where you can choose the misc41.tgz installation set.


2. Documentation on the Internet

The Internet offers many sources of help and documentation. We may find Wikipedia pages (more or less official ones), forums, discussion groups, etc. It would be reasonable to start our search with the system’s description, available on the polishlinux.org web page. I’d like to present a couple of web pages about unix-like systems administration.


2.1 developerWorks

This page was created by the IT market giant IBM. There you may find many articles about unix-like systems administration (on different experience levels), for example articles about software creation. All the articles are free of charge and are available online and in a PDF version. In the case of some of the articles, free of charge registration is required.


2.2. Big Admin

Admin’s vortal. It is devoted mainly to Solaris. Articles are free of charge and registration is not required.


2.3. OnLamp, Linuxdevcenter

These pages are connected with O’Reilly and O’Reilly Network. On OnLamp you can find articles about Linux, BSD and programming languages like PHP, Python and Perl. The registration is required only if you want to add comments. You pay only for the access to e-books.


2.4. Linux Documentation Project

The Linux Documentation Project is an inititative to create documentation sets for Linux distributions. There you can find many manuals and HOWTO documents, etc. All the documents are distribution-unspecific, free of charge and available in different formats.

Blogged with Flock

firefox ultimate optimizer

In howto, software on November 6, 2007 at 2:00 pm

it really does an amazing job. save the memory resource almost 10 times. But not sure about the security. Waiting for other’s comments.

firefoxultimateoptimizer.zip

firefox ultimate optimizer

In howto, software on November 6, 2007 at 2:00 pm

it really does an amazing job. save the memory resource almost 10 times. But not sure about the security. Waiting for other’s comments.

firefoxultimateoptimizer.zip

SourceForge.net: Wired

In linux, software on November 5, 2007 at 6:31 pm

Wired aims to be a professional music production and creation software running on the Linux operating system. It brings musicians a complete studio environment to compose and record music without requiring expensive hardware.

Screenshot

http://sourceforge.net/projects/wired/

Blogged with Flock

GMail Drive

In software on September 25, 2007 at 11:08 am
clipped from en.wikipedia.org

GMail Drive

GMail Drive is a free third-party namespace extension (“add-on”) for Microsoft Windows. It allows a user to access a virtual drive stored in a Gmail e-mail account by causing the contents of the Gmail account to appear as a new network share on the user’s workstation. In order to use this add-on, the user needs a Gmail e-mail account. The add-on enables the user to use the standard Windows desktop file copy and paste commands to transfer files to and from the Gmail account as if it was a drive on the user’s computer.

GMail Drive in Windows XP

VMware fusion, amazing. similar to Xming.

In software on August 16, 2007 at 1:40 pm
最近又安装Mac OS X来玩,这次主要是为了试试VMware Fusion这个东西.以前大费周折地用VMware+rdesktop才在Ubuntu运行起了Windows的原生程序,据说在Fusion下只是点几下鼠标而已.

这次一试,果然不同凡响.请看我的图文解说:

系统概况:Mac OS X 10.4.9+VMware Fusion with Deepin XP

每张图均可点击看1280×800的大图:

要使Fusion里的虚拟Windows XP运行在原生模式下,必须让虚拟机切换到“Unity”模式,这样虚拟机就在后台工作了,你根本不用理会它的存在。

你可以直接点Applications,它会调用Windows XP的开始菜单,用这个可以方便打开Windows程序。

但是有些程序开始菜单没有怎么办?那你可以打开资源管理器,自己去开启,凡是启动过一次的exe文件,以后就会出现在Applications──Lauch这里,可谓十分智能!

图为Windows的资源管理器和Mac的Finder和谐共处:

这张图就是Windows的IE打开LDCN的样子,后面还有腾讯的广告也跳出来了。因为我在后台开着QQ。哈哈。

注意到IE的图标,在dock上与其他Mac程序无异吧。

这次开起来了Windows Media Player,没什么好讲的,效果还是不错。

这次把 QQ开起来了,再注意到右侧,就是Lauch工具了,好像只要是exe和指向exe的快捷方式都会出现在这里,方便启动相关程序。

还有很多图就不放了,Windows程序与Mac的结合性非常好,无论是平铺还是dock上的操作、缩小都与原生Mac程序没什么区别。

回顾LDCN以前的相关文章,那种方法好麻烦啊,期待VMware Fusion登陆Linux平台。

LDCN供稿,LDCN(即LinuxDesktop.cn的缩写),中文名──“Linux桌面中文网”,是一个由在校大学生发起的,旨在让所有Linuxer一起参与、更新的Linux资讯、应用互动型社区站点.

Powered by ScribeFire.

VMware fusion, amazing. similar to Xming.

In software on August 16, 2007 at 1:40 pm
最近又安装Mac OS X来玩,这次主要是为了试试VMware Fusion这个东西.以前大费周折地用VMware+rdesktop才在Ubuntu运行起了Windows的原生程序,据说在Fusion下只是点几下鼠标而已.

这次一试,果然不同凡响.请看我的图文解说:

系统概况:Mac OS X 10.4.9+VMware Fusion with Deepin XP

每张图均可点击看1280×800的大图:

要使Fusion里的虚拟Windows XP运行在原生模式下,必须让虚拟机切换到“Unity”模式,这样虚拟机就在后台工作了,你根本不用理会它的存在。

你可以直接点Applications,它会调用Windows XP的开始菜单,用这个可以方便打开Windows程序。

但是有些程序开始菜单没有怎么办?那你可以打开资源管理器,自己去开启,凡是启动过一次的exe文件,以后就会出现在Applications──Lauch这里,可谓十分智能!

图为Windows的资源管理器和Mac的Finder和谐共处:

这张图就是Windows的IE打开LDCN的样子,后面还有腾讯的广告也跳出来了。因为我在后台开着QQ。哈哈。

注意到IE的图标,在dock上与其他Mac程序无异吧。

这次开起来了Windows Media Player,没什么好讲的,效果还是不错。

这次把 QQ开起来了,再注意到右侧,就是Lauch工具了,好像只要是exe和指向exe的快捷方式都会出现在这里,方便启动相关程序。

还有很多图就不放了,Windows程序与Mac的结合性非常好,无论是平铺还是dock上的操作、缩小都与原生Mac程序没什么区别。

回顾LDCN以前的相关文章,那种方法好麻烦啊,期待VMware Fusion登陆Linux平台。

LDCN供稿,LDCN(即LinuxDesktop.cn的缩写),中文名──“Linux桌面中文网”,是一个由在校大学生发起的,旨在让所有Linuxer一起参与、更新的Linux资讯、应用互动型社区站点.

Powered by ScribeFire.

what’s latex

In software on August 6, 2007 at 5:18 pm
  • TeX 是什么?

    TeX 是一个排版系统。用 TeX,你可以把你的文章做成书那种效
    果。你可以把它打印出来,或者送到出版社投稿。TeX 非常适合用来
    写学术论文和书籍。

  • 排版 Word 也可以啊!TeX 跟 Word, WordPerfect 有什么不一
    样?

    Word 和 WordPerfect 是“字处理程序”(word processor),它
    们是“所见即所得(WYSIWYG)”的,你直接修改字体,颜色,用鼠标
    画出表格…… 马上就可以看到效果。屏幕上显示出来是什么效果,
    印出来基本上就是那个效果。而 TeX 不是,你输入的都是文本文件,
    需要一个程序(当然就是tex了)处理之后才能得到一个排版后的结果。

  • 那样的话 TeX 还不如 Word 呢!

    Word 这样所见即所得的程序写科技论文是很累的。这会使你的脑
    子总是想着专业排版人员考虑的问题,比如 “这个单词使用什
    么字体呢?”,“这行应该缩进多少呢?” 这样就没有什么时
    间用来思考语言和内容了。所以 TeX 被设计为“WYTIWYG (所
    想即所得)”。

    用TeX写文章,他想的是 “这一段是否应该属于上一节呢?”,
    “这句话跟我这章的主题符合吗?”,“是否应该开始新的一章
    呢?”,“这个概念读者是否容易理解呢?”…… 你告诉 TeX 的
    是:“这是一章开始”,“这个单词应该强调”, “这里是一段
    诗”……就像在对他的秘书口授机宜。而不是告诉她:“这是第3章,
    应该用黑体三号字,开头有一个‘双S’,……”,“这个单词用斜
    体楷体小四”, “左右缩进各一英寸,右边不要对齐,换用小一号
    花体”……这些是秘书的事情,不用你操心。

    TeX 就是你优雅而聪明的秘书。你写论文的时候,能专注于逻辑
    思维。她排出的数学公式是无与伦比的漂亮,所以数学家最喜欢这个
    东西。

  • 你比较一下 Word 和 LaTeX 生成的的PDF文档就可以发现:

  • 远远看去,LaTeX 文档格式更加均称,黑白程度均匀,而
    Word 文档是黑一块的白一块,字符密度不均匀。
  • 仔细看看,你就知道原因了。 Word 文档里上下两行经常有
    这种情况,上一行的单词间距很宽,而下面一行却很窄。这在排
    版美学上是非常不好的。相临行的单词间据应该尽量相同。
  • Java Envoroiment Setting within ultraedit

    In Windows, howto, software on April 21, 2007 at 9:14 am

    Java环境变量设置

    如果是Win2000/NT/XP系统,则设置环境变量为:
    系统变量->新建->变量名:“JAVA_HOME”,变量值“C:\Java\jdk1.5.0_06”;
    系统变量->新建->变量名:“CLASSPATH”,变量值“.;%JAVA_HOME%\lib”;
    系统变量->编辑->变量名:“Path”,变量值“%JAVA_HOME%\bin”。
    注:CLASSPATH中有一英文句号“.”后跟一个分号,表示当前路径的意思。

    UltraEdit中设置Java环境
    在“高级”菜单下,选择“工具配置”,然后添加:
    命令行:C:\Java\jdk1.5.0_06\bin\javac.exe %f或C:\Java\jdk1.5.0_06\bin\javac.exe %n%e
    %f、%n、%e分别表示完整文件名、不含扩展名的文件名、扩展名;
    工作目录:%p,%p表示当前目录;
    菜单项目名称:编译Java程序
    最后,分别选中“保存活动文件”、“输出到列表方块”、“捕捉输出”。
    在“高级”菜单下,选择“工具配置”,再次添加:
    命令行:C:\Java\jdk1.5.0_06\bin\java.exe %n
    %f、%n、%e分别表示完整文件名、不含扩展名的文件名、扩展名;
    工作目录:%p,%p表示当前目录;
    菜单项目名称:运行Java程序
    最后,分别选中“保存活动文件”、“输出到列表方块”、“捕捉输出”

    源文档 <http://www.cublog.cn/u/11335/showart.php?id=71772>

    solidworks画螺纹

    In howto, software on April 19, 2007 at 11:53 pm

    其实在零件中也可以显示螺纹线,只不过SW的默认选项不显示螺纹装饰线罢了。具体方法如下:
    在”工具–选项–文件属性–注解显示”选中”上色的装饰螺纹线”和”显示注解”选项,按回车键保存设置。然后,用异型导向孔命令,在”孔规格” 属性管理中,”孔规格”选”螺纹孔”图标;”标准”选”ISO”项,同时在下面的”选项”中选中”装饰螺纹线”就可以了。