Posted in January 15, 2011 ¬ 17:59h.Piotr
If you want to create every possible word or combination of letters (or any other characters) you can use very simple BASH function:
$ echo {a..c}
This command will print all possible letters starting with a and ending on c (inclusive), so the result is:
a b c
You can get every possible combination of letters from the given range, which length is larger than 1, i.e.:
$ echo {a..c}{a..c}
This command will print every possible combination of letters starting with a and ending on c (inclusive) with another letter from the same range. The result result is:
aa ab ac ba bb bc ca cb cc
Be the first to like.
Posted in January 13, 2011 ¬ 17:55h.Piotr
When you want to create a boolean property in a Java Bean (let’s name it visible), you most likely would want to use a boolean type variable and create accessors for it.
Well, if you use a boolean primitive it is allowed to create a getter in one of two manners:
public boolean getVisible()
or
public boolean isVisible()
Notice that the second option is only allowed when your property is a boolean primitive. Therefore, when your property is a Boolean object, the getter should be in only one form:
public Boolean getVisible()
It’s easy to make such a mistake, but JEE EL (Expression Language) is very strict about that (which is understandable).
So, I guess it’s the best just to use the get…() form of a accessor. If you have a code-style language-related problem with accepting “getVisible()” construct in your code, just try translating your property form from question into statement form like:
Boolean visilibity;
public Boolean getVisibility()
Sounds better, doesn’t it?
2 people like this post.
Posted in January 9, 2011 ¬ 18:47h.Piotr
I wanted to find some solution to a problem of automatic generation of build numbers/version identifiers using an ANT. I figured out that I can achieve it in the following way:
<target name="numerate.version"
description="Generates version number and sets it in
Client properties file.">
<tstamp>
<format property="build.time"
pattern="yy-MM-dd_hh:mm"
unit="hour" />
</tstamp>
<buildnumber file="build.number" />
<property name="version.code"
value="${build.version}/${build.time}/${build.number}" />
<echo>Version: ${version.code}</echo>
<replaceregexp file="${client.commonsi18n.pl}"
match="(version[ \t]*=[ \t]*)+.*$"
byline="true"
replace="\1${version.code}" />
</target>
A short description what is going on:
- tstamp is generating an actual date in given format (yy-MM-dd_hh:mm) and saves it as a property (build.time),
- buildnumber saves the incremented number of build in a file (build.number),
- replaceregexp replaces the given expression (version[ \t]*=[ \t]*)+.*$) with a following expression (\1${version.code}). In other words – in this example, it replaces the old build/version number with the new one.
The last part (replaceregexp) is used to get the most recent version number in the *.properties file which can be printed on the presentation layer (i.e. on the page footer). You can achieve it using the GWT i18n features, which uses the properties files for international labels generation.
Needles to say, this target should be invoked before the actual GWT compilation.
An example of generated build/version number using this script is as follows:
0.1d/10-01-08_07:51/31
Be the first to like.
Posted in January 8, 2011 ¬ 16:35h.Piotr
In the Axis2 (which you can download from this site) bin subdirectory, there is a java2wsdl.sh file which can be used to generate a WSDL file from plain Java classes.
Below is a very rough example how to use it:
/home/palli/axis2-1.5.4/bin/java2wsdl.sh -o /home/palli/ -of Test.wsdl -sn WSAdditionalOperations -cp . -cn com.nullhaus.ediploma.server.WSAdditionalOperations
Used arguments:
o – output directory where the generated WSDL will be saved,
of – output filename of the WSDL,
cp – java classpath,
sn – name of the service,
cn – fully qualified name of the class you want to be used to generate the WSDL file.
Be the first to like.
Posted in January 4, 2011 ¬ 15:34h.Piotr
I’ve recently bumped into a problem with using a SSL Network Extender when trying to establish a VPN connection through the web browser.
The SNX was throwing a ‘failed to initialize’ error without any details despite the right credentials.
To identify the error, I needed to execute the snx from the command line (snx) which points that the SNX is missing a libstdc++.so.5. I had a libstdc++.so.6 installed at that point.
In the Ubuntu repositories, there wasn’t anything earlier than libstdc++6, so the only solution I found, was to download version 5 from this site (version for 32 bits).
After installing this package, the snx (both – from the command line and from the web browser) worked just fine.
Be the first to like.
Posted in January 2, 2011 ¬ 17:34h.Piotr
When you create a *.jar file using jar command-line tool, it is worth to remember that the order of arguments does matter, so:
jar cmvf projects/myTags/etc/MANIFEST.MF myTags.war myTags
means that you must firstly provide the manifest file (m), than the JAR filename (f).
If you use the same order of arguments but change the switches like this:
jar cvfm projects/myTags/etc/MANIFEST.MF myTags.war myTags
the command will not be executed. According to the switches, your first argument should be the JAR filename (f) and then manifest file (m).
Be the first to like.
Posted in December 23, 2010 ¬ 14:33h.Piotr
Sometimes, there is a need to use SOCKS Proxy for connection even if an application itself isn’t providing such feature.
If you’re working on Windows you can use FreeCap which allows you to put your applications into FreeCap “sandbox”. Everytime you run app from this “sandbox” it is sent through the SOCKS proxy you set as an configuration option.
Update: Recently I’ve heard that it is somewhat impossible to execute this application on Windows 7. It hasn’t been updated for a long time, so I guess you need to find something else… or try it and post the results ;-)
If you’re working on GNU/Linux, you can use TSOCKS and configure it, i.e. like that:
/etc/tsocks.conf:
local = 192.168.0.0/255.255.255.0
server = 127.0.0.1
server_type = 5
server_port = 7070
Every application you’ll run from command line, which is not in local network, will be sent through SOCKS v5 Proxy at 127.0.0.1:7070.
Be the first to like.
Posted in November 26, 2010 ¬ 09:32h.Piotr
Recently I was trying to configure a SSL site working on a localhost. The whole point was to configure the Apache2 to work with the SSL and I found this site to be particular useful why trying to solve this problem
Be the first to like.
Posted in September 25, 2010 ¬ 06:55h.Piotr
Sometimes you just really want to use the autocomplete feature and omit the HTML form autocomplete=”off”.
To do so, you need to modify following file (the firefox version might, and probably will be, different than the one posted below):
/usr/lib/firefox-3.6.10/components/nsLoginManager.js (in Windows it might be something like C:\Program Files\Mozilla Firefox\components\nsLoginManager.js)
Change this:
_isAutocompleteDisabled : function (element) {
if (element.getAttribute("autocomplete").toLowerCase() == "off")
return true;
return false;
}
to this:
_isAutocompleteDisabled : function (element) {
return false;
}
Or just add comments to the conditional section of the method, to assure it will always return false.
Be the first to like.
Posted in July 3, 2010 ¬ 09:04h.Piotr
It seems that in Ubuntu 10.04 the tun module (which is used to create fake network interface) is compiled into the kernel instead of being a module as in Ubuntu 9.10. It results in error while running the snx command:
FATAL: Module tun not found.
This problem can be solved either by recompiling the kernel and setting the tun as a module (not to be compiled into the kernel itself) or by adding appropriate command to modprobe.
Just add
install tun /bin/true
to one of conf files in /etc/modprobe.d, or use the commands below:
echo -e "install tun /bin/true\n" > built-in.conf
sudo cp built-in.conf /etc/modprobe.d/
Thanks to Constantine Peresypkin and psorcerer for providing a solution.
Be the first to like.