Oracle Snippets Part 1 – How to clear a schema in Oracle

This script deletes all user objects in a schema (Tables, views, procedures, dblinks, etc…) without dropping the user.

SQL Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
conn test/test

set head off
set pagesize 0
set verify off
set feedback off

select 'drop '||object_type||' '|| object_name||  DECODE(OBJECT_TYPE,'TABLE',' CASCADE CONSTRAINTS;',';')
from user_objects

spool drop_objects.sql
/
spool off

@drop_objects.sql

original source: https://community.oracle.com/thread/328462

JUnit Snippets Part 1 – The Temporary Folder Rule

The TemporaryFolder Rule is the easiest way to create a temporary folder in your JUnit tests.

Available since JUnit 4.7

The following code snippet was taken from the JUnit API docs.

1
2
3
4
5
6
7
8
9
10
11
public static class HasTempFolder {
  @Rule
  public TemporaryFolder folder = new TemporaryFolder();

  @Test
  public void testUsingTempFolder() throws IOException {
      File createdFile = folder.newFile("myfile.txt");
      File createdFolder = folder.newFolder("subfolder");
      // ...
     }
 }

Ext.dataview.DataView and setEmptyText

I’m currently developing a Sencha Touch application and therefore I use Sencha Touch Beta2.

I had to change the emptyText property of a Ext.dataview.List via setEmptyText() and ran into a little bug which adds another emptyTextCmp component inside the list’s element rather than update the existing one.

So I came up with an override for this. maybe this helps someone out there too.

The function code we are going to override is Ext.dataview.Dataview#updateEmptyText:

Original function code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
updateEmptyText: function(newEmptyText) {
        var me = this;
        if (newEmptyText) {
            me.emptyTextCmp = me.add({
                xtype: 'component',
                cls: me.getBaseCls() + '-emptytext',
                html: newEmptyText,
                hidden: true
            });
        }
        else if (me.emptyTextCmp) {
            me.remove(me.emptyTextCmp, true);
            delete me.emptyTextCmp;
        }
    }

Override:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Ext.define('My.override.of.dataview.DataView', {
    override: 'Ext.dataview.DataView',
   
    updateEmptyText: function(newEmptyText){
        var me = this;
        if (newEmptyText) {
            if (me.emptyTextCmp){
                me.emptyTextCmp.setHtml(newEmptyText);
            } else {
                me.emptyTextCmp = me.add({
                    xtype: 'component',
                    cls: me.getBaseCls() + '-emptytext',
                    html: newEmptyText,
                    hidden: true
                });
            }
        } else if (me.emptyTextCmp) {
            me.remove(me.emptyTextCmp, true);
            delete me.emptyTextCmp;
        }
    }
});

Sencha Touch (ExtJS) – Problems with Ext.TabPanel when using ‘cardswitch’ event

Currently I’m writing a mobile application based on Sencha Touch 1.1.0.
When I was using the ‘cardswitch’ event of the TabPanel class I noticed that the API docs show a wrong number of arguments:

Description in API docs:

1
cardswitch : ( Ext.Container this, Ext.Component newCard, Ext.Component oldCard, Number index, Boolean animated )

This is how it is implemented:

1
cardswitch : ( Ext.Component newCard, Ext.Component oldCard, Number index, Boolean animated )

Maybe this is helpful to some developers out there.