niedenzu

Hints and tricks for developers

Martins Amazon Wunschliste

highlight form elements with jquery 23. April 2015



//highlight form elements....


document.styleSheets[0].insertRule("::-webkit-input-placeholder { color: green; font-weight: bold ;  background-color:rgba(255,255,255,1); border: 1px solid green}", 0);


$.each($("input"), function() {
	if ($(this).attr('name')) {
		$(this).val("");//evtl inhalte loeschen
		//if ($(this).attr('hasDatepicker')) {
			//wenn Datepicker, dann Felder vergroessern
			$(this).removeAttr("size");
			$(this).removeAttr("maxlength");
			
		//}
		$(this).attr("placeholder",$(this).attr('name'));			
	}

});


$.each($("select"), function() {
	if ($(this).attr('name')) {
		$(this).prepend("");
		$(this).css({ color : "green", fontWeight: "bold" }).val($(this).attr('name'));
		$(this).val($(this).attr('name'));
	}
});



$.each($("input[type=radio], input[type=file]"), function() {
	if ($(this).attr('name')) {
		$(this).before("
"+ $(this).attr('name') +"
"); } }); $.each($("input[type=hidden]"), function() { //nur elemente die ein name attrib haben.. if ($(this).attr('name')) { $(this).removeAttr("type"); $(this).before("
"+ $(this).attr('name') +"\n(hidden)
"); } });
No Comments on highlight form elements with jquery
Categories: Uncategorized

Start WebSphere Portal 24. February 2015

c:\IBM\PortalServer\AppServer\bin>startserver WebSphere_Portal
ADMU0116I: Toolinformationen werden in der Datei
           C:\IBM\PortalServer\wp_profile\logs\WebSphere_Portal\startServer.log
           protokolliert.
ADMU0128I: Das Tool wird mit dem Profil wp_profile gestartet.
ADMU3100I: Die Konfiguration des Servers wird gelesen: WebSphere_Portal
ADMU3200I: Der Server wurde gestartet. Es wird auf den Initialisierungsstatus
           gewartet.

No Comments on Start WebSphere Portal
Categories: Uncategorized

Gute Einfürung in Graphviz 19. February 2015

http://4webmaster.de/wiki/Graphviz-Tutorial

No Comments on Gute Einfürung in Graphviz
Tags:
Categories: Uncategorized

mobaxterm 18. February 2015

wget
vi
grep

F11 = full screen

No Comments on mobaxterm
Categories: Uncategorized

Sonar Postgresql 30. January 2015

Do you want to use Sonar with postgresql?
Then read the following articel.

https://github.com/darianmiller/devmachine/wiki/Configure-Sonar-to-Utilize-PostgreSQL

This can be very handy if you want to use the maven sonar pluging.
All results of the scan will be stored to this DB.

No Comments on Sonar Postgresql
Categories: Uncategorized

Continuous delivery 29. January 2015

big-pic-2

  • XXX-build (executes test and builds the current snpashot
  • XXX-deploy (creates a package and deploys it to nexus)
  • XXX-deliver (deploys the release-package to test-server)

build

  • Executes the JUnit Tests.
  • Perform Sonar checks.
  • creates an snapshot-package.
  • deploys the snapshot-package to nexus.

This Job is executed on every commit.
The time leak is 5 mins.

The build can be executed manually by pushing the “Jetzt bauen”-Button

jetzt_bauen

deploy

skips the JUnit-Tests.
Skkps the Sonar checks.
creates an release package.
deploys the release-package to nexus.

This Job is executed by pushing the “Perform Maven Release”-Button.
Hudson screenshot

deploy

deliver

The Hudson/Jenkins server executes a script over ssh that downloads the latest release package and restart the server. The script itself just executes a Java-Program that does all the nasty work.

  • determin the package version of the artifact
  • downloads the artifact to filesystem (e.g. /srv/stage/mywebapp.war
  • deploys the webapp in the Applicationserver

This Job has to be executed manually in Jenkins.

version overview

You should inform yourself about the current Versions.
It’s a good idea to do this before an after the deivery of your software.

Bildschirmfoto 2015-01-29 um 07.01.04

test overview

You should inform yourself about the current Versions.
testergebnisseIt’s a good idea to do this before an after the deivery of your software

No Comments on Continuous delivery
Categories: Uncategorized

Suspend uncaugth Exception 28. January 2015

Problem desciption

While debugging a webapp with eclipse and java. Nothing special happens but the IDE jumps in the debugging mode.

Reason

An uncaught exception has occured.

Solution

Uncheck the Suspend on uncaught Exceptions flag.
suspend_uncaught

No Comments on Suspend uncaugth Exception
Categories: Uncategorized

Nexus – Performing a Release Build

https://wiki.jenkins-ci.org/display/JENKINS/M2+Release+Plugin

Installing the m2release Plugin

jenkins_install_m2_release_plugin

Performing a Release Build

Hudson screenshot

Other option to perform an release-build

  • alternaviv :https://wiki.jenkins-ci.org/display/JENKINS/Release+Plugin
  • http://www.baeldung.com/maven-release-nexus
  • http://www.baeldung.com/maven-deploy-nexus
No Comments on Nexus – Performing a Release Build
Categories: Uncategorized

jqueryui icons in pdf 24. January 2015

We are using the jqueryui icons in our webapp.
We also generate pdfs to create a printable document that fits our needs.
This post describes how tho add the icons in general.
Later we will provide a java sample by using iText

The jqueryui icons are organized in a ui-icons_xxxxxx_256x240.png file
where 2e83ff is the rgb color code in our example ui-icons_2e83ff_256x240.png.

ui-icons_2e83ff_256x240

icons_jquery

No Comments on jqueryui icons in pdf

ant task to deploy to nexus

I you want to switch to maven and jenkins, I might happen that you can’t change all
dependies to maven and jenkins.
In my scenario one of the projects was a cobol-project that used a special compiler.
So I used ant to create it.

The following script shows you how to deploy your module to your company’s nexus.

No Comments on ant task to deploy to nexus
Categories: Uncategorized

THE JEE AND PHP FRAMEWORK 23. January 2015

The Company you work for is developping JEE and PHP Applications?
Many Companies make the mistake by trying to switch to one Programming Language.
But – that simply does not work.

Our approach is to provide guidelines on how to reuse as much as possible for both teams.

You will get following advantages

  • Quicker Application development.
  • Same look and feel of PHP and JEE Applications by reusing the the css – Same user experience
  • Reusage of SQL-Queries
  • Reusage of Javascript
  • Less time spent to solve commen problems. You can spend more time in the development of your business logik.
  • Easy way to reuse code in one Language in by the other

Quicker Application development.

If you use our blueprint you don’t have to start a discussion.
You dont’t need to setup project or a directory structure.
You cant take advantage of our dokumentations.
So you just need to add your parts to it.

Look and Feel

We are using the jQuery-UI-Framework to build user interfaces. It is quite simple to change the look and feel of your app. Just visit http://jqueryui.com/themeroller/ and download a theme you like. Thats it your done.
It is not complicated to cusomize the theme.
If you don’t like the theme then build you own.
By using jQuery-UI you get all kinds of ui-components that you can reuse.

  • Datepicker
  • Tabs
  • Autocomplete
  • Buttons
  • and many more

Bildschirmfoto 2015-01-24 um 07.40.10

Reusage of Javascript

Developing Javascript can be very complicated. Developping good Javascript is even more complicated. We are using jQuery to simplyfie the development. Features that are not part of javascript or jQuery are added by jQuery extensions and custom javascript.
If you use our javascript stack you don’t have to worry if the components fit to each other. They are.

Our Sample app.
All examples in this book are based on our sample app. You kann see it in real life at www.someplace.com. If you want to develop your own app the sample app is a good point to start from. It is an hybrid app wich means it can run in an JEE environment or on an Apache webserver using PHP.

Layout

Html_head.php bzw. htm_head.jsp
Navigation_menu.php or naviation_menu.jsp

Single-Page Application?

By reading todays web-development books you have 2 different paradigm.

  • Multi-Page App
  • Single-Page App
  • page.php
  • page.jsp
  • page.js

Reusage of SQL-Queries?

Yes it is defnitively possible.
We are putting all sql queries we use in one xml-File (Queries.xml).
We use the same syntax as hibernate does.




	
		select * from my_table1
		where x = '1'
	

If you want to use the query to make a custome select in your favorite dbtool just go ahead und cut-and-paste the query to it and exexute it.

We provide 2 samples to get the query. One in PHP and the otherone ind Java.

preserveWhiteSpace = false;

$doc->Load('Queries.hbm.xml');

$xpath = new DOMXPath($doc);

// We starts from the root element
$query = '//hibernate-mapping/sql-query[@name="getAnliegenByKundennummerWithoutSpecifiedOne"]';

$entries = $xpath->query($query);

foreach ($entries as $entry) {
    echo "{$entry->nodeValue}";
}
?>

Using jquery icons in pdf

You whant to reuse the jquery icons in a pdf?
A post on howto to this ist posted here here

No Comments on THE JEE AND PHP FRAMEWORK
Categories: Uncategorized

Maven repositories

If you work with maven in an enterprise environment you have to deal with multible repositories

1. your local repository
2. the official repository of you enterprise.
3. the repositories in the internet.

Scenario 1

your offical repository is connectect to the internet.
Bildschirmfoto 2015-01-24 um 08.20.52

Scenario 2

your offical respositry has no access to the internet

nexus_kein_zugriff

Normaly you sit behind a firewall.
So you need to configure your settings.xml to use the proxy to access the internet.
In my case I new the user and password.

When you setup a new project or you want to perform a compile maven
downloads …

The central repositories are supportin http and https-urls.
In my case I could not import the certificates…
So I had to configure maven to use the http-urls.

No Comments on Maven repositories
Categories: Uncategorized

Install maven on Mac OS X

  • Download the archiv from apache
  • cd ~/Downloads
  • unzip apache-maven-3.3.3-bin.zip
  • cd /usr/local
  • sudo mkdir apache-maven
  • sudo mv ~/Downloads/apache-maven-3.3.3 /usr/local/apache-maven
  • cd /Library/Java/JavaVirtualMachines/
  • ls
  • cd ~
  • vi .bash_profile

1.Extract the distribution archive, i.e. apache-maven-3.2.5-bin.tar.gz to the directory you wish to install Maven 3.2.5. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.2.5 will be created from the archive.
In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5.
Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.
Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS=”-Xms256m -Xmx512m”. This environment variable can be used to supply extra options to Maven.
Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.
Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.7.0_51 and that $JAVA_HOME/bin is in your PATH environment variable.
Run mvn –version to verify that it is correctly installed.

To set environmen variable on mac:
/bin/launchctl setenv FOO BAR
echo $FOO

edit the .bach_profile in your home directory

export M2=$M2_HOME/bin
export PATH=$M2:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

Finde out where java is
Use /usr/libexec/java_home -v 1.7 command on a terminal shell to figure out where is your java 1.7 home directory

thats it. you are set up

The local repositoy will be created in following folder:

/Users/martin/.m2/repository

if you perform

mvn install

install – install the package into the local repository, for use as a dependency in other projects locally

No Comments on Install maven on Mac OS X
Tags: , ,
Categories: Uncategorized

Sicherung der Postgres Datenbank 20. January 2015

pg_dump postgres > c:\Daten\db.sql

Wenn man ausversehen den Filenamen vergisst geht die Ausgabe an die Console.
Der Output dauert ewig.

Das Gute an dieser Art der Sicherung ist, dass dies über rechnerarchitekturgrenzen hinweg funktioniert.
Anders formuliert – ich kann die Daten von Windows sichern und auf mac wieder einspielen.

Weiter führende Links findest du unter:
http://www.postgresql.org/docs/9.3/static/app-pgdump.html

Einspielen der Sicherung

psql postgres < c:\Daten\db.sql

No Comments on Sicherung der Postgres Datenbank
Categories: Uncategorized

Deployment und der Symlink

Wenn man eine Site im professionellen Umfeld betreiben möchte,
so kommt benötigt man ein Versionkonzept.

Ziel ist es zwischen verschiedenen Versionen einer Webanwendung hin und her zuschalten.

  • Entwicklung
  • Test
  • Staging
  • production

ETU
ITU – Integration-Umgebung
STU – Systemtest-Umgebung
PU – Produktionsumgebung

Lokal
Entwicklung
Konsolierung
Produktion

Erzeugung eines Links.

ln -s v1.2.1 production

Auf den 1und1 Servern ist der git client installiert.
Es ist somit ohne Probleme möglich über die Kommandozeile Versionen einer Software
auzuchecken.

alternativ kann man die Software auch über svn verwalten. Dies wird von 1und1 nicht unterstützt.

No Comments on Deployment und der Symlink
Categories: Uncategorized

eclipse datasource explorer vs. Squirell SQL 19. January 2015

Als Java-Entwickler arbeite ich Tag für Tag mit Eclipse.
Dadurch kenne ich die Shorcuts um schnell mit meiner Lieblings-IDE arbeiten zu können.

Die letzten Jahre habe ich mit Quantum gearbeitet. Jedes mal wenn eine neue Version von Eclipse erschiene ist,
musste ich das Plugin nachinstallieren.
Doch Eclipse kommt mit von sich aus mit einem eigenen Tool für die Datenbank.
Den Eclipse Datasource Explorer.

Der ist gar nicht mal so schlecht wenn man weiß wie er zu bedienen ist.
Als ich ihn zum ersten mal ausgeführt habe konnte ich damit reichlich wenig anfangen.
Mir war nicht klar wo ich meine SQLs eingeben konnte und wie man sie ausführt.

Mit ALT + X kann man im SQL Scrapbook SQL-Queries ausführen.

Eine Funktion die ich von Squirell schätzen gelern habe ist.

No Comments on eclipse datasource explorer vs. Squirell SQL
Categories: Uncategorized

eclipse remote system explorer – shell ed – php plugin 21. October 2014

Sometimes I need to do administration stuff.
Because I am a fulltime Java Developer I feel confortable using eclipse.
I only have basic knolege about vi.
Another thing is – I work with Windows and Mac Computers – And I like software that can run on poth operating systems.

mobaxterm and WinSCP are nice Tools for SSH and sFTP but they are not eclipse.

“Remote system explorer” is a build in

shell_ed

net.sourceforge.shelled-site-2.0.1

No Comments on eclipse remote system explorer – shell ed – php plugin
Categories: Uncategorized

Trim String to fit in UTF-8 encoded DB-column 20. October 2014

Most People in the World are using more tjen the ASCIIcode. Most of our customers deal with an international audience. The only solution ist to use UTF8 everywhere. Everywhere means in the database and in the software.

UTF8 is a format to spare space.

public class WWSUtils {
	
	 public static String trimUnicodeToMaxsizeInUtf8Bytes(String input, int size) {
	        
	        //first trim - is suffucient only ASCII Usage
	        if (input.length() > size) {
	            input  = input.substring(0, size);
	        }
	        
	        while  (WWSUtils.lengthInUtf8Bytes(input) > size) {
	            input = input.substring(0, input.length() - 1);
	        }
	        
	        return input;
	    }

	     public static int lengthInUtf8Bytes(final CharSequence sequence) {
	            int count = 0;
	            for (int i = 0, len = sequence.length(); i < len; i++) {
	              final char ch = sequence.charAt(i);
	              if (ch <= 0x7F) {
	                count++;
	              } else if (ch <= 0x7FF) {
	                count += 2;
	              } else if (Character.isHighSurrogate(ch)) {
	                count += 4;
	                ++i;
	              } else {
	                count += 3;
	              }
	            }
	            return count;
	     }

}


Javascript Verison will be posted soon.

No Comments on Trim String to fit in UTF-8 encoded DB-column
Categories: Uncategorized

Postgress

which is an alternative to IBMs DB2?

I’m trying to use Postgress as a alternative DB-Server.

  • should be open source
  • shuld run on windows mac and linx
  • should be compatible with db2

I tryed postgress because, if you got to oreilly.com you get literatur and manuels.
The amount of literatur you get from oreilly.com is always a good indicator on the
attention a software or it-sytem gets.

pgsql_connection

create a Instance

The Database should use Unicode as Encoding.
Because our customer is operation world wide we need to use an Encoding which uses foreign Character sets.
You need to issue the following commant to create a UTF8 Database.

C:\Daten\pgsql\bin> initdb -D c:\Daten\pgsql-data - E UTF8

launch the databaseserver


C:\Daten\pgsql\bin>postgres -D c:\Daten\pgsql-data

PostgreSQL has the data types smallserial, serial and bigserial; these are not true types, but merely a notational convenience for creating unique identifier columns. These are similar to AUTO_INCREMENT property supported by some other databases.
If you wish a serial column to have a unique constraint or be a primary key, it must now be specified, just like any other data type.
The type name serial create integer columns. The type name bigserial create a bigint column. bigserialshould be used if you anticipate the use of more than 231 identifiers over the lifetime of the table. The type name smallserial create a smallint column.

Listing all Databases

psql -l

No Comments on Postgress
Categories: Uncategorized

Highlight code in your html-page

I made some good experience using the syntaxhighlighter_3.0.83.
It uses different Bruches to higlight different Languages such as

  • java
  • javascript
  • sql

]]>

No Comments on Highlight code in your html-page
Categories: Uncategorized
Martin Rocks