[Oracle DB] Create and schedule a job

To create and schedule a basic job on an Oracle DB, you'll need to create:
  • A script performing the desired action
  • A schedule
  • A job
The script can be passed as code directly to the job, a function/procedure, a package function/procedure.

Step 1: Create package with our function

PROCEDURE myProcedure;  

PROCEDURE myProcedure AS
--variable declaration here
  NULL;--not actually needed
END myProcedure;

Step 2: Create schedule and job. Refer to the linked documentation for more information regarding the various parameters

 --create schedule  
      repeat_interval => 'FREQ=YOUR_FREQUENCY',     
      start_date => TO_TIMESTAMP('START_DATE', 'FORMAT'),  
      schedule_name => '"mySchedule"');  
 --create job on mySchedule  
       job_name => 'myJob',  
       job_type => 'PLSQL_BLOCK',  
       schedule_name => '"mySchedule"',  
       job_action => 'BEGIN myPackage.myProcedure; END;',  
       number_of_arguments => 0,  
       job_class => 'DEFAULT_JOB_CLASS',  
       enabled => true,  
       auto_drop => true,  
       comments => 'SOME_DESCRIPTION');  

[TIBCO Spotfire] Run script at startup from a Web Player mashup

If you created a mashup page that includes a Spotfire analysis served via Web Player using JavaScript, you can easily trigger the embedded IronPython scripts to run as soon as the report is opened.

This also works if the report is accessed directly via an URL that uses Configuration Blocks.

  • Create a Document Property as a boolean and set it to false.
  • Tie your script to that Document Property; every time its value changes, the script is triggered
If using the JS mashup page, have a JS script run when the onOpened event is fired and set that property. Make sure that the mashup page runs under the same site as the Web Player on the IIS server, eg: "Add application" under the Spotfire Web Player site.

Mashup page:

     <script type="text/javascript" src="PATH_TO/SpotfireWeb/GetJavaScriptApi.ashx?Version=3.1"></script>  
     <script type="text/javascript" src="PATH_TO/myScript.js"></script>  
           <!-- Whatever -->  
           <div id="webPlayerDiv"/>  


 var webPlayer;  
 var webPlayerRelativePath = "PATH_TO/SpotfireWeb/";  
 var analysisPath = "PATH_TO/myAnalysis";  
 <!-- when the page is accessed, include the Web Player analysis via JS -->  
 window.onload = function()  
 var openWebPlayer = function()  
   var webPlayerCustomization = new spotfire.webPlayer.Customization();  
      <!-- enable/disable toolbar buttons -->  
   webPlayerCustomization.showCustomizableHeader = true;  
   webPlayerCustomization.showTopHeader = true;  
   webPlayerCustomization.showClose = true;  
   webPlayerCustomization.showAnalysisInfo = true;  
   webPlayerCustomization.showToolBar = true;  
   webPlayerCustomization.showExportFile = true;  
   webPlayerCustomization.showExportVisualization = true;  
   webPlayerCustomization.showUndoRedo = true;  
   webPlayerCustomization.showDodPanel = true;  
   webPlayerCustomization.showFilterPanel = true;  
   webPlayerCustomization.showPageNavigation = true;  
   webPlayerCustomization.showStatusBar = true;  
      webPlayer = new spotfire.webPlayer.Application(webPlayerRelativePath, webPlayerCustomization);  
   var onError = function(errorCode, description)  
     log('<span style="color: red;">[' + errorCode + "]: " + description + "</span>");  
      <!-- when the report is loaded, set our Document Property to true to trigger the script -->  
   var onOpened = function(analysisDocument)  
   webPlayer.open(analysisPath, "webPlayerDiv", "");  

If using the configuration block in the URL instead, add:


So you'll have something like:


[Windows Server] Disable shutdown reason tracker

Every time you halt or reboot your Windows Server machine, you'll have to specify a reason before you can proceed.
This can be disabled by running:


then browsing to

Computer Configuration->Administrative Templates->System then searching for the entry: Display Shutdown Event Tracker and setting it to disabled.

[Windows Server] Change password policy

On Windows Server you can change the password policy, eg:

  • User cannot change password
  • Password must be at least X characters long
  • Password expires after X days
  • ...
Either locally for the server:


Or for the whole domain:


Run either one of these tools depending on your needs then browse to Account Policies->Password Policy

[Windows Server] Disable Server Manager auto start at login

You can block Windows Server Manager from starting automatically at login from its configuration.

Open Server Manager, then click on the Manage button and choose "Server Manager properties", you'll have the choice there.

[Windows Server] Enable automatic login

On Windows Server 2008/2012 it's possible to enable automatic login if the server is NOT a domain controller.

Simply run:


Found under WIN_INSTALL_DIR\System32, and uncheck "Users must enter a username [...]". You'll have to insert you username and password and at the next reboot you'll brought directly to your desktop.

If your server is a Domain Controller (DC) too, then you cannot use this tool, but will have to uncheck the same setting from the "Active Directory Users and Computers" snap-in


[Spotfire] Get data from marking via script

Should you need to get data from a marking while inside an IronPython script in Spotfire, you may try:

 from Spotfire.Dxp.Data import *  
 from System import String,Object  
 markingName = 'some_name' #can also be passed as parameter!  
 DataTableSelection = 'some_table' #can also be passed as parameter!  
 #get marked rows  
 rowMask = Document.Data.Markings[markingName].GetSelection(DataTableSelection)  
 #get cursor on the marking for the values we want  
 cursor = DataValueCursor.CreateFormatted(DataTableSelection.Columns["some_column"])  
 #cycle on our cursor and do something with the values  
 for row in DataTableSelection.GetRows(rowMask.AsIndexSet(),cursor):  
         print cursor.CurrentValue  

Remember that all inputs can be passed as parameters to our script!

[Oracle] Run commands in different schema

In Oracle, it is possible to change the current schema/user with the ALTER SESSION statement:


All subsequent commands will use that schema as default when nothing is specified. Of course, you'll need permission to execute the ALTER SESSION and all other statements on the new schema.


[Windows 7] Create repair USB key to run bootrec

Say that your Windows 7 machine had a problem and you can no longer boot in; usually this can be easily fixed by running the bootrec utility to repair the MBR/boot sector

For some very important reasons, this extremely useful tool can only be run from a Windows install DVD and you don't have direct access to it, even from the safe mode. Luckily, you can create a bootable USB key where to place the Windows RE without having to get said DVD - only catch: you'll need access to a working Windows 7 PC.

Now that your friend generously gave you permission to use his PC, let's get started.


[SQL] Escape special characters in LIKE statement

When using the LIKE statement in a SQL query, there are special characters which have a particular meaning such as _ (single character) and % (sequence of characters) which have to be escaped if you intend to actually search for them in the string.

You can do so as:

LIKE 'pattern' ESCAPE 'escape_character'

for example:

FROM mytable
WHERE name LIKE '%John\_D%' ESCAPE '\';

Which will search for any string containing "John_D"

[Ubuntu] Calibri and Microsoft fonts not displayed correctly

When using or displaying fonts from the Microsoft family on Ubuntu, they sometimes appear to be displayed incorrectly, rendering them unreadable. The issue is that the font rendering engine Freetype, uses the embedded bitmaps found inside those fonts which are only there so that they look pretty on Windows.

The solution is to disable that behaviour by creating a file .config/fontconfig/fonts.conf with this content

 <match target="font" >  
   <edit name="embeddedbitmap" mode="assign">  

By logging out and in again, you should finally see them correctly displayed

[HTML] Image as input button

When creating an HTML form, replacing an input button with an image is as easy as:

 <input type="image" src="http://example.com/path/to/image.png" />  

[SSL] Create Java keystore from certificate and key

To create a Java keystore file from a certificate and key pair files, you can use the openssl and keytool commands.

First, convert the certificate to PKCS12 format:

openssl pkcs12 -export -in mycertificate.crt -inkey mykey.key -out mycertificate.p12

then create the keystore:

keytool -importkeystore -srckeystore mycertificate.p12 -srcstoretype PKCS12 -destkeystore mycertificate.jks -deststoretype JKS

[Ubuntu] Change terminal background color

On Ubuntu Linux, the default gnome terminal theme doesn't lend itself easily to screenshots, since they decided for some reason that violet would be a good background choice.

To change it, install gconf-editor:

sudo apt-get install gconf-editor

Then run it:

gconf-editor &

And browse to:


where you should uncheck "use_theme_colors" and change the default background color to anything you like. You will also find all other settings such as foreground color, font and so on.


TIBCO Best Paella Meeting

A product you just love

Click on the image to view the full album


More hanging

Same route, new people, everyone hanging

Click on the image to view the full album


[TIBCO Spotfire] Link to a specific Web Player analysis page

Linking to a specific page from a Tibco Spotfire Web Player-served analysis is pretty easy.

You first need to enable the JavaScript API from the Web Player Web.config file under WEB_PLAYER_INSTALL_DIR\VERSION\webroot:

find the section and change the value to true, then restart the Web Player site from IIS.

You can now create direct links to the report pages using URLs in the format:


where page_name is NOT case sensitive, or:


where page_number starts from 0

Note the mandatory semicolon (;) at the end of the URL

[Suse] Configure LDAP server error "is ldapi enabled" from YaST

Suppose you configured your LDAP server (openLDAP) in Suse (which is STILL free after the trial period, you just don't receive updates) via YaST, but unticked the "use ldapi" checkbox.

You'll find out that you can no longer configure it via YaST due to an error "[...] is ldapi enabled?". Unfortunately, you cannot re-enable it via YaST now, but you can still do so via configuration file.

Edit /etc/sysconfig/openldap with a text editor of your choice and set:


then restart the server

sudo /etc/init.d/ldap restart

[Apache Tomcat] Find server version from command line

A quick way to find Tomcat's server version from command line is to run:

java -cp catalina.jar org.apache.catalina.util.ServerInfo

from the TOMCAT_INSTALL_DIR/tomcat/lib folder

[VirtualBox] Resize virtual hard disk

Resizing a virtual HD on VirtualBox is a fairly simple process but may involve using a third party tool too.

Changing the virtual disk size can be achieved using the modifyhd command from command line:

VBoxManage modifyhd .vdi --resize NEW_SIZE

Note that this will just resize the HD, the guest OS will NOT automatically adapt to these changes, meaning that you'll have to manually shrink/expand the virtual HD partitions before starting the OS again.

You can do that with, for example, GParted, which comes with as a handy live cd (iso) too; just download the image and link it as virtual CD then start the machine and boot from CD drive.

[Oracle] Stop/start database and listener from command line

You can start or stop an Oracle database instance (you can dbca to configure one) from command line via the SQLPlus tool by connecting to it as SYSDBA user:


then to stop:


and to start:


To manage listeners on Linux (use netca to configure one) you can run instead:

$ORACLE_HOME/bin/lsnrctl stop|start

Where is the name of the listener as configured via netca or found as the output of:

ps -ef | grep tnslsnr

[VirtualBox] Linux guest additions installation fails due to missing kernel sources

If the installation of VirtualBox's guest additions packages fails on Linux due to missing kernel sources, just install them (google install kernel sources to find many detailed guides for your particular OS) as well as make and gcc.

Then, from a console do a:

export KERN_DIR=path_to_the_sources

before running the install script


[Java] unzip

Now that we know how to zip in Java, let's see how to unzip using the same Apache Commons Compress library:

 import java.util.*;  
 import java.io.*;  
 import org.apache.commons.compress.archivers.zip.*;  
 import org.apache.commons.compress.utils.IOUtils;  
 public void unzip(String ziplocation, String zipname, String unziplocation){  
      //method variables  
      private ZipFile zipFile;  
      private Enumeration<ZipArchiveEntry> entries;  
      private ZipArchiveEntry entry;  
      private File entryDestination;  
      private InputStream in;  
      private OutputStream out;  
      zipFile = new ZipFile(ziplocation+File.separator+zipname);  
      //get zip file content references  
      entries = zipFile.getEntries();  
      if(entries != null){  
           //for each reference, unzip to unziplocation, creating directories if needed  
           while (entries.hasMoreElements()) {  
                entry = entries.nextElement();  
                entryDestination = new File(unziplocation, entry.getName());  
                if (entry.isDirectory()){  
                else {  
                     in = zipFile.getInputStream(entry);  
                     out = new FileOutputStream(entryDestination);  
                     IOUtils.copy(in, out);  
                     //close streams ignoring exceptions  

[Java] zip file or directory (with subdirectories)

Note: it is possible to perform zip operation with standard Java libraries, but more superfluous steps are required (ie: more streams have to be handled).

A simple way to zip a file or folder (with or without subdirectories) maintaining the folders structure is using the Apache Commons Compress library.

 import java.util.*;  
 import java.io.*;  
 import org.apache.commons.compress.utils.IOUtils;  
 import org.apache.commons.compress.archivers.*;  
 import org.apache.commons.compress.archivers.zip.*;  
 public void zip(String location, String name, String ziplocation, String zipname){  
      //method variables  
      private OutputStream out;  
      private ArchiveOutputStream zip_out;  
      private File f;  
      //out writes the final file, zip_out creates the zip archive  
   out = new FileOutputStream(new File(ziplocation+File.separator+zipname+".zip"));  
   zip_out = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out);  
      //zip it  
      File f = new File(location+File.separator+name);  
      //first time baseDir is empty  
      dozip(f, "");  
      //close archive  
 //aux method for zipping  
 private void dozip(File myFile, String baseDir) throws Exception{  
      //maintain the directory structure while zipping  
      String entryName = baseDir+myFile.getName();  
      //DO NOT do a putArchiveEntry for folders as it is not needed  
      //if it's a directory then list and zip the contents. Uses recursion for nested directories  
      if(myFile.isDirectory() == true){  
           File[] filesList = myFile.listFiles();  
           if(filesList != null){  
                for (File file : filesList) {  
                     dozip(file, entryName+File.separator);  
           //add file  
           zip_out.putArchiveEntry(new ZipArchiveEntry(myFile, entryName));  
           IOUtils.copy(new FileInputStream(myFile), zip_out);  

It has to be recursive so that we can handle subdirectories correctly. The resulting zipped file will unzip to the same exact folder structure originally zipped. If you pass the location and ziplocation parameters with the path separator already appended, there's no need to concatenate File.separator in the code.

[Java] move file or directory

Java versions before 7 amazingly lack a simple (one method) way of moving a file or directory to another directory.

Luckily there's the Apache Commons IO library. Using that, you would do something like:

import java.util.*;
import java.io.*;
import org.apache.commons.io.FileUtils;

public void move(String fromDir, String toDir){
//moveToDirectory(File, File, createDestDir), we MUST create two File objects before!
File from = new File(fromDir);
File to = new File(toDir);
/*returns void, throws exceptions: 
NullPointerException - if source or destination is null
FileExistsException - if the directory or file exists in the destination directory
IOException - if source or destination is invalid or if an IO error occurs moving the file*/
FileUtils.moveToDirectory(from, to, false);

[DOS] touch equivalent command to create a file

How do you create a file from DOS?


some_command >> filename

works but what if you just need to create an empty file? Well there's no single command like touch you can use, but a simple way to achieving the same result is by combining type and the output redirection.

type, will show you the input file contents. type nul will return successfully without showing any output. Now it's just a matter of adding redirection:

type nul >> filename

and you'll have created and empty file.

[Remmina] Cannot connect to RDP server

When using Remmina you may sometimes encounter the generic 'Cannot connect to RDP server' error even if all settings are correct, and usually there's no other debug information available.

What has helped me most of the times is simply deleting the server entry line from ~/.freerdp/known_hosts then trying to reconnect. You should be prompted to accept the server key again and eventually it should connect.

[Oracle] Find DB components versions

Here's a simple query to quickly find the currently installed versions of Oracle DB's components:

SELECT * FROM v$version;


Malta against the infidels

Against all odds the brave chevaliers made it back

Click on the image to view the full album


[Linux] MPlayer 5.1 AAC to AC3 encode on the fly

Mplayer is arguably the most powerful media player for Linux, but unlike VLC, it lacks an intuitive and powerful configuration GUI (though SMPlayer is amazing).

Thus, in order to set it up correctly, you'll need to fiddle both with the GUI and some old-school text file configuration.

First, install it as (for Ubuntu/Debian):

sudo apt-get install mplayer2 smplayer

Then check you have some output like this:

lavcac3enc     : runtime encode to ac3 using libavcodec

when you run this command:

 mplayer -af help | grep lavcac3enc

Now, to have it encode a 5.1 AAC audio track to AC3 on the fly, you'll need to:

configure via GUI (SMPlayer):

- disable the audio equalizer under Preferences->General->Audio
- enable AC3/DTS pass-through S/PDIF under the same section
- add this parameter:


under Advanced->Options for MPlayer->Audio filters

configure via text file by editing ~/.mplayer/config:


I'm using pulse since alsa gives me nearly 2 seconds of audio delay, but if you wish you can use it by setting instead:



[Ubuntu] Enable hibernation

Ubuntu by default has the hibernation option disabled, even if the system is installed with enough swap space.

Before enabling it, first check if it works without issues by running this command:

sudo pm-hibernate

If the system hibernates correctly and you don't see any errors, edit the /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla file:

gksu gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

Then look for these two sections:

[Disable hibernate by default in upower]
[Disable hibernate by default in logind]

And change the ResultActive value to yes

Save, reboot and you'll have the option to hibernate the system now.

[Ubuntu] Fix volume reset after reboot

A small but annoying bug in Ubuntu causes the sound volume to be unmuted and reset to 100% after a reboot or logout.

This can be fixed by editing the /etc/pulse/default.pa configuration file for PulseAudio:

gksu gedit /etc/pulse/default.pa

Then look for these lines:

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

and comment out the first one:

### Automatically restore the volume of streams and devices
#load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

Save, logout or reboot and you're set.


[OpenSSH] Convert putty PPK key to OpenSSH format

To convert a putty-generated PPK key to the OpenSSH format, you can use puttygen:

puttygen MY_PPK_KEY.ppk -O private-openssh -o MY_OpenSSH_KEY

to convert a private key and:

puttygen MY_PPK_KEY.ppk -O public-openssh -o MY_OpenSSH_KEY

to convert a public key

[VMware Player] Share USB mobile broadband between host and guest OS

To share a USB mobile broadband connection between the host and guest OSs with VMware Player, simply set the guest OS network interface to use the NAT mode instead of the bridged mode.

This way you'll also be able to set up routing rules on the host OS which will apply to the guest OS too.


[Windows] Scan hosts for open ports without Telnet with PortQry

When testing a connection, you'll probably want to check if a particular port is reachable on the destination host. Telnet is fine enough for this task:

telnet host port

but unfortunately, Windows comes with the Telnet client disabled by default. Since enabling it requires you to have Administrator privileges, an alternative is to use Microsoft PortQry which is a command line tool with no installation required.

After downloading and extracting it, you can run it as:

portqry -n host -e port

[VmWare] Reduce guest swapping

VmWare allows you to specify how the guest system handles swapping to the host disk. Much like Linux's swappiness value, you can suggest to use more host memory instead of swapping to disk; this is especially useful if you do not have a swap partition.

To edit the setting, open your VM's .vmx file, while the VM is powered off, using text editor and add these lines:

MemTrimRate = "0"
mainMem.useNamedFile = "FALSE"
sched.mem.pshare.enable = "FALSE"
prefvmx.useRecommendedLockedMemSize = "TRUE"

Note: If you are using a Linux host, use the following entry instead of mainMem.useNamedFile which only applies to Windows hosts:

mainmem.backing = "swap"

[Ubuntu] Add swap partition and change swappiness

If for some reason(s) you decided to install Ubuntu without specifying a swap partition, you can still add one (or a swapfile) later on without too much hassle.

[Debian] Run Wireshark as non-root user

Wireshark by default enables only the root user to capture network traffic; the idea is that as a root user you'll capture and store the traffic and as non-root user you'll perform any analysis you need. This unfortunately does not allow you to perform a "live capture" where you can work on the data while it is freshly captured from your network interface.

To enable non-root users to run a live capture too, simply dpkg-reconfigure it:

sudo apt-get install wireshark
sudo dpkg-reconfigure wireshark-common

When prompted to allow non-root user to perform restricted operations, say Yes.

Then logout and login again and you should be set. If not, add your user to the wireshark group:

sudo usermod -a -G wireshark $USER

[Debian] Test APT changes without altering the system

The APT package manager allows you to test the changes a command would perform without altering the system. To do that, simply add --dry-run to the desired command (usually an install or remove one).


apt-get install SOMEPACKAGE --dry-run

Will show you what dependencies will be installed alongside the specified package but no actual installation will take place.

[Linux] Add Wine-installed application launcher to panel or menu

If you need to run Windows applications under Linux, then you're probably using WineHQ. To add a Wine-installed application launcher to the desktop panel or menu, just add a new "Custom launcher" with this command:

bash -c "wine PATH/TO//FILE.EXE"

[FileZilla] Connect to SFTP site with PPK key file

To connect to an SFTP site using a PPK key file with FileZilla, you'll just have to follow some simple steps.

First, add the key file to FileZilla under Preferences->Settings->Connection->SFTP

Then, from the Site Manager fill the fields with the values for your SFTP connection. If you don't need to put in a password, choose "Normal" as "Logon type"


Budapest, in euros please!

Leading the army to repel the archers attack in Budapest can tire you up, thankfully a litre of ale costs 590 Florins only.. wait that's too much.. or is it?

Click on the image to view the full album


[Debian] Set up wireless networking on a Lenovo T430 laptop

On a Lenovo T430 running Debian Wheezy and MATE desktop environment, the wireless networking was not working good even after installing the non-free drivers and Wicd, so you can install GNOME's good ol' network-manager instead.

[Debian] Install MATE desktop environment

Now that GNOME 2 is dead in favour of the not-so-good GNOME 3, users are still able to experience their solid and favourite desktop experience with MATE.

Installing it is really simple; this guide will describe how to add it to Debian Wheezy (stable release).

[Debian] Install package and its dependencies using dpkg

When installing a package with dpkg:

dpkg -i package.deb

its dependencies will not be automatically installed. To solve this, run:

apt-get -f install

after the dpkg installation

[Linux] Set LightDM default session

To change the default desktop session the user logs in to from LightDM, run as root:

/usr/lib/x86_64-linux-gnu/lightdm/lightdm-set-defaults -s DEFAULT_SESSION


/usr/lib/x86_64-linux-gnu/lightdm/lightdm-set-defaults -s mate-session

[Xfce] Disable session saving on shutdown or logout

Xfce can save the current session on shutdown or logout so that the next time the user logs in, all the applications he was using are up and running. Unfortunately, this setting sometimes is enabled even when not requested; to change it, edit ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml by setting these properties:

 <property name="AutoSave" type="bool" value="false"/>  
 <property name="SaveOnExit" type="bool" value="false"/>  


[Linux] Replace Unity with another desktop environment

If you too feel like Unity is a nightmare and would like to switch to another desktop environment, but do not fancy to reinstall everything from scratch, know that it's indeed possible to switch between multiple installed ones at login time, although it's not recommended to have more than one installed.

This example will show how to convert Ubuntu(Unity) in XUbuntu(Xfce), but can be adapted to any desktop environment you like (simply install the desired environment instead of xubuntu-desktop).

First, install XUbuntu desktop:

sudo apt-get install xubuntu-desktop

Now if you log out, before you log in, you'll be able to select which desktop environment you want to log in to by clicking on the Ubuntu logo and selecting another session (ie: XUbuntu Session).

If you wish to remove the old environment to clean things up a little, run:

sudo apt-get remove activity-log-manager-common compiz compiz* gnome-applet* gnome-bluetooth gnome-control-center gnome-desktop* gnome-pane* gnome-power-manager gnome-screensaver gnome-screenshot gnome-sessio* gnome-shell-common gnome-termina* gnome-user* hud libzeitgeist* nautilus overlay-scrollba* python-zeitgeist unity unity* zeitgeist zeitgeist*

Afterwards, you may also want to run:

sudo apt-get autoremove

and if you have installed deborphan:

sudo orphaner --purge

[Linux] Xfce change show desktop keyboard shortcut

Trivially, this setting can be found under System Settings->Window Manager->Keyboard shortcuts, then just double click on a shortcut to input the new one. The default value is CTRL+ALT+D.

However, it may happen that the shortcut associated with the "Minimize all open windows and show desktop" behaviour does not work after logging out of the session or restarting the PC.

It is possible to fix this issue by manually editing the configuration in .config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

Look for the line containing show_desktop_key as value and alter it suiting your needs. For example, to set the shortcut as Super+D, use:

Note that the "show desktop" behaviour differs from the standard in Xfce. Usually, after minimizing everything then opening a new window and minimizing everything again, you'd see the desktop. In Xfce instead, the minimization is treated as a toggle so the second time you minimize everything, you're actually bringing all the previously minimized windows back up.

You can verify this by adding the "show desktop" button to the panel, then toggling the shortcut and seeing that the button is depicted as pressed and stays that way until you toggle the shortcut again.

[XUbuntu] Disable guest session

To disable the guest session in XUbuntu, simply run:

sudo sh -c 'printf "[SeatDefaults]\nallow-guest=false\n" >/usr/share/lightdm/lightdm.conf.d/50-no-guest.conf'

this was tested under release 14.04 LTS.

To enable it again, either delete that file or remove the allow-guest=false line from it.

You may have to log out and log in again to see the changes applied.

[Linux] Xfce set Chrome as default browser

So, you installed Google Chrome (not Chromium) on your machine and set it as default browser from its menu but even if it's the only installed browser, you see Xfce not using it as the default one:

exo-open --launch WebBrowser

asks you to specify the default browser instead of launching it, and if you set it, Chrome complains he's not the default every time you open it.

You may work around the issue by changing the preferred application for the browser:

gksu xfce4-settings-manager

and setting the default browser as:

/usr/bin/google-chrome "%s"

then ignoring Chrome's complaint.

[Linux] Xfce not showing all apps in the menu

When using Xfce as your desktop environment, you may notice that some installed applications are not listed in the main menu while other desktop environments indeed show them.

What happens is, if one of the application categories is Settings, then it won't show up under the main menu and will be listed under the Settings Manager application, accessible from the main menu. After opening it, you'll see those unlisted applications available.

After editing the application categories by altering its .desktop file, you'll see it listed under the main menu as well.

[Linux] Add/remove PPA repositories

You can easily add and remove PPA repositories to your software sources with the apt-add-repository command. Use:

sudo apt-add-repository ppa:USER/REPOSITORY

to add and:

sudo apt-add-repository -r ppa:USER/REPOSITORY

to ONLY remove (same as --remove) it. Alternatively, if you installed ppa-purge, you can use it to remove the repository AND (if possible) revert to the official packages:

sudo ppa-purge ppa:USER/REPOSITORY

[Linux] Install VMWare Player

After downloading VMWare Player for Linux, you may feel a bit stuck on how to install it. Luckily, it's as easy as:

gksudo bash PATH_TO_DOWNLOAD_LOCATION/VMware-Player-VERSION.bundle

If you do not have gksu, install it:

sudo apt-get install gksu


[Oracle] Get user's tablespace quota

To check the current quota status for user's tablespaces, run this query on DBA_TS_QUOTAS:

SELECT tablespace_name, username, ROUND(bytes/1024/1024) MB, ROUND(max_bytes/1024/1024) MAX_MB 
FROM dba_ts_quotas;

remembering that you will need the grants to access it

[TIBCO ActiveSpaces] Implement shared_all persistence

TIBCO ActiveSpaces supports persistence to a DB of your choice when spaces are configured in shared_all persistence mode.

By implementing the Persister interface in Java, C or .NET, you are able to create a persistence client that connects to your DB and joins the metaspace, receives callbacks on AS events and handles persistence to and from the DB.

You can download a code sample in Java (DISCLAIMER: NOT PRODUCTION READY, just a sample!) showing you how to create the persistence client to an Oracle DB.

[Oracle] Get DB tables size in MB

To have an idea of how much space your Oracle DB tables occupy, you may run this query on ALL_TABLES:

SELECT owner, table_name, num_rows, ROUND((num_rows*avg_row_len)/(1024*1024)) MB 
FROM all_tables;

Remember that it is accurate only if you gathered statistics before:


Usually you could have the grants to query it but a more precise query, would be to query DBA_SEGMENTS, which would require you to have additional grants:

SELECT segment_name, segment_type, ROUND(bytes/1024/1024) MB
FROM dba_segments
WHERE segment_type='TABLE'
AND segment_name='your_table_name';

and will include also the data currently in the bin. If you want to ignore it, query DBA_EXTENTS instead


[CentOS] Install Oracle XE

Unlike on Windows, installing Oracle XE on CentOS requires some more steps after the actual RPM installation.

After you download the zip file, extract it and install the RPM, browse to the Disk1 directory under the folder where you extracted everything into.

Now run as root

/etc/init.d/oracle-xe configure

to configure and start the database.

The installation process creates a /u01 folder, inside it, under app/oracle/product/VERSION_NUMBER/xe/bin you'll find the oracle_env.sh script which sets some environment variables used by Oracle for you.

To have it permanently set those variables for your user, add this line to your .bash_profile (found under your user home):

. /u01/app/oracle/product/VERSION_NUMBER/xe/bin/oracle_env.sh

After this, you should be able to run SQLPlus (you may have to log out and log in again or just open a new terminal window).

[Linux] Purge unwanted locales on RPM installation

When installing RPM packages on Linux, you'll also install a lot of unneeded locales - there are only so many languages you can speak.

To avoid installing all locales every time, you can specify the ones you're interested in inside the /etc/rpm/macros.lang file (example for English UK and Italian):

%_install_langs   en:it:en_GB:en-GB:it_IT:it-IT

this will apply only to newly installed RPMs.

[CentOS] Browse folders in same window

CentOS comes out of the box with the uber-annoying setting to open each folder in a new window; this makes the screen really messy very fast as you browse the filesystem.

To have it always use the same window when opening new folders, just alter this setting:

Edit->Preferences->Behavior->Always open in browser windows

Then log out and log in again


Real-time fun in Rome

A.k.a. TIBCO CTS meeting 2014

Click on the image to view the full album


[TIBCO BusinessEvents] Listen for ActiveSpaces events

When working with TIBCO BusinessEvents, it's possible to create a channel on which to listen for TIBCO ActiveSpaces events such as:

  • TIBAS_EVENT_PUT when a tuple is inserted, overwritten, or updated
  • TIBAS_EVENT_TAKE when a tuple is taken or removed
  • TIBAS_EVENT_EXPIRE when a tuple reaches the end of its time to live and expires from the space
  • TIBAS_EVENT_SEED when there is redistribution after a seeder joins or leaves, and the local node is seeding or unseeding. This is only applicable if the listener distribution scope is SEEDED
  • TIBAS_EVENT_UNSEED when there is redistribution after a seeder joins or leaves, and the local node is seeding or unseeding. This is only applicable if the listener’s distribution scope is SEEDED

[Oracle] Get DDL statement from SQL query

In Oracle, it's possible to get an object DDL statement via a simple SQL query, by relying on the get_ddl function in the DBMS_METADATA package.

The syntax is simple:

    object_type     IN VARCHAR2,
    name            IN VARCHAR2,
    schema          IN VARCHAR2 DEFAULT NULL,
    version         IN VARCHAR2 DEFAULT 'COMPATIBLE',
    model           IN VARCHAR2 DEFAULT 'ORACLE',
    transform       IN VARCHAR2 DEFAULT 'DDL')

For example, to get the DDL statement for all VIEWs under schema USER_SCHEMA:

FROM user_views;

if you want tables, use:

FROM user_tables;

while if you are interested in a specific object (eg a table) you can use:


[Windows] Force service shutdown

On Windows, if a service is hanging in the STOPPING state, it's possible to forcefully stop it by following these steps.

First, find the service name. In the service properties, on the General tab, it's the first entry: Service name
Then, open a command prompt and type:

sc queryex SERVICE_NAME

to find the service PID

Lastly, type:

taskkill /PID SERVICE_PID /F

to forcefully kill the service with PID SERVICE_PID. Note that this allows you to also kill services with the NOT_STOPPABLE and IGNORES_SHUTDOWN flags.

[Oracle] Reset/recover SYS password

In Oracle, it's possible to connect to the database without specifying a password if the user account on the machine where the DB is running is a member of the DBA group.

Then it will be possible to reset the password for any user (even SYS); this is especially useful if you forgot what your password was. First, connect to the machine where the DB is running then open a command prompt and type:


to log in, then type


to change the password for USER_NAME


[PL/SQL] Extract data from XML BLOB

What if you need to query a stored XML, but it was unfortunately stored as a BLOB instead of a CLOB?

You can easily convert it to a CLOB first, then query it with:

 l_blob BLOB;  
 l_clob CLOB;  
 l_dest_offsset PLS_INTEGER := 1;  
 l_src_offsset PLS_INTEGER := 1;  
 l_warning PLS_INTEGER;  
 l_myData MYTYPE;  
 --get the blob  
 SELECT myBlob  
 INTO l_blob  
 FROM myTable  
 WHERE something;  
 --create empty CLOB  
      dest_lob => l_clob,  
      src_blob => l_clob,  
      amount => DBMS_LOB.LOBMAXSIZE,  
      dest_offset => l_dest_offsset,  
      src_offset => l_src_offsset,  
      blob_csid => DBMS_LOB.DEFAULT_CSID,  
      lang_context => l_lang_context,  
      warning => l_warning  
 --crea XML from CLOB  
 l_XML := XMLTYPE.CREATEXML(l_clob);  
 --extract data from the XML  
   '//root/node/text()',  --be sure to match your XML tree naming! - /text() is optional, use it if the node content is CDATA
   'xmlns="OPTIONAL_XMLNS_HERE"' --optional, if you don't need it, do not even pass it to the function   
 ) node_value  
 INTO l_myData  
 EXCEPTION WHEN NO_DATA_FOUND THEN --optional exception block  
      --something else  

[PL/SQL] Convert BLOB to CLOB

So you decided for some reasons that a BLOB would be a good type choice to store something for which the CLOB was invented, but now you'd like to take full advantage of all the CLOB functions or you need to query that XML you stored.

After blaming the gods for that poor choice, you may want to ease your pain by converting it to a CLOB:

 l_blob BLOB;  
 l_clob CLOB;  
 l_dest_offsset PLS_INTEGER := 1;  
 l_src_offsset PLS_INTEGER := 1;  
 l_warning PLS_INTEGER;  
 SELECT myBlob  
 INTO l_blob  
 FROM myTable  
 WHERE myConditions;  
      dest_lob => l_clob,  
      src_blob => l_blob,  
      amount => DBMS_LOB.LOBMAXSIZE,  
      dest_offset => l_dest_offsset,  
      src_offset => l_src_offsset,  
      blob_csid => NLS_CHARSET_ID('YOUR_CHARSET'), --optional, you may also use DBMS_LOB.DEFAULT_CSID if you don't have specific requirements  
      lang_context => l_lang_context,  
      warning => l_warning  

You'll then have your converted BLOB in the l_clob variable

[Oracle SQL] SELECT FROM list of string values

In Oracle SQL, you can perform a SELECT from a list of string values using the DBMS_DEBUG package as:

FROM TABLE(SYS.DBMS_DEBUG_VC2COLL('value1', '...'. 'valueN'))

Which will create a table on the fly populating it with the values passed, one for each new row in a single column. Of course, you'll need to be able to execute that package's procedures/functions.

[Microsoft Access] UPDATE table SELECT FROM nested query

For those of you forced to use Microsoft Access, thus needing to write bad SQL, here's how you would write an UPDATE table SELECT FROM subquery statement:

SET A.column = B.column
WHERE A.key = B.key

which is equal to SQL's:

SET column = (
        SELECT B.column
        FROM B
        WHERE A.key = B.key)


[TIBCO BusinessEvents] Send message to specific receiver on a multi-event queue

In an usual TIBCO BusinessEvents setting, all messages received on a channel are automatically mapped to the specified default event, but this process only works if ALL the messages received represent that particular event.

Since it's also possible to register multiple events on a queue binded to the same channel, for all the non-default events, we have to explicitly specify which event to fire, so that the incoming message is mapped to the correct event.

This can be done by adding two parameters to the message in the header section:
  • _ns_ which specifies the namespace. The namespace points to the event type, eg: www.tibco.com/be/ontology/Events/MyEvent
  • _nm_ which specifies the name of the event, eg: MyEvent

[TIBCO Spotfire] Export only marked rows from Web Player

Users accessing Spotfire analysis from the Web Player have the ability to export data in multiple formats (assuming they were given the necessary licenses).

It is also possible to only export marked rows by selecting the data of interest, enabling the Details-On-Demand view, and exporting the data from there, simple as that.

[TIBCO Spotfire] Count grouping by columns

With custom expressions in Spotfire, you have more control on how the data is to be handled and displayed. These expressions are also useful when managing calculated values and calculated columns.

One common thing you may want to do, is the equivalent of the SQL statement:

SELECT column1, ..., columnN, COUNT(columnX) FROM table GROUP BY column1, ..., columnN

To count how many rows have a particular value in columnX, grouping the results by the unique values in column1, ..., columnN

In Spotfire, this can be accomplished with the OVER expression:

Count([columnX]) OVER ([column1], ..., [columnN])

If you need a COUNT(DISTINCT(columnX)), you can use UniqueCount([columnX]) instead.

[TIBCO Spotfire] Filter only unique values in data to display

When configuring a data source, you have multiple options to limit the data in the display visualization. One of those is Limit data using expression, which allows you to write simple expressions that will always be evaluated, regardless of the filters the user may set.

One thing it's possible to accomplish this way, is the equivalent of the SQL statement:

SELECT DISTINCT(column1, ..., columnN) FROM mytable

to only display tuples with the same values in the specified columns once, regardless of any other different values they may have in other columns.

In Spotfire, you can do this with the Rank function:

Rank(Rowid(), "Asc", [column1], ..., [columnN]) = 1

[TIBCO Spotfire] Write data to database

TIBCO Spotfire primarily reads data from a DB to populate analysis and reports, but it is also possible to have it write data back on the database.

Doing so is fairly easy; the key point is to remember that the last operation in the Information Link MUST return data back. This means that your procedure that performs the desired operation (INSERT, UPDATE, DELETE) MUST return data back, even if usually you wouldn't do that in standard SQL.


[PL/SQL] Duplicate rows changing column values

Imagine you have a table user_accesses like this:


And you want to split the department column so that each row only has one value instead of a semi-colon separated list.

The following script replicates the rows where the specified column has multiple values, replicating all the data in the other columns. The specified column will be populated with each value in the list (replicated values are not discarded).


You can perform an INSERT passing a ROWTYPE value in Oracle versions greater than 9 with:

INSERT INTO mytable VALUES myrowtypeval;