Montag, 22. April 2013

Force Opera to display JSONs in browser

Maybe you suffer from the problem, that Opera always wants to download a JSON file (mime: application/json) instead of displaying it using fancy extensions like JSONviewer. This can be solved by adding a rule for mime type application/json, as seen in the screenshot. Click Settings > Preferences > Advanced > Downloads > Add.

Samstag, 20. April 2013

YouTube videos to mp3 converter script

I am using a tiny shell script that converts a youtube video to mp3. It takes as input the youtube url and generates the mp3 in ~/youtube-dl. It requires youtube-dl, so probably it is limited to *NIX boxes.
$ sudo apt-get install youtube-dl
Create a file youtube-conv.sh with the following code
#/bin/sh name=$(youtube-dl --get-title ${1}|sed 's/ /_/g') echo title ${name} id=$(echo ${1} | sed 's/=/ /g' | awk '{print $2}') echo download to ${id} youtube-dl ${1} -o ${id} # > /dev/null echo convert to ~/youtube-dl/${name}.mp3 convert=$(ffmpeg -i ${id} -f mp3 ~/youtube-dl/${name}.mp3) echo ${name}.mp3 created echo remove ${id} rm ${id}
Invoke the script with the youtube url as argument, e.g.
./youtube-conv.sh http://www.youtube.com/watch?v=7cF2ZSNrEIw
Note: there are issues, if the video name contains non ASCII characters

Mittwoch, 17. April 2013

CQ5 replace Tab in ContentFinder with custom implementation

Adobe already explained how to add a custom tab to Content Finder. In order to replace an existing tab with your custom js file, e.g. movie tab, you simply have to use the same "id" value. For the movie tab, it is cfTab-Movies
{ "tabTip": CQ.I18n.getMessage("Movies"), "id": "cfTab-Movies", "xtype": "contentfindertab", "iconCls": "cq-cft-tab-icon movies", (..) }

Montag, 15. April 2013

Parent-aware unidirectional @OneToMany relationship in Hibernate/JPA

In a classical unidirectional one-to-many relation, the referred entity (Call) is not aware of its parent (Bill).
public class Bill { (...) @OneToMany( fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinColumn(name = "billId") private Set calls; (...) }
Though, there may be some cases, where it is reasonable to make the information of the relation also available in the child entity (again, Call), e.g. if you want to retrieve all Calls of a specific Bill. An easy way to achieve that, is to explicetily add a @JoinColumn to the child entity. This column is completely managed by JPA/Hibernate, hence not modifieable.
public class Call { (...) @Column( insertable = false, updatable = false ) private Long billId; (...) }
This solution expects, that Id column of Bill is of type long. Use orphanRemoval=true, to force removal of not associated childs.

Samstag, 13. April 2013

Video lectures about machine learning

Some really good videos of an indian university, in the field of machine learning

Freitag, 5. April 2013

mutlitail - scrolback and pause features

The two probably most important features in multitail (via pantz.org).

Pause

To pause all the logs press the "p" key.

Scroll back

To use the log windows scroll back feature press the "b" key and select the log you want to scroll back through.
Maybe you will need those commandline options
-mb x Set scrollback buffer size (in bytes, use xKB/MB/GB). -M nlines Set the buffersize on ALL following files.

glogg - GUI-based log highlighting

Days ago, I mentioned a console based highlight tool multitail, today I want to suggest the GUI-based tool glogg. Glogg could be an *NIX alternative to the Windows flagship BareTail.
$ sudo apt-get install glogg

Montag, 1. April 2013

Apache2 file permissions

Directories
find /var/www -type d -exec chmod 0775 {} +
Files
find /var/www -type f -exec chmod 0664 {} +