Searching for signal

For the last few years, one of the tool I have greatly used is a Huawei E587 modem. It’s a great little device which gave me a lot of freedom. Even if it is quite old, it outperforms, even without an external antenna any smartphone I used for tethering and especially my new Samsung Galaxy S5 Neo which, as a parenthesis, has one of the poorest software I have ever seen, reminds me of a circa 2000 windows pre-installed on a laptop and filled with junkware.

However, as many other devices, the reporting of signal strength is very simplistic. My goal was to be able to identify the best spot for the external antenna defined by the best signal strength.

(more…)

Running chrome in docker with audio

The goal is to run google-chrome in a docker container with audio support. I did this trying to get skype.apk to run in archron since skype for linux does not support conferencing anymore. Even if running skype in archron did not seemed to work chrome runs flawlessly with audio support via pulse:

So here is the Dockerfile:

FROM ubuntu:14.04
MAINTAINER len@len.ro
 
RUN apt-get update && apt-get install -y wget pulseaudio && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - && apt-get update && apt-get install -y google-chrome-stable
 
RUN rm -rf /var/cache/apt/archives/*
 
RUN useradd -m -s /bin/bash chrome
 
USER chrome
ENV PULSE_SERVER /home/chrome/pulse
ENTRYPOINT [ "google-chrome" ]

You can build your container using:

docker build -t len/chrome .

The run it using:

docker run -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -v $HOME/Downloads/chrome:/home/chrome/Downloads -v /run/user/$UID/pulse/native:/home/chrome/pulse -v /dev/shm:/dev/shm --name chrome len/chrome

 

Oracle: drop all schema contents

Purpose: drop all schema contents without dropping the user.

DECLARE
BEGIN
  FOR r1 IN ( SELECT 'DROP ' || object_type || ' ' || object_name || DECODE ( object_type, 'TABLE', ' CASCADE CONSTRAINTS PURGE' ) || DECODE ( object_type, 'TYPE', ' FORCE' ) AS v_sql
                FROM user_objects
               WHERE object_type IN ( 'TABLE', 'VIEW', 'PACKAGE', 'TYPE', 'PROCEDURE', 'FUNCTION', 'TRIGGER', 'SEQUENCE' )
               ORDER BY object_type,
                        object_name ) LOOP
    BEGIN
        EXECUTE IMMEDIATE r1.v_sql;
    EXCEPTION	
    WHEN OTHERS THEN
         DBMS_OUTPUT.PUT_LINE(SQLERRM);
	 END;
  END LOOP;
END;
/

Ensure rPi connectivity

The problem: make sure I can connect to my raspberry pi B+ even if no network is available or network change.

The idea: set a static IP.

First some information:

  • running raspbian 8.0 (cat /etc/issue)
  • there is no need for a crossover UTP cable if you connect directly to the device you can use a normal cable
  • IP configuration is delegated from /etc/network/interfaces to the dhcpcd daemon. This is why the eth0 is set on manual.

I did not wanted to crash default config. Just wanted to ensure the device will be visible. So I just added an aliased (virtual) interface with a fixed ip:

 

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
 
auto lo
iface lo inet loopback
 
iface eth0 inet manual
 
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 10.13.0.201
netmask 255.255.255.0
network 10.13.0.0
 
allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
 
allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

This is my /etc/network/interfaces. You can now use a normal UTP cable to connect directly to the PI or on the LAN by setting an IP in the same class:

ifconfig eth0 10.13.0.1 up

Please note that if you are on ubuntu and have a NetworkManager controlled interface you might need to disable auto-control by editing /etc/NetworkManager/NetworkManager.conf (see the unmanaged-devices section)

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
 
[ifupdown]
managed=false
 
[keyfile]
unmanaged-devices=mac:xx:xx:xx:xx:xx:xx

 

 

From monolithic single platform apps, to “write once, run everywhere”, (back) to … ?

‘A “line-of-business application” is one set of critical computer applications perceived as vital to running an enterprise’, as Wikipedia defines it. It might not always include cutting-edge technical innovation, but it involves a lot of functional knowledge on business processes thus becoming critical for the well-being of an enterprise and, as a result, has a very long life span.

The first application of this type I have worked on was running on Sun machines (OMG, how old I am! :). The architecture was simple, monolithical, the application ran on only one OS and connected directly to the DB. I think it is still in operation today somewhere. Trying to port it to NT at some point was more or less a disaster.

The second one I worked on had a html interface based heavily on tables and rarely js, developed using java and hibernate (very new at that point). The multi-tier architecture involved a server and a html client which ran in a browser, deployment and upgrade of the client was instant, the possibilities of connectivity were greatly improved. However, the interface was basic, standardized. It is still in operation today and due to the simple html used, we stepped in browser-hell only for a couple of times.

The third one was designed around 2005, with a Flex interface and java server-side. At this point it the code was ‘truly’ write once, run everywhere. The architecture was similar to the one in the previous case, but the interface had no limits, with a great look and everything a “native” interface could bring. It ran flawlessly on all flash supporting browsers. It took a few years to develop, it takes up to a year to implement at a client site and it will be buried much sooner than expected, by the death of the “so much hated flash” (even if some clients still run IE6).

Now I am looking for the set of technologies for the next application of this type. I will be working on with these technologies hopefully for some good years, and have hit a wall on the interface side. Instead of writing code for a “virtual machine” running on a variety of hosts (browsers) I am facing the possibility of writing a variety of code running on a variety of hosts. How is this anything else but a technological regression? I know the arguments against the “write once, run everywhere” paradigm once used by Sun for its java, but this is a damn gui, nothing else.
Yes, there are subtle bugs and security issues, but how can you compare this with the security issues involved in having n versions of the same application? With something like GWT or Vaadin, you add the huge complexity of handling all the browsers in your application. Consider the security issues involved in patching many such applications instead of a single ‘vm’. On maybe I should not even write a web based application and revert to a situation similar to the one from the first case I described, with completely different branches, for different platforms written in different languages? How can this development effort be justified? Or, in order to ensure longevity and easy development, the logical choice is to choose a single platform and develop natively for it alone?

ORA-01000: maximum open cursors exceeded

First, assume your schema is called ‘D’.

To see the cursor parameters:

SHOW parameter cursor;

See this faq for the meaning of these parameters: http://www.orafaq.com/node/758

To check the amount of “open” and “closeable” run:

SELECT a.value, s.username, s.sid
  FROM v$sesstat a, v$statname b, v$session s
  WHERE a.statistic# = b.statistic#  AND s.sid=a.sid
  AND b.name = 'opened cursors current' AND username = 'D';

To find the session which is having the largest number of cursors:

SELECT s.username, s.sid, a.value
  FROM v$sesstat a, v$statname b, v$session s
  WHERE a.statistic# = b.statistic#
  AND s.sid = a.sid
  AND b.name = 'opened cursors current'
  AND s.username = 'D'
  AND a.value = (SELECT MAX(a.value) FROM v$sesstat a, v$statname b, v$session s
  WHERE a.statistic# = b.statistic#
  AND s.sid = a.sid
  AND b.name = 'opened cursors current'
  AND s.username = 'D');

To find the sql attached to the cursors:

SELECT oc.sql_text, s.sid 
 FROM v$open_cursor oc, v$session s
 WHERE OC.sid = S.sid
 AND OC.USER_NAME ='D'
 AND s.sid=123

For nowhere land

I guess nobody is still using flex, but I still have to debug legacy code and I run into this nice compiler error:

    [mxmlc] Error: null
    [mxmlc] 
    [mxmlc] java.lang.NullPointerException
    [mxmlc] 	at flex2.compiler.util.QName.hashCode(QName.java:131)
    [mxmlc] 	at java.util.HashMap.hash(HashMap.java:366)
    [mxmlc] 	at java.util.HashMap.getEntry(HashMap.java:466)
    [mxmlc] 	at java.util.HashMap.get(HashMap.java:421)
    [mxmlc] 	at flex2.compiler.util.QNameMap.get(QNameMap.java:46)
    [mxmlc] 	at flex2.compiler.as3.reflect.Class.getVariable(Class.java:194)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.findEvents(DataBindingFirstPassEvaluator.java:702)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.findEvents(DataBindingFirstPassEvaluator.java:662)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.watchExpression(DataBindingFirstPassEvaluator.java:959)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:635)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:85)
    [mxmlc] 	at macromedia.asc.parser.QualifiedExpressionNode.evaluate(QualifiedExpressionNode.java:43)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:436)
    [mxmlc] 	at macromedia.asc.parser.GetExpressionNode.evaluate(GetExpressionNode.java:55)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:613)
    [mxmlc] 	at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExpressionNode.java:57)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:316)
    [mxmlc] 	at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:224)
    [mxmlc] 	at macromedia.asc.parser.ArgumentListNode.evaluate(ArgumentListNode.java:45)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:651)
    [mxmlc] 	at macromedia.asc.parser.SetExpressionNode.evaluate(SetExpressionNode.java:58)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:613)
    [mxmlc] 	at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExpressionNode.java:57)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:316)
    [mxmlc] 	at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:359)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:405)
    [mxmlc] 	at macromedia.asc.parser.FunctionCommonNode.evaluate(FunctionCommonNode.java:104)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:325)
    [mxmlc] 	at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefinitionNode.java:106)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
    [mxmlc] 	at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:923)
    [mxmlc] 	at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingExtension.generate(DataBindingExtension.java:87)
    [mxmlc] 	at flex2.compiler.as3.Compiler.generate(Compiler.java:696)
    [mxmlc] 	at flex2.compiler.mxml.ImplementationCompiler.generate(ImplementationCompiler.java:308)
    [mxmlc] 	at flex2.compiler.mxml.Compiler.generate(Compiler.java:159)
    [mxmlc] 	at flex2.compiler.API.generate(API.java:3514)
    [mxmlc] 	at flex2.compiler.API.generate(API.java:3477)
    [mxmlc] 	at flex2.compiler.API.batch2(API.java:416)
    [mxmlc] 	at flex2.compiler.API.batch(API.java:1117)
    [mxmlc] 	at flex2.compiler.API.compile(API.java:1290)
    [mxmlc] 	at flex2.compiler.API.compile(API.java:1210)
    [mxmlc] 	at flex2.tools.Compiler.mxmlc(Compiler.java:275)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at flex.ant.FlexTask.executeInProcess(FlexTask.java:283)
    [mxmlc] 	at flex.ant.FlexTask.execute(FlexTask.java:225)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [mxmlc] 	at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [mxmlc] 	at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.Target.execute(Target.java:435)
    [mxmlc] 	at org.apache.tools.ant.Target.performTasks(Target.java:456)
    [mxmlc] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    [mxmlc] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    [mxmlc] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [mxmlc] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    [mxmlc] 	at org.apache.tools.ant.Main.runBuild(Main.java:851)
    [mxmlc] 	at org.apache.tools.ant.Main.startAnt(Main.java:235)
    [mxmlc] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    [mxmlc] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Caused by this small modification in code:

<mx:TextInput id="motpPin"
text="{editedItem.@motpPin}"
change="{setValue(editedItem, '@motpPin' + selectedAuthNo, motpPin)}"/>
<mx:TextInput id="motpPin"
text="{editedItem.@['motpPin' + selectedAuthNo]}"
change="{setValue(editedItem, '@motpPin' + selectedAuthNo, motpPin)}"/>

Create timelapse movie from shaked photos

The problem consist of creating a timelapse made of photos which have been taken with a camera which has been removed and attached to a tripod during a few months thus creating a lot of shaking. Solution, use hugin to align photos:

#!/bin/bash
 
align_image_stack -v -a$1 -s 2 *.jpg
 
mkdir base
for i in $(find . -maxdepth 1 -name "*.tif"); do n=".$(echo $i | cut -f2 -d".").jpg"; convert $i $n && mv $n base; done
rm *.tif
cd base && mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell:autoaspect:vqscale=3 -mf type=jpeg:fps=5 mf://*.jpg -o $1.avi && cd .. && mv base/$1.avi .

 

Oracle 12c on Ubuntu 14.04 (sort of)

After Oracle 11g very good experience with installing on Ubuntu I had high hopes for 12C also. They crumbled down quite fast. This is the summary of almost 2 days lost trying to install oracle on Ubuntu with the ups and downs.

Conclusion

First the conclusion: my personal conclusion is that oracle 12c does not work, with an acceptable amount of effort, on Ubuntu 14.04. It should be possible to install it following a guide but it’s by no means comparable to an 11g install. Most of the errors are in the linking phase where you have to manually edit the makefiles to add various missing (not found in current config) libraries. Finally I managed to install oracle 12C using a docker container using this guide but this is also not without problems.
(more…)

Resize a kvm disk image

1. From the vm, stop the vm:

poweroff

2. From the host, resize the disk image:

qemu-img resize /virt/disk02.img +50G

3. From the host edit partition table

parted /virt/disk02.img
GNU Parted 2.3
Using /virt/disk02.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free                                                       
Model:  (file)
Disk /virt/disk02.img: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
        16.4kB  1049kB  1032kB           Free Space
 1      1049kB  51.5GB  51.5GB  primary  ext4         boot
        51.5GB  107GB   55.9GB           Free Space

(parted) rm 1                                                             
(parted) mkpart primary 1049kB -2G
(parted) print free                                                       
Model:  (file)
Disk /virt/disk02.img: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
        16.4kB  1049kB  1032kB           Free Space
 1      1049kB  105GB   105GB   primary  ext4
        105GB   107GB   2000MB           Free Space

Yes: rm 1, since this only deletes partion information, not data. Then you recreate partition info on top of data.

4. From the guest, restart, then:

resize2fs /dev/sda1