Thursday, July 11, 2013

Exporting Skype Chat/Skype Contacts to csv file using the shell script and sqlite3 (usually already installed on mac)

Edit: a very first draft version of Skype Exporter have been made and released.
check it, and report any issues to

I heard there are not so many nice ways to get the chat history from skype, so I came across a page of one guy who shows a way to open the sql chat history database and delete all conversations. I thought to make something more from that idea (as delete chat history is now one of the options in skype)

Create a file
place either this text:
sqlite3 -batch "$HOME/Library/Application Support/Skype/$1/main.db" <<EOF
.mode csv
.output $2.csv
select * from Messages where dialog_partner = '$2';
.output stdout
now make the script executable by running

chmod +x
now, when you want to export some chat history from certain person, you can do it by:

sh your_skype_name your_friends_skype_name

and it will create a csv file with name persons_skype_name.csv in the same folder where the script is placed.

You can also modify the script, and use for example as a sql query other tables, like:

sqlite3 -batch "$HOME/Library/Application Support/Skype/$1/main.db" <<EOF
.mode csv
.output contacts.csv

select * from Contacts;
.output stdout
 This will give you whole list of Contacts in csv file. when you run it as:
sh your_skype_name

A bit more step-by-step instruction I wrote in this post

Edit: In case you want to get the exact time-date export, I suggest changing the "select ..." line with the following one:
select author,dialog_partner,datetime(timestamp, 'unixepoch', 'localtime'),body_xml from Messages where dialog_partner = '$2';
Edit: Edit: Thanks to Bob for discovering incomplete query, I tried to fix it now.
select author, datetime(timestamp, 'unixepoch', 'localtime'), edited_timestamp, body_xml from Messages where convo_id in (select id from Conversations where identity = '$2');

Tuesday, June 4, 2013

Printing out all fields of an object

Often when debugging the printed Object has just the hash number (like Object@h43a356).
The following static method uses reflections to print out all fields:

builder.ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE);

Friday, May 10, 2013

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 :)

Friday, March 1, 2013


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.

Definition of free software

All software that are under a free software license give four freedoms to all users:
  • Freedom to use
  • Freedom to study
  • Freedom to copy
  • Freedom to modify and distribute modified copies
Notice that free here, does not mean free of charge, you can still charge / be charged for open source software (e.g. Montavista Linux).
Free Software licenses fall in two main categories:
  • The copyleft licenses – Modified code must be released under the same license
  • The non-copyleft licenses – Modified code can be kept proprietary, but still requires attribution

GPL License

General Public License Version 3 LogoThe GNU GPL (General Public License) covers over 50% of the free software projects including the Linux kernel, Busybox and many applications.
GPL is a copyleft license so it requires derivative works to be released under the same license and programs linked with a library released under the GPL must also be released under the GPL.
Some programs are covered by version 2 (Linux kernel, Busybox and others), but more and more programs covered by version 3, released in 2007.
This is a major change for the embedded market as GPLv3 requires that the user must be able to run the modified versions on the device as long as the device is targeted to consumer.
There is no obligation to release the source when the binary is not distributed. For that reason, you can keep your modifications secret until product delivery.
Once you release the binary, you should do one of the following to make sure you comply with the GPL:
  • Provide a copy of the source code on a physical medium.
  • Provide a written offer valid for 3 years that indicates how to fetch the source code.
  • Provide a network address of a location where the source code can be found.
In all cases, the attribution and the license must be preserved.
Companies often delay the release of the source code for several months or even years after the binary is released.

LGPL License

Lesser General Public License Version 3GNU LGPL (Lesser General Public License) covers around 10% of the free software projects and is mainly used by libraries. It is also a copyleft license and modified versions must be released under the same license. But contrary to GPL, programs linked against a library under the LGPL do not need to be released under the LGPL and can be kept proprietary. It must be linked dynamically, not statically as the user must keep the ability to update the library independently from the program.
LGPL is used in many libraries, including the C libraries and ffmpeg.

Non-copyleft licenses

Berkeley Software Distribution LicenseThere are many different non-copyleft licenses where you can modify the code and keep the changes proprietary. The most commonly used are:
  • Apache license
  • BSD license
  • MIT license
  • X11 license

Practical Examples

  1. If you make modifications to the Linux kernel, Busybox, U-Boot or other GPL software, you must release the modified versions under the same license and be ready to distribute the source code to your customers. Kernel drivers are a gray area but most people think they do not have to be released as GPL code and the source can be kept closed.
  2. If you make modifications to the C library, ffmpeg or any other LGPL library, you must release the modified versions under the same license.
  3. If you create an application that relies on LGPL libraries, then you can keep your application closed, but you must link dynamically with the LGPL libraries. If one the libraries is GPL, then you code becomes GPL.
  4. If you make modifications to a non-copyleft licensed software, then you can can keep your modifications closed, but you must still credit the authors either on a web page or in a leaflet in the product box.

Best Practices with Open Source Licenses

Here are some steps to follow during the development life cycle:
  • Before using a free software library, application or operating system, make sure the license matches your project constraints.
  • Make sure to keep a complete list of the free software packages you use, the original version you used and to keep your modifications and adaptations well-separated from the original version.
  • Conform to the license requirements before shipping the product to the customers.
  • Talk to a lawyer if your company can afford it.
Bear in mind that free software licenses have been enforced successfully in courts as you can see at,
If you want to keep your modifications proprietary try to do the followings if possible:
  • Always link to LGPL libraries dynamically. As long as your program does not use open source code, it can remain closed source. But if you are using GPL libraries then your source becomes GPL.
  • Write your proprietary source code in a separate application and use some inter-process communication to interact with programs based on open source code.
Finally, try to keep the changes separate either by using patches or a revision control system or both. This makes keeping track of the changes easier and facilitate migration to a newer version of free software when it is made available.

Friday, February 22, 2013

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:
  1. SyntaxHighlighter plugin [demo] [github]
  2. Snippet [link]
  3. Google Prettify [link] 
  4. Hightlight.js [link] 
  5. SHJS [link] 
  6. Chilli JS [link] 
  7. beautyOfCode [link]
  8. Lighter.js [link]
  9. DlHighlight [link]
  10. JUSH [link]

Markup editor plugins

  1. CodeMirror [link] along with CodeMirror UI [link] 
  2. MarkItUp! [link]
  3. 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 attention.
  1. redactor [link]  *
  2. ckedit [link] - has a huge amount of options, but is very slow on netbook, even the minimized version without any plugins
  3. wysihtml5 [link]
  4. mercury editor [link]  *
  5. Tiny Editor [link]
  6. elRTE [link]
  7. Aloha editor  [link] *
  8. CLEditor [link]
  9. bootstrap-wysiwyg [link]
  10. NicEdit [demo] [link]
  11. TinyMCE [link]

Tuesday, February 19, 2013

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");

    public String marshal(Date v) throws Exception {
        return dateFormat.format(v);

    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.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement(name = "foo") 
public final class Foo { 
    // Other fields omitted 

    @XmlElement(name = "timestamp", required = true) 
    protected Date timestamp; 

    public Foo() {} 

    public Date getTimestamp() { 
        return timestamp; 

    public void setTimestamp(final Date timestamp) { 
        this.timestamp = timestamp; 


Seven habits of highly effective programmers