preload
Dez 28

There is no vertical-aligment css-attribute in css 2.0. So how to align elements vertically?

1
2
3
4
5
6
7
8
DIV.container {
    min-height: 10em;
    display: table-cell;
    vertical-align: middle }
...
<DIV class="container">
  <P>This small paragraph...
</DIV>

To align vertically the paragraph P on line 7, you have to use display: table-cell; and vertical-align: middle;

Runs on Mozilla, Safari and IE8 but not IE7

This example is from W3.org. Orginal article can be found here.

Tagged with:
Dez 20

If you want to download a file with curl type the following code into bash:

1
curl -O http://www.url.de/file.html

-O means to output to a file and not to stdout, normally the screen.

What if you need to resume a download of a big file?

1
curl -C - -O http://www.url.de/file.html

With -C – you continue downloading the current file. If is important to write -C -. Don’t forget the -

You can also set a referrer and the user agent.

1
curl -C - -O -A http://www.url.de -e "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6" http://www.url.de/file.html

With -A you can set the referrer and -e sets the user agent.

Pretty helpful.

Tagged with:
Dez 18

You would like to know the spellout word from an integer? Use the ICU library from IBM.

1
2
3
4
import com.ibm.icu.text.RuleBasedNumberFormat;
// ...
int num = 100198
System.out.println(new RuleBasedNumberFormat(Locale.US, RuleBasedNumberFormat.SPELLOUT).format(number));

The result is: one hundred thousand, one hundred and ninety-eight
You can get the spellout of the number in other languages. Check Locale.GERMANY instead of Locale.US and you have: hunderttausendhundertachtundneunzig

Tagged with:
Dez 17

I just stumbled upon an article about the java.awt.robot from java while reading java stuff. When you would like to fill textboxes or to click buttons etc. on an swing or awt window automatically you can use the java.awt.robot class.

Check this example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
package desktopapplication1;
 
import java.awt.AWTException;
import java.awt.event.KeyEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.awt.Point;
import java.awt.event.InputEvent;
import org.jdesktop.application.FrameView;
 
public class Robot implements Runnable {
 
    private FrameView frameview;
 
    public Robot(FrameView frameview) {
        this.frameview = frameview;
    }
 
    public void run() {
        try {
            initRobot();
        } catch (AWTException ex) {
            Logger.getLogger(Robot.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
        private void initRobot() throws AWTException {
        // create a robot to feed in GUI events
 
        java.awt.Robot rob = new java.awt.Robot();
 
        // enter some keystrokes
 
        int keyinput[] = {
            KeyEvent.VK_T,
            KeyEvent.VK_E,
            KeyEvent.VK_S,
            KeyEvent.VK_T,
            KeyEvent.VK_I,
            KeyEvent.VK_N,
            KeyEvent.VK_G
        };
        rob.delay(1000);
        rob.keyPress(KeyEvent.VK_SHIFT);
 
        ((DesktopApplication1View)this.frameview).getjTextField1().requestFocus();
        for (int i = 0; i < keyinput.length; i++) {
            rob.keyPress(keyinput[i]);
            rob.delay(1000);
        }
        rob.keyRelease(KeyEvent.VK_SHIFT);
        rob.keyPress(KeyEvent.VK_ENTER);
 
        // move cursor to exit button
 
        Point p = ((DesktopApplication1View)this.frameview).getjButton1().getLocationOnScreen();
        rob.mouseMove(p.x + 5, p.y + 5);
        rob.delay(2000);
 
        // press and release left mouse button
 
        rob.mousePress(InputEvent.BUTTON1_MASK);
        rob.delay(2000);
        rob.mouseRelease(InputEvent.BUTTON1_MASK);
 
    }
 
}

I started the class in a separate thread, the example from sun, where I took most parts of the code uses ActionListener to update the textfield.

Now you have to start the thread with:

1
2
       Thread t = new Thread(new desktopapplication1.Robot(this));
       t.start();

Check the example from sun – http://java.sun.com/developer/TechTips/2000/tt0711.html

Tagged with:
Dez 14

To send simple mails im Java, e.g. without header modifications or attachment you can use apache commons library.

Download it at http://commons.apache.org/ and add the jar to your project.

1
2
3
4
5
6
7
8
9
SimpleEmail email = new SimpleEmail();
email.setHostName("host.test.com");
email.setFrom("from@test.com", "testfromname");
email.addTo("to@test.com", "testtoname");
email.addBcc("bcc@test.com", "testbccname");
email.setSubject("testsubject");
email.setMsg("testmessage");
email.setAuthentication("username", "pass");
email.send();

Check simple email-class documentation for further configuration as smtp-port etc.

Tagged with:
Dez 14
After unpacking the Kernel Archive to “/usr/src” use the following:
1
2
3
4
make dep
make clean
make bzImagemake modules
make modules_install
Tagged with:
Dez 10

To create the stub classes in c# you have to add a web reference.

  • Create a new Application, e.g. Console Projekt or Window Application Projekt
  • Right click on References
  • Left click on Add Service Reference
  • Left click at the bottom on the Add Service Reference-Window on Advanced Add Service Reference
  • Left click at the bottom on the Sevice Reference Settings-Window on Add Web Reference
  • Enter the Web Service URL in the URL-Textfield and press go
  • Optional choose another Web Service Namespace
  • Click Add Reference

Et Voilà. Extremly simple.

Tagged with:
Dez 09

Normally you can create stub classes from a wsdl-file via console by calling wsdl2java. To generate stub classes from wsdl with netbeans you have to add to the build.xml file the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<path id="axis.classpath">
   <fileset dir="/usr/local/axis/lib/">
      <include name="**/*.jar" />
    </fileset>
</path>
 
<taskdef resource="axis-tasks.properties" classpathref="axis.classpath" />
 
<target name="Generate From WSDL">
    <axis-wsdl2java
    output="src/"
    testcase="false"
    verbose="true"
    serverside="false"
    url="http://url.to-webservice.com/?wsdl">
    <mapping namespace="http://axis.apache.org/ns/interop"
    package="wsdltester" />
    <mapping namespace="http://www.namespace.de/types/"
    package="wsdltester.stubs" />
    <mapping namespace="http://www.namespace.de/services/"
    package="wsdltester.service" />
 
    </axis-wsdl2java>
</target>

Note that you have to modify several settings like the namespaces and the url to the web service on line 15! Do not just copy the code.

Tagged with:
Dez 08

To detach from an actual session press

1
Ctrl+a d

Reattach with

1
screen  -r

To list the actual detached sessions:

1
screen  -list

You will see something like:

1
2
4840.pts-3.localhost  (Detached)
4628.pts-1.localhost (Detached)

Reattach it with:

1
screen  -r 4840.pts-3.localhost

To share a session with another user you have to ensure some steps.

Set the screen binary setuid root:

1
chmod  +s /usr/bin/screen

Login as root and start a screen session and name it:

1
screen -S sessionName

Enable multi-user access function by pressing Ctrl+a then :multiuser on (to type “:”, press “shift+;”)
Grant permissions to the second user by pressing Ctrl+a: acladd username, where username is the Unix user for the second user.

1
screen  -x root/sessionName

Activate logging with:

1
Ctrl+a H

A file in your home directory will be created. Something like $HOME/screenlog.1

Type exit to exit screen.

Dez 03

To delete the .svn folders recursivly in a checked out svn repositiory create a file e.g. called deletesvn.reg and use the following script:

?View Code REGISTRY
1
2
3
4
5
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 &amp;&amp; COLOR 9A &amp;&amp; FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
Tagged with: