Wednesday 10 December 2014

Hooray! Moved to keencod.in

Keen /c/o/d/e blog moves from Blogger to separate hosting.
Get ready for new tips, bits and awesome project releases. Check at keencod.in!

Wednesday 20 August 2014

Just to Remember: Using GoldenGate defgen utility

./defgen paramfile ./dirprm/defgen.prm
Credits to Oracle DBA blog.

Thursday 14 August 2014

Remote Desktop: Map local drive as network drive to speed up access

A handy feature of MS Remote Desktop is it's ability to access local computer's filesystem.
But the round robin between remote and local is very slow when you access it through 'My Computer' then 'C on LocalMachine' and so on. For me it opens next folder for about 10 seconds or more.
To greatly increase local filesystem access speed (up to multiple times) one should map local filesystem as network drive, say map \\tsclient\D\ as X:.
And don't forget to check 'Reconnect on logon' ;)

Tuesday 29 July 2014

PL/SQL: Procedure to copy package with another name

Here's simple procedure build upon custom listagg implementation (see Custom listagg function using cursor to bypass ORA-01489) that creates a copy of existing package with a new name.
It comes very handy when you have several versions of package (say production and development) and constantly switch between them.
It simply obtains package definition and body and then recreates them with a new name.
procedure cp_package( a_owner in varchar2, a_name in varchar2, a_new_name in varchar2 ) as 
  v_head clob;
  v_body clob;
begin
  select regexp_replace( 
    pk_utils.listagg_clob( 
        cursor (
          select text
          from all_source
          where name like upper( a_name ) 
            and owner like upper( a_owner )
            and type like 'PACKAGE'
          order by line
        )
        , ''
      )
      , a_name
      , a_new_name
      , 1
      , 0
      , 'imn'
    )
    , regexp_replace( 
    pk_utils.listagg_clob( 
        cursor (
          select text
          from all_source
          where name like upper( a_name ) 
            and owner like upper( a_owner )
            and type like 'PACKAGE BODY'
          order by line
        )
        , ''
      )
      , a_name
      , a_new_name
      , 1
      , 0
      , 'imn'
    )
  into v_head
    , v_body
  from dual
  ;

  execute immediate 'create or replace ' || v_head;  
  execute immediate 'create or replace ' || v_body;  
  
  dbms_output.put_line( 'Successfully copied package ' || upper( a_name ) || ' to ' || upper( a_new_name ) );
end;

Sunday 15 June 2014

Separate keyboard: Moving toward a dream

I've been dreaming about separate keyboard since I first read someone saying that using it could double typing speed. Think it could be the author of great touch typing courses Vladimir Shahidjanyan who said that. This idea sparked in my head as I always was too lazy and hated to lose time when I could save it. So after a while I bought myself Kinesis Freestyle 2! But as a heavy emacs user I failed to adopt to it. It has very long spacebar and thereby makes it hard to use emacs' cursor movement commands. One should constantly shift from touchtyping default position ('asdf' and 'jkl;') to reach Control and Meta keys with a thumb.

From the day I failed to use Freestyle I decided to build my custom mechanical separate keyboard as some great people on Deskthority do.

Having limited access to desired components and knowing little bout how to put them all together, building custom separate mechanical keyboard still remains a dream for me.

But having no progress with this project irritated me. So I decided to hack two ordinary membrane keyboards into separate one. First design I thought of was to just to cut body of two keyboards in a half and then just to bend or roll the underlying circuit thereby freeing some space in between two parts. Next I planned to plug in both keyboards and just to start using them.

While searching for keyboards with small spacebar I studied how keyboards work. Especially how keyboard controller works with a key matrix

It's not very hard in theory, but what has totally upset me was the possibility of race conditions.

I thought that it will totally break my first design idea, cause say pressing a key on the left-hand keyboard could come after the press on a right-hand though it was hit first.

So I came to the hard decision to decipher which matrix row or column does each controller's output drive. Then I planned to solder pins of both matrices to one controller thus eliminating race conditions. It was possible, but needed a some preparation and actually paused the progress

The whole project would be on hold now If I have not came to David Kadavy's post on using split keyboard and to the comment from Ryan Buie Blakeley who said he recently started using TWO keyboards at the same time.

So my first design was actually possible!

All I had to do is to check for race conditions.

Lucky I had two rare ThinkPad Travel UltraNav Keyboards both tenkeyless and having small spacebars. So the whole setup for checking for race conditions looks like on the photo.
Using two tenkeyless keyboards as one split erogonomic keyboard

Took it in my girlfriends photo studio but retouched by myself. Don't be too harsh on me not having perfect photoshop skills :)

And you know what? I'm typing this post on this two keyboards and it feels right. No race conditions, and you get accustomed to it in a few minutes (considering you can touch type).

Another nice feature of this setup is that having touchpad and point stick on both of keyboards makes it possible to use both hands to control mouse poiter. I move it with the right touchpad while pressing left ultranav mouse key.

The next thing to try is to implement the first design by actually cutting the body of two keyboards, lucky now I have two HP keyboards with Japanese layout meaning they have really small spacebars.

For those who does not have any special requirements for keyboard layout like having small spacebar, you can try Kinesis Freestyle or any other split ergonomic keyboard (read Davids post on why one should consider trying).

Hope to try the cut-the-half design in a couple of months, so stay in touch!

Edit Somebody already implemented my design idea with cutting body and bending circuit underneath a keyboard. See the project on Instructables. That's great!

Plus from another Instructables project I've learned that Goldtouch V2 Keyboard can easily be hacked into truly separate keyboard. I like it's layout and spacebar size, so it seams soon I'm gonna buy two pieces ^) one for office and one for home.

Wednesday 11 June 2014

SQLDeveloper: Handy user report to generate column names and data types for arbitrary query

I've already covered the tough question on converting arbitrary query to clob delimited text (Take 1 and Take 2). The resulting function used a code snippet that produced a list of column names and their datatypes in it's intestines. Based on that snippet here's a SQLDeveloper user reports that produces a list of column names and their datatypes for arbitrary query. A result of a report is ready to be used in create (temporary) table statement or insert statement (for target columns) and in many other ways.
Here's the text of a report:
/* http://stackoverflow.com/questions/6544922/column-names-in-an-empty-oracle-ref-cursor */
DECLARE
  v_ref_cur SYS_REFCURSOR;
  v_cur_handle NUMBER;
  v_count NUMBER;
  v_desc_tab dbms_sql.desc_tab;
  v_statement clob := :a_statement;
  v_print_data_type pls_integer := :a_print_data_type;
  DELIMITER constant varchar2( 5 char ) := chr( 13 ) || chr( 10 ) || chr( 9 ) || ', ';
  PROCEDURE print_desc_tab( a_desc_tab IN sys.dbms_sql.desc_tab, a_print_data_type in pls_integer ) as
    v_data_type VARCHAR2(30);
    v_delimiter varchar2( 30 char ) := '';  
  BEGIN
    dbms_output.put_line( '<pre>' );
    FOR i IN 1 .. a_desc_tab.count LOOP
      SELECT DECODE( to_char( a_desc_tab( i ).col_type ), 1, 'VARCHAR2', 2, 'NUMBER', 12, 'DATE' )
      INTO v_data_type
      FROM dual
      ;
      dbms_output.put( v_delimiter || a_desc_tab( i ).col_name );
      if ( 1 = a_print_data_type ) then
        dbms_output.put( ' ' || v_data_type);  
        case a_desc_tab( i ).col_type
          when 1 then
            dbms_output.put( '(' || to_char( a_desc_tab( i ).col_max_len ) || ' char)' );  
          when 2 then
            if ( 0 != a_desc_tab( i ).col_precision ) then
              dbms_output.put( 
                '(' || to_char( a_desc_tab( i ).col_precision ) || ', ' || to_char( a_desc_tab( i ).col_scale ) || ')'  
              );  
            end if;
          else
          
            null;
        end case;
      end if;
      v_delimiter := DELIMITER;
    END LOOP;
    dbms_output.new_line;
    dbms_output.put_line( '</pre>' );
  END print_desc_tab;
  
BEGIN
  OPEN v_ref_cur FOR v_statement;

  v_cur_handle := dbms_sql.to_cursor_number( v_ref_cur );
  dbms_sql.describe_columns( v_cur_handle, v_count, v_desc_tab );
  
  print_desc_tab( v_desc_tab, v_print_data_type );
  dbms_sql.close_cursor( v_cur_handle );
END;
And here's the link for user report (hosted on Google drive). Once downloaded it can be imported into SQLDeveloper.

Wednesday 14 May 2014

Delphi: Most useful keyboard shortcuts

Here are most useful keyboard shortcuts for Delphi IDE, that I extracted from this wiki (some of these I did not know before).
ShortcutDescription
TabIn Object Inspector activates incremental search for properties. Press again Tab to move focus to property value
Ctr+EIncremental search (search is an undoable action)
Ctrl+Shift+IIndent the current selected block
Ctrl+K I
Ctrl+Shift+UUnindent the current selected block
Ctrl+K U
Alt+[Go to matching paranthesis
Alt+]
Alt+LeftBrowse backward (hotlink history)
Alt+RightBrowse forward (hotlink history)
Alt+UpBrowse to symbol under editor cursor (invoke a hotlink and add it to the hotlink history)
Ctrl+F5Add watch
Alt+GGo to line number in editor
Ctrl+SpaceInvoke code completition
Ctrl+Shift+SpaceInvoce code parameter hints
Ctrl+EnterOpen file at cursor
Ctrl+Shift+EnterFind all references
Ctrl+Shift+UpNavigate to method implementation/declaration
Ctrl+Shift+Down
Ctrl+Alt+PActivate the Tool Palette in filtering mode (start typing, press Enter to drop component)
Ctrl + /Comment line/selected block
Ctrl + Shift + TAdd TODO
F11Invoke Object Inspector window
Shift+Alt+F11Invoke Structure window
Ctrl+Alt+BInvoke Breakpoints window
By the way, I made this cool looking table with emacs Org mode ;-)