Cleaning up, found some bits of code…

#include <stdio.h>
#include <math.h>

int main(int argc, char **argv)
{
float h;

printf( “aantal argc: %d\n” ,argc);
printf( “argv0: %s\n”, argv[0]);
printf( “argv1: %s\n”, argv[1]);

h=0x3fff;

/*
16 * 16^0
16 * 16^1
16 * 16^2
3 * 16^3
= 16656
*/

printf( “h: %f\n”, h);

h=(100.0 / h);

printf( “h: %f\n”, h);

return 0;
}

compiled and executed it:

$ ./ctest
aantal argc: 1
argv0: ./ctest
argv1: (null)
h: 16383.000000
h: 0.006104

Well that’s very exiting.

ref cursor column names

declare
 l_ref sys_refcursor;
 l_cur integer;
 l_exe integer;
 l_sql varchar2(100) := 'select * from <>';
 l_tab dbms_sql.desc_tab;
 l_cnt integer;
 l_val varchar2(4000);
 l_num number;
 l_dat date;
begin
 l_cur := dbms_sql.open_cursor;
 open l_ref for l_sql;
 dbms_sql.parse(l_cur, l_sql, dbms_sql.native);
 dbms_sql.describe_columns(l_cur,l_cnt,l_tab);
 
 for i in 1..l_cnt
 loop
 
 dbms_output.put_line(i||' '||l_tab(i).col_name||' '||l_val);
 -- dbms_output.put_line('|- type : '||l_tab(i).col_type);
 -- dbms_output.put_line('|- max_len : '||l_tab(i).col_max_len); 
 -- dbms_output.put_line('|- precision : '||l_tab(i).col_precision); 
 -- dbms_output.put_line('|- scale : '||l_tab(i).col_scale);
 -- dbms_output.put_line('|- > : '||'['|| case l_tab(i).col_type when 1 then 'varchar2('||l_tab(i).col_max_len||')' when 2 then 'number('||l_tab(i).col_precision||','||l_tab(i).col_scale||')' when 12 then 'date' end ||']');
 case l_tab(i).col_type 
 when 2 then dbms_sql.define_column(l_cur, i, l_num);
 when 12 then dbms_sql.define_column(l_cur, i, l_dat);
 else dbms_sql.define_column(l_cur, i, l_tab(i).col_name,l_tab(i).col_max_len);
 end case;

 end loop;
 
 l_exe := dbms_sql.execute(l_cur);
 
 loop
 if dbms_sql.fetch_rows(l_cur) = 0 then
 exit;
 end if; 

 for j in 1..l_cnt loop
 case l_tab(j).col_type
 when 2 then 
 dbms_sql.column_value(l_cur, j, l_num); 
 l_val := l_num;
 when 12 then 
 dbms_sql.column_value(l_cur, j, l_dat);
 l_val := to_char(l_dat,'dd-mm-yyyy hh24:mi:ss');
 else 
 dbms_sql.column_value(l_cur, j, l_val);
 end case; 
 dbms_output.put_line(rpad(l_tab(j).col_name,32)||l_val); 
 end loop;
 end loop;
 
end;

move directories

I wanted to differentiate my movies into ones playable on dlna aware devices and others. ie my avi’s and mkv’s and mp4’s are ok. but files with reside into folders named video_ts need to be excluded.

So how to mv all dir’s (in from current dir) where an avi exists into the dlna folder:

find . -iname ‘*.avi’ | cut -d ‘/’ -f2 | sort | uniq | xargs -I {} mv -i {} /mnt/usb1/dlna/

(run this command again for mkv’s and mp4’s and move the folders where a video_ts exists into non_dlna).

plug my alcatel 3g modem in an usb3 port….

Cut ‘n Paste from some forum:

In the last ‘upstream’ version of usb_modeswitch, there is an additional global option SetStorageDelay in the config file “/etc/usb_modeswitch.conf”.
You can set this to “3” or anything else, and usb_modeswitch will check if this is the minimum value and set it accordingly via the respective sysfs attribute.

oracle xml quicky

declare
c_x sys_refcursor;
l_xml_ xmltype;

begin

open c_x for select t.a,t.b,t.c
from zzz_test t;

select t.xml_
into l_xml_
from xmltable(‘/’
passing xmltype(c_x)
columns xml_ xmltype path ‘.’) t;

dbms_output.put_line(l_xml_.getclobval());

end;

<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <A>1</A>
  <B>Some text</B>
  <C>6</C>
 </ROW>
 <ROW>
  <A>7</A>
  <B>Some other text</B>
  <C>5</C>
 </ROW>
 <ROW>
  <A>8</A>
  <C>4</C>
 </ROW> 
</ROWSET>

And now for something completely different….

POSTGRESQL

Why didn’t I think off that before.

$johannes@ubuntu:~$ sudo apt-get install postgresql

$johannes@ubuntu:~$ sudo apt-get install postgresql-doc

login:

sudo -u postgres psql postgres

change password:

\password postgres

create database johannes;

create user johannes;

ctrl D

~$ psql

johannes=>

create table test (a varchar(10));
insert into test (a) values(‘b’);
commit;
\password

CTRL D …..

 

Some Oracle session information

select s.process,s.status
,s.username,s.schemaname
,s.sid,s.serial#
,to_char(s.logon_time,’dd-mm-yyyy hh24:mi’) logon_time
,substr(sq.sql_text,1,25) sql_txt
from v$session s
left outer join v$sql sq
on s.sql_id = sq.sql_id
order by 5;

And kill some session:

ALTER SYSTEM KILL SESSION ‘sid,serial#’;

chrooted sftp

chrooted sftp:

$ sudo adduser –shell /bin/false pietjepuk

password:

$ /home $ sudo chown root:pietjepuk /home/pietjepuk/
$ sudo chmod 755 /home/pietjepuk/

$ sudo vi /etc/ssh/sshd_config

comment de regel waar sftp server wordt bepaald:
#Subsystem sftp /usr/lib/openssh/sftp-server

En voeg het volgende onderaan toe:
Subsystem sftp internal-sftp
Match User pietjepuk
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTCPForwarding no

$ sudo service ssh restart

json kladblok

http://api.jquery.com/jquery.getjson/

$.getJSON( “ajax/test.json”, function( data ) {
var items = [];
$.each( data, function( key, val ) {
items.push( “

  • ” + val + “
  • ” );
    });

    $( “

      “, {
      “class”: “my-new-list”,
      html: items.join( “” )
      }).appendTo( “body” );
      });

      http://stackoverflow.com/questions/867916/creating-a-div-element-in-jquery

      jQuery(‘

      ‘, {
      id: ‘foo’,
      href: ‘http://google.com’,
      title: ‘Become a Googler’,
      rel: ‘external’,
      text: ‘Go to Google!’
      }).appendTo(‘#mySelector’);