Posts

How to do replaceAll,replaceFirst,... without regular expression

I do love regular expressions, but sometimes you simply want to replace one string with another. And to make things worse, sometimes your search string is unknown during development time, so it would be great somehow to tell Java not to try parsing search string as a regular expression. For that, I found the best way is the following: String newString = oldString . replaceAll( Pattern . quote(searchString),replacementString); Additionally, this way you ensure no bugs in case your pure text-based searchString not to become compilable regular expression, which can surprisingly often be the main source of bugs :)

Licenses

Image
I really like this post. Very clearly and quickly explainedthe differences between different type of licenses. The great thing about open source code is the large amount of high quality code that is available and many embedded projects use FOSS code as it really speeds up development time. What is not often taken into account are the licenses for the code. Many companies often simply ignore licenses issues and some even go one step further by obfuscating the code to work around dual license issues or to hide the use of a particular open source library. Even though history shows that few companies get sued due to open source license infringements and release of open source code modified in commercial projects often requires the community involvement, open source licenses should still be taken into consideration as the risk still exists. I’ll give an overview of open source licenses in this blog post, as well as recommendation on how to keep your proprietary code closed...

Javascript highlighter, markup editor, WYSIWYG editor plugins

Depends on what you need, but the following plugins are available in terms of markup presenting/editing plugins I would divide into three main types, Syntax Highlighter plugins - it highlights a code so that it is easier to read Markup editor plugins - turns textareas into rich and powerful markup editors WYSIWYG editor plugins - high level editors for end-users Syntax Highlighter plugins  So far, I have seen several of them: SyntaxHighlighter plugin [demo] [github] or [demo] [github] Snippet [link] Google Prettify [link]   Hightlight.js [link]   SHJS [link]   Chilli JS [link]   beautyOfCode [link] Lighter.js [link] DlHighlight [link] JUSH [link] Markup editor plugins CodeMirror [link] along with CodeMirror UI [link]   MarkItUp! [link] SmartMarkUP [link]   WYSIWYG editor plugins  I personally really like those inline-smooth editors, so in that regard I have places a little star on those that cought my...

Customizing the JAXB marshalling/unmarshalling

The following example is used for customizing the way how the dates are being parsed, but it could be used for any other specific customizing import java . text . SimpleDateFormat ; import java . util . Date ; import javax . xml . bind . annotation . adapters . XmlAdapter ; public class DateAdapter extends XmlAdapter < String , Date > { private SimpleDateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss" ); @Override public String marshal ( Date v ) throws Exception { return dateFormat . format ( v ); } @Override public Date unmarshal ( String v ) throws Exception { return dateFormat . parse ( v ); } } which then as adapter can be used to customize marshalling/unmarshalling... import java . util . Date ; import javax . xml . bind . annotation . XmlAccessorType ; import javax . xml . bind . annotation . XmlAccessType ; import javax . xml . bind . annot...

Seven habits of highly effective programmers

Very interesting article http://drupal.technicat.com/writing/programming.html

Chris Maki's Blog: Annotated JAXB Classes

Interesting, but JAXB sometimes is not able to use its own generated .java files. So, if you see the error javax.xml.bind.JAXBException: "your.package" doesnt contain ObjectFactory.class or jaxb.index the following post might be your solution: Chris Maki's Blog: Annotated JAXB Classes

Setting up HTTPS support for WAMP

If you use WAMP to get local PHP server, you might run into issues to set up the HTTPS. The following step-by-step tutorial indeed helped me, and I think it would be useful to re-post it. Recently I had to run a website with several https links under local server for testing and I had to configure the Open SSL server that comes with WAMP server. I'm sure it would be helpful for you as well. First thing first, we need to create that self-signed SSL certificate, so go to DOS command prompt (Start menu -> Run -> cmd). ext, we need to navigate to the directory that contains the openssl executive file which is located in folder C:\wamp\bin\apache\apache2.2.11\bin by default. In order to go there, we need to type the command as follows. Code: Select all cd\wamp\bin\apache\apache2.2.11\bin After press Enter, your prompt should change as follows Code: Select all c:\wamp\bin\apache\apache2.2.11\bin> From there, we begin to create the self-signed SSL certificate and...