I gave a short presentation at Hacking in Parallel in Berlin about how to revive abandoned open-source projects.
Abstract:
Most open-source projects have limit lifetime: at some point in time development stops and the project becomes unmaintained. A lot of projects often do not even reach the stage, where they are used by a critical mass of users.
In this talk, I will go through the steps of continuing an open-source project using my lessons learned from forking Google's MyTracks and crafting it into OpenTracks.
Every 19.7 years aka every 1024 weeks the week counter in GPS transmission has an overflow.
This is how to apply a fix if the hardware did not got a software update.
/** * 1. Ancient fix for phones that do not set the time in {@link android.location.Location}. * 2. Fix for GPS time rollover happening every 19.7 years: https://en.wikipedia.org/wiki/GPS_Week_Number_Rollover */publicstaticvoidfixTime(@NonNullLocationtrackPoint){if(trackPoint.getTime()==0L){Log.w(TAG,"Time of provided location was 0. Using current time.");trackPoint.setTime(System.currentTimeMillis());return;}{longtimeDiff=Math.abs(trackPoint.getTime()-System.currentTimeMillis());if(timeDiff>1023*UnitConversions.ONE_WEEK_MS){Log.w(TAG,"GPS week rollover.");trackPoint.setTime(trackPoint.getTime()+1024*UnitConversions.ONE_WEEK_MS);}}}
Some years ago, a friend of mine showed me the Simple Sabotage Field Manual.
This document was created by the Office of Strategic Services (predecessor of the CIA) in January 1944 to prepare a successful D-Day.
It contains some really interesting recommendations how to slow down and obstruct within organisations (incl. companies), and these are really practical (and well used).
Recently, created a presentation about it (presentation):
While working on OpenTracks, I wanted to send geographical data (e.g., points as well as KML, GPX) to another installed application that could show this kind of data (e.g., OsmAnd or Maps.ME).
The main reason for this, was that I did not want this functionality in OpenTracks as it was not a core feature.
To achieve this usually, the FileProvider is used and it's usage is really simple: just get the Uri of the file to be shared and send an intent (be aware of grantUriPermission).
This is awesome as long as the file is already stored on the device - it is painless simple.
However, what happens if the data is not yet stored in the file system?
For example, the data resides in a SQLite database?
This is actually achivable using FileProvider:
1. One could store the data in a temporary file and store it somewhere (e.g., the app's cache directory).
2. Send the intent.
3. Later delete the temporary file.
This solution works quite well and is probably in use quite often.
However, it does not feel very beautiful (at least not for me).
What I actually wanted was the a ContentProvider that can share a virtual (i.e., file is created on the fly from database).
Thus, I do not need to create the temporary file and delete it later.
Luckily, this is possible and this is actually quite straight forward.
The following shows an example that is inspired by FileProvider, but the interesting part is in openFile() and how a ParcelFileDescriptor can be created without an actual file.
publicclassShareContentProviderextendsContentProviderprivatestaticfinalString[]COLUMNS={OpenableColumns.DISPLAY_NAME,OpenableColumns.SIZE};//Provide file name and size.@OverridepublicCursorquery(@NonNullUriuri,@NullableString[]projection,@NullableStringselection,@NullableString[]selectionArgs,@NullableStringsortOrder){// Inspired from FileProvider// ContentProvider has already checked granted permissionsif(projection==null){projection=COLUMNS;}String[]cols=newString[projection.length];Object[]values=newObject[projection.length];inti=0;for(Stringcol:projection){if(OpenableColumns.DISPLAY_NAME.equals(col)){cols[i]=OpenableColumns.DISPLAY_NAME;values[i++]=uri.getLastPathSegment();}elseif(OpenableColumns.SIZE.equals(col)){cols[i]=OpenableColumns.SIZE;values[i++]=-1;//Return a file size of -1}}cols=Arrays.copyOf(cols,i);values=Arrays.copyOf(values,i);finalMatrixCursorcursor=newMatrixCursor(cols,1);cursor.addRow(values);returncursor;}@Nullable@OverridepublicStringgetType(@NonNullUriuri){return"PutYourMimeTypeHere";}@Nullable@OverridepublicParcelFileDescriptoropenFile(@NonNullUriuri,@NonNullStringmode)throwsFileNotFoundException{PipeDataWriterpipeDataWriter=newPipeDataWriter<String>(){@OverridepublicvoidwriteDataToPipe(@NonNullParcelFileDescriptoroutput,@NonNullUriuri,@NonNullStringmimeType,@NullableBundleopts,@NullableStringargs){try(FileOutputStreamfileOutputStream=newFileOutputStream(output.getFileDescriptor())){//TODO: Write your actual databyte[]data=newbyte[]{255,255,255};fileOutputStream.write(data);}catch(IOExceptione){Log.w(TAG,"there occurred an error while sharing a file: "+e);}}};returnopenPipeHelper(uri,getType(uri),null,null,pipeDataWriter);}
The full code is available on Github.
In addition, please be aware to make the ShareContentProvider accessible to the calling app (i.e., grantUriPermission).
For OpenTracks, I ran, however, into another issue related to Android's security.
OpenTracks uses internally a ContentProvider that manages access to the internal SQLite database.
My initial approach was to implemented the ShareContentProvider and let it forward requests to the internal ContentProvider (i.e., two separate instances), but both belonging to OpenTracks.
In ShareContentProvider, I used getContext().getContentResolver() to access the internal ContentProvider.
This works quite well.
However, if ShareContentProvider receives a request from another app (access granted via temporary grantUriPermission), Android's security infrastructure does not allow to forward requests to the internal ContentProvider.
The reason is rather simple as the calling app only got permission for one URI managed ShareContentProvider and not for the internal ContentProvider URIs.
One (im)possible solution would be to make the internal ContentProvder to be world readable (i.e., exported="true"), but this would expose all data of your app to all other installed apps.
And this is an absolute no go!
I solved this issue by using only one ContentProvider for OpenTracks (i.e., merging ShareContentProvider and the internal ContentProvider).
The resulting ContentProvider can then use himself to acquire the necessary data for file sharing URIs.
The implementation is rather simple as ShareContentProvider inherits from the internal ContentProvider and forwards all internal requests to it's parent.
For convenience, ShareContentProvider has a static function to create a sharing URI as it later needs to parse the URI again.
OpenTracks can now share geo-data files with other map application without using temporary files.
Some years ago, I was a happy user of Google's MyTracks.
It was a great application to track your sport and outdoor activities.
The feature (I rarely used) I liked the most was that you could take pictures and these were included in the tracks.
However, in 2016 Google decided to stop working on MyTracks and also removed it from the Play Store.
Gladly, the source code of MyTracks was released as Open Source (Apache 2.0 license) and thus, theoretical, could be maintained further.
However, nothing happened so far and while looking for a new spare-time project, I decided to revamp MyTracks.
For me, it was and will be an interesting endeavour on restoring a fully matured Android application while adding/changin/removing features while keeping it maintainable.
The revamped version is now released as OpenTracks.
OpenTracks will project vision is rather simple: privacy first, features second.
Following, this vision OpenTracks will not include functionality that will require Internet access.
This also includes features like showing a recorded track on map.
Usually, downloading data from a webpage is straight forward.
Just use your favorite tool and go (such as wget or curl).
Sometimes, however, it is not that simple - especially if the webpage requires a login (this means not sending credentials as part of the URL).
The following code does a login and then downloads a webpage from such a webpage.
It uses PhantomJS.
varpage=require('webpage').create();page.onResourceReceived=function(response){// console.log('Response (#' + response.id + ', stage "' + response.stage + '"): ' + JSON.stringify(response));};//Start process: Loginpage.open('https://LOGIN-URL',function(status){if(status!=='success'){console.log('Unable to access network');phantom.exit(-1);}else{console.log(page.url);//Set handler for the follow-up of the login request.page.onLoadFinished=downloadData;page.evaluate(function(){//Set credentialsdocument.getElementById('USERNAME').value="USERNAME";document.getElementById('PASSWORD').value="PASSWORD";//Trigger login requestdocument.getElementById('Login').click();});}});functiondownloadData(status){console.log(status);console.log(page.content);page.onLoadFinished=undefined;//Download datapage.open('https://DATA-URL',function(status){console.log(page.content);phantom.exit(0);});}
German characters in ImportString[data, "RawJSON"] break during parsing.
A string containing the German character "ß" (also tested "ä") will be broken, ie., the letter as well as the following letters are not correct.
Libreboot mainly offers Grub2 as payload (at least for Lenovo X60).
That's quite nice and often sufficient as one can start Linux.
The default startup procedure of Libreboot is first start a deblobbed coreboot, which then loads Grub2.
Coreboot, Grub2, and all configuration are flashed to the bios chip.
This ROM is actually a large binary blob, which includes the Coreboot File System (CBFS).
During the boot process, coreboot loads the CBFS from the bios chip into the RAM.
So, every subsequent bootloader can access this file system to load configuration files or even load subsequent bootloaders.
On my Lenovo X60, I now wanted to have the following start procedure: coreboot -> Grub2 -> SeaBIOS.
The simplest solution would be to just add the SeaBIOS ROM to the CBFS and flash the new CBFS (e.g., here).
However, I don't like the risky procedure of flashing my hardware and potentially bricking it (Lenovo X60 with 64bit C2D are really rare).
This can be easily solved by using Grub2's capability to access harddrives.
Thus, SeaBIOS can be loaded from Grub2 (using a USB thumbdrive):
chainloader (usb0,msdos1)/bios.bin.elf
boot
This works, but as the VGA-rom is not available only debug output via serial port if configured will be shown (e.g., screen /dev/ttyUSB0 115200).
For VGA support, the SeaVGABIOS needs to be findable by SeaBIOS.
If SeaBIOS was compiled with CBFS support, it could be put into the CBFS and flash it - not an option for me.
General Features -> coreboot CBFS support: disabled
VGA ROM -> VGA Hardware Type: coreboot linear framebuffer
make
Please note that CBFS support should be disabled, because coreboot loaded a CBFS.
Thus, SeaBIOS might also use CBFS provided ROMs and also other bootloaders (such as the provided Grub2).
This works like charm: even a Windows 10 installer start loading (but is not functional).
Tiny issue as of today: the keyboard of my X60 works in Grub2, but for SeaBIOS I needed to use a external USB keyboard.
Asterisk is a powerful telephone server.
However, its configuration via extensions.conf is a little bit annoying, if you would really like to program your dialplan (e.g., if-then-else, read a file, execute some command line program, ...).
The diaplan can also be implemented using LUA: extensions.lua.
Here, is a short demo setup for a telephone conference server that is reachable via telephone number using sipgate.de and a lua-based dialplan.
The server registers at sipgate.de, who provide a telephone number for the server.
All incoming calls at the server are forward to a telephone conference room.
I used this setup from Asterisk 11 until Asterisk 13 running on a FreeBSD 10.X.
sip.conf:
1[general] 2allowguest=no 3alwaysauthreject=yes 4 5canreinvite=no 6 7disallow=allow 8allow=g711 910;SIPGATE This is the incoming uplink11register=> USERNAME:PASSWORD@sipgate.de/USERNAME1213[trunk_incoming]14type=peer15host=sipgate.de16context=trunk_incoming
NOTE: Asterisk does not reload the extensions.lua automatically even not using core reload.
After configuration changes the module must be reloaded: module reload pbxlua.so_.
NOTE: The LUA-parser in Asterisk is very nitty-gritty.
Be careful about using only spaces and align the code properly.
NOTE: The traffic is not encrypted.
Take care of it yourself by setting up a IPSec-tunnel!
Update: SVGGraphicsElement.getTransformToElement() was removed from the current draft.
In difference to pixel-based images formats, like JPEG or PNG, do SVG images allow to add animations, can be programmed and can react to user input.
If an SVG image is embedded in a webpage, such an image can be modified with JavaScript as needed.
For example change the text, color or change position of elements in the image.
In SVG elements can be positioned with by setting their a) x/y-coordinates and b) using transform.
Whereas the first just sets the coordinates relative to the current coordinate system of the object, transform modifies the coordinate system for all this object and all childs.
Both images are rendered exactly the same and from a viewer's perspective are therefore equal.
However, those are not equal from a programmatic perspective they are not.
TL;DR: When you need to re-position SVG-elements, try to avoid transform.
Here is an example with three rectangles.
id="rect1" and id="rect3" are positioned via coordinates whereas id="rect2" and id="rect2-inner" are positioned via transform(s).
Two functions are required without transform svg-object.getBBox() and with transform svg-object.getTransformToElement(svg-object).
The first, returns the minimal rectangle that contains the current object including x/y-coordinates.
The second, calculates the shift between the virtual coordinate systems due to transform.
varrect1=document.getElementById("rect1")varrect2=document.getElementById("rect2");varrect2inner=document.getElementById("rect2-inner");varrect3=document.getElementById("rect3");varrect3inner=document.getElementById("rect3-inner");rect3.getTransformToElement(rect1).e//x-shift = 0 (no transform)rect2.getTransformToElement(rect1).e//x-shift = 120 (transform)rect2inner.getTransformToElement(rect1).e//x-shift = 120 (transform)//Get x-coordinates _relative_ each coordinate system.rect1.getBBox().x//0rect2.getBBox().x//0 (moved by transform)rect2inner.getBBox().x//15 (moved by transform AND x)rect3.getBBox().x//240//Move rect3inner to center of rect1: x-only (no transform)rect3inner.setAttributeNS(null,"transform","translate("+(rect1.getBBox().x-rect3inner.getBBox().x+rect3inner.getBBox().width/2)+",0)");//Move rect2inner to center of rect3: x-only (transform)transform=rect2inner.getTransformToElement(rect3)rect2inner.setAttributeNS(null,"transform","translate("+(-transform.e+Math.abs(rect3.getBBox().x+rect2inner.getBBox().x)-rect2inner.getBBox().width/2)+",0)");
In the end both approaches work, but applying transform in addition makes moving more complicated.
And as their are nicer things to do than debugging SVGs - try to avoid transform or at least RTFM.
NOTE: For some SVGs (created with (Inkscape)[https://inkscape.org]), I had some trouble due to transform (getTransformToElement() always returned the same values although different transform were applied).
Inkscape removes transform attributes, when grouping and then ungroup elements; x/y-coordinates are re-calculated appropriately.
Laut Karte sollte der Tag eigentlich nicht so schlimm werden - ging erst nur bergab und dann nochmal fies bergauf.
Zwischendurch musste ich allerdings feststellen, dass das Winterjöchli zwar bergab geht, aber keine fahrbahre Strecke ist.
Also 1 Stunde das Rad an den Kühen vorbei getragen.
Als das vorbei war ging es runter ins Tal und wieder rauf. Diesen kleinen Berg hatte ich leider übersehen...
Knapp 2 Stunden später begann ich den Aufstieg zur Heilbronner Hütte.
Schön ist anders - mir ist nicht ganz klar, wie man diese Strecke runter fahren soll.
Und irgendwann hatte ich beschlossen bis nach Oberstdorf weiter zu fahren - es gibt nur eine Bahn nach Berlin und die geht um 9:40...
Bei der Hütte angekommen habe ich dann kurz Bescheid gesagt, dass ich nicht da bleibe sondern gleich nach Oberstdorf weitermache.
Es war ja erst 17:30 und Sonnenuntergang erst um 21:14.
Was kann da schon schief gehen. Also wieder runter ins Tal und rauf auf den Schroffenpass (Tragen) und wieder runter (Schieben).
An der ersten Hütte nach dem Pass bekam ich einen Liter frischer Milch - frisch aus der Kuh - und dann ging es mit 30+kmh runter nach Oberstdorf.
Das Ende.
Nachtrag:
Eine Übernachtung habe ich spontan gefunden (schickes Hotel und sehr netter Besitzer).
Das Bahnpersonal am kommenden Tag war auch sehr freundlich (Fahrradkarte können wir nicht mehr buchen, aber sprich mal mit dem Zugpersonal).
Und dann ging es nach Hause!
Die Tour startete mit einer ziemlichen Hochpass.
Cooles Gelände, guter Ausblick und es ging nur bergab.
Bis ins Tal war ich mit einem Heilbronner unterwegs gewesen.
Und dann begann das Schieben.
Ich habe heute das Rad so knapp 4 Stunden geschoben - erst die Straße hoch, dann einen fiesen Gebirgspass hoch und dann zum Schluss zur Hütte.
Zwischendurch war das Rad ein echt guter Wanderstock...
Am Nachmittag ging es dann durch malerische Landschaft abwärts.
Und es gab den ersten Defekt.
Zwischendurch hatte sich mein Schnellspanner am Hinterrad gelöst.
Autsch. Ist aber nichts passiert - hatte mich schon gewundert, warum die Bremse sich so komisch anfühlte.
Zum Schluß ging es dann wieder bergauf...
Hat aber alles gut geklappt.
Zwischendurch gab es noch Mittag in Form von Frischeiwaffeln und Schokomilch - vorzüglich.
Also der harte Teil der Tour ist geschafft. War aber ein echt guter Tag!
Die Tour heute habe ich auch ein wenig vereinfacht - bevor mich gleich ins Gelände zu begeben, bin ich einfach die Straße bergab gerollt und nur den Anstieg zur Hütte gemacht.
Bergauf war meine Motivation echt am Ende - ich kam nicht vom Fleck und war nur am schwitzen. Dann habe ich noch einen Mitstreiter gefunden und wir sind zusammen bis zur Hütte rauf. Zwischendurch noch Cola auf einer Alm und dann Mittag - war dann echt ein guter Tag! Mein Mitstreiter ist dann am Nachmittag noch weiter auf seiner Rundtour zurück ins Tal.
Ich bin dann noch zu Fuss ein wenig den Berg hoch und habe mir ein paar Murmeltiere angeschaut.
Nach der Abkürzung gestern habe ich gleich so weitergemacht.
Hoch auf das Stilfser Joch mit dem Rad war einfach nicht drin - also auf zum Busbahnhof und feststellen, dass es leider keinen Bus gibt.
Ich habe allerdings echt viel Glück gehabt!
Ein italienische Gruppen von Mountainbikefahrern hatte einen Bus gechartert, um einen Junggesellenabschied zu begehen - also rein in den Bus und es ging los.
Die Fahrt dauerte knapp eine Stunden und dann waren wir oben. Leider wurde eines der Fahrräder beschädigt - einige Bikes hingen hinten am Bus und bei einem hat der heiße Auspuff den hinteren Mantel angeschmolzen.
]
Oben angekommen, begann eine echt langweilige Abfahrt mit glühenden Bremsschreiben.
Einfach nur runter den Asphalt und alle paar Meter Pause machen, damit die Bremsen abkühlen.
Einen kurzen Trail habe ich dann zum Glück noch gefunden.
Dann war ich schon im Tal und im Hotel - es war kurz vor 12.
Also noch eine Stunden wandern und dann den Nachmittag einfach nur rumliegen - nur mal den Ausblick genießen.
Ich bin heute los und mir war schon klar, dass die geplante Route nicht machbar war.
Ich hätte mich einfach zwischendurch in die Gegend gelegt und wäre dann bis morgen liegen geblieben.
Hier die Stelle der Entscheidung - irgendwo 10km später fängt da richtig fieses Gelände an (bergauf).
]
Also in den sauren Apfel gebissen und Landstraße.
War trotzdem ein sehr zäher Prozess, aber mit guter Aussicht.
Und dann eine kolossale Fehlentscheidung meinerseits - statt wie geplant den ursprünglichen Pass (wie laut Tour geplant) zunehmen, habe ich gepokert und wollte den folgenden nehmen.
Naja. Auf dem Weg dahin ging es auf der Straße richtig bergab und damit hatte ich keine reale Chance mehr.
Also rein in den Bus...
Aber sind hier alle sehr hilfsbereit und Kommunikation mit Händen, Füßen und Landkarten kein Problem.
Heute ging es richtig los. Am Anfang war es nur Bundesstraßen (eher umspannenden).
Trotzdem Klasse, weil es ging nur bergauf.
Also Musik ins Ohr und los geht es.
Dann tauchte links plötzlich ein ziemlich blauer See auf und ich war bei dem strahlenden Sonnenschein fast baden - hätte nur zu lange gedauert.
Und so sieht eine ziemlich spektakuläre Straße aus (links ging es ziemlich runter).
Zwischendurch musste ich mich durch eine Rudel Bergziegen(?) schleichen und später gab es dann auch freilaufende Kühe - wie in der Werbung.
Ansonsten war der Tag echt lang.
Irgendwann war selbst der kleinste Hügel enorm und an vielen Stellen hab ich dann einfach geschoben.
Ich muss unbedingt meine Kräfte besser einteilen.
Auf jeden Fall einen Hammer Ausblick und wenn es bergab geht, ist die Welt ziemlich in Ordnung.
Geht los.
Heute schon einmal einen Bahn-Marathon erledigt - 14 Stunden sitzen, warten und umsteigen sind richtig lang.
Hat aber alles einwandfrei funktioniert.
Und zwischendurch traf ich noch zur Abwechslung den Orient-Express (im Bahnhof Innsbruck).
Der Zug ist schon ein eindrucksvolles Gefährt!
Und am Ende bin ich gut angekommen.
Allerdings ist der erste Eindruck Gardasee - Wolkenbruch.
Oder falls das geht: Wolkenbrüche.
Stand auch nicht im Wetterbericht.
Bin also auf Präzision die kommenden Tage gespannt.
Ansonsten sind die Berge schon eindrucksvoll und die Ortschaft Arco echt cool.
Ist so ein kleines italienisches Örtchen mit viel Flair.
Und gutes Essen und nette Gastgeber gibt es hier auch.
For a subjective user study on temporal effects of varying system performance, I needed to create a video with varying video encoding bandwidth, e.g. up to min 3 take 2 Mbit/s and then for 1 min 0.5 Mbit/s.
//1. (optional) Determine keyframe position using _ffprobe_ ([see](http://superuser.com/questions/554620/how-to-get-time-stamp-of-closest-keyframe-before-a-given-timestamp-with-ffmpeg)
ffprobe -select_streams v -show_frames -v quiet VIDEO | awk -F=' /pict_type=/ { if (index($2, "I")) { i=1; } else { i=0; } } /pkt_pts_time/ { if (i && ($2 >= 150)) print $2; } '| head -n 1
//2. Encode all parts of the video
ffmpeg -i VIDEO -ss 0 -to 180 -b:v 2M PART1
ffmpeg -i VIDEO -ss 180 -to 240 -b:v 1M PART2
ffmpeg -i VIDEO ...
//3. Paste all parts together (replace xx accordingly)
ffmpeg -i PART1 -i PART2 ... -i PARTxx -filter_complex '[0:0] [1:0] ... [xx:0] concat=n=xx:v=1 [v]' -map '[v]' -b:v 20M VIDEO_RECODED
//At this point the video encoding bandwidth should be rather big (here 20Mbit/s), so the introduced articifacts are encoded properly.
//4. Verify that video is frame identical
//If the cut timestamps are not correct, single frames might be dropped and thus audio and video get asynchronuous.
//For this cut one frame (best almost at the end with same motion) and save it for the original and the transcoded video.
//When comparing those they should look identical (especially viewing angle) except for additional coding artificats.
ffmpeg -ss 00:34:00 -t 1 -i VIDEO -f mjpeg VIDEO.jpg
ffmpeg -ss 00:34:00 -t 1 -i VIDEO_RECODED -f mjpeg VIDEO_RECODED.jpg
//5. (optional) Re-add the audio from original VIDEO
ffmpeg -i VIDEO_RECODED -i VIDEO -map 0:0 -map 1:1 -c:a copy -c:v copy
I needed to downgrade a package (Asterisk) on a FreeBSD 10.1.
After an update I found that my configuration had some issues.
Actually, pkg makes downgrading a package (incl. it's dependencies) a very convenient task.
Just get the YOURFAV.VERSION.xz for your desired version (take a look into /var/pkg/cache).
And then run:
pkg install YOURFAV.VERSION.xz
After downgrading everything and searching for ours I found the mistake: spelling errors in a configuration file.
Sometimes it is necessary to get access to the audio of a VoIP telephony connection (more precisely SIP/RTP).
My reason for this is quite simple: for laboratory studies on subjective quality of telephony, I need be able to introduce degradations like noise and speaker echo.
This is a short howto (for Ubuntu 14.04) to let Asterisk run in proxy mode (directmedia=no), route the audio via JACK to Puredata and back.
In Puredata then audio can be modified as needed.
Configure one extension (phone number) that:
1. answers the call
2. enables JACK for the caller to callee channel,
3. then dials the callee,
4. and on answering enables JACK for the callee to caller channel using a post dial macro.
The i(...) and o(...) tell asterisk to connect directly to the defined JACK ports - thus PD should already be running.
ATTENTION: If JACK is not running and the asterisk JACK application is thus failing to connect, it fail silently by just emitting a warning and audio is passed on directly.
4. Start JACK and Puredata
All applications connecting to a JACK server running as user X need also to run as X.
As Asterisk is running as user asterisk simply start JACK and Puredata as user asterisk.
JACK
Start JACK either directly or using qjackctl as user asterisk.
If you need realtime, enable it properly.
sudo -u asterisk "jackd --no-realtime -d dummy"
Dummy is used as backend as I do not need local sound output from JACK - if you want it use Alsa instead.
Puredata
Start Puredata as user asterisk and connect to JACK.
Puredata version before 0.46
Overwriting the HOME-variable is necessary for Puredata version less than version 0.46, which will be included in Ubuntu 15.04.
Otherwise the UI is not loaded as reading the config-files fails and the UI process stops.
During the summer I found that the JACK application of Asterisk (prior version 12; I used 11) only supported narrowband (8000Hhz).
In general is the JACK application nothing else than two buffers incl. two resamplers (to and from JACK).
For the wideband case Asterisk was downsampling to 8000Hz handing the data to the JACK application, which resampled and handed over to JACK and vice versa.
I found that three things needed to be changed:
1. Prevent Asterisk from downsampling to 8000Hz
2. Dynamic buffer sizes depending on Asterisk and JACK sampling frequency
3. Resampling parameters
After that the necessary changes were straight forward and the patch made it into Asterisk 13.
The functionality can be easily backported to Asterisk 11 by just replacing apps/app_jack.c using the one of Asterisk 13.
Just follow this procedure (on Debian/Ubuntu).
It works quite well, if you are aware that the parser is very nitpicking againt indentation: always use either spaces or tabs.
The Asterisk documentation gives a a nice overview how to use Lua.
Macros and Pre-Dial-Handler are missing there, but they are quite useful...
Here is the syntax example:
For my spare-time project TheSchreibmaschine
I need to get the position of the letter in a div that was clicked.
Limitation: it is not possible to add additional childs to the div.
1<div>This is some awesome text</div>
The solution is actually quite straight forward:
just capture the mouse event and ask the document to calculate the caret-position using the mouse coordinates.
Here is the solution I adopted:
1functioninsertBreakAtPoint(e){ 2 3varrange; 4vartextNode; 5varoffset; 6 7if(document.caretPositionFromPoint){// standard 8range=document.caretPositionFromPoint(e.pageX,e.pageY); 9textNode=range.offsetNode;10offset=range.offset;11}elseif(document.caretRangeFromPoint){// WebKit12range=document.caretRangeFromPoint(e.pageX,e.pageY);13textNode=range.startContainer;14offset=range.startOffset;15}16// do whatever you wanted here!17}
There is one limitation (at least I have a small problem in Chromium) that the range.textNode must
not necessarily identical to the one that was clicked: the contained text might be shorter than expected.
The reason for that remained unknown. I just did the access via range.textNode.parentElement.firstChild
as in my case the div only has one child, which is the text.
For further reference the stackoverflow.
Thanks to @TimDown.
Asterisk 11 and following added support for publishing/distributing the presence of an extension.
This enhances the hints, which are so faronly server-generate extension states, e.g. idle, unavailable, busy.
Actually the presence can be set for an extension independant how this extension is connected to the system.
So far the functionality was limited to exten => _X,hint,SIP/${EXTEN}, which gives you server-side generated extension states.
Now the presence state can be set for an extension using the dial plan function/variable PRESENCE_STATE().
In my case, clients are only connecting via SIP and can now subscribe for presence states of their buddies (in this case extensions).
Works like charm.
However: The presence state cannot be updated the SIP way by a SIP client for the used extension (which is denoted by a hint).
Asterisk does not SUBSCRIBE on the presence state of the client, when it registers.
Thus the client does not know that Asterisk would be interested in his presence state and therefore does not NOTIFY Asterisk, if his presence state changes.
And now Asterisk cannot inform all other clients that are subscribed on this extension...
At the moment Asterisk only allows to set the presence state it presents for an extensions using the PRESENCE_STATE() and sadly not the SIP way.
Olle E. Johansson confirmed the behavior on the Asterisk mailing list.
PJSIP contains an un-documentated feature that does volume adjustments during media-flow.
The conference bridge contains a very basic Automatic Gain Control that adjusts the volume level of each to-be-mixed signals, if the volume difference to the previous frame is to large.
It is however implement as define-directive in the C-code and thus enabled during compile time.
The investigation for this feature started as some severe "quality changes" (during a call the sound got quantizied heavily with a lower volume) unexpectetedly occured using PJSIP under perfect conditions:
Finding and disabling the AGC lead us to another issue that was masked by it.
Somehow the EchoCanceler kicks in after around 5s seconds of continuous speech and the resulting signal is sounds heavily reduced in volume (spectogram is similar to original signal).
And the AGC increases the volume again fast enough leading to "quantisation"-like sound.
So disabling the EchoCanceler (a runtime option) as well as (just to be sure) the AGC fixes the problem.
UPDATE: This patch is not required on Asterisk 11.7 upwards.
Asterisk 1.8 does not allow to loop sip calls. This is in fact the correct behavior as specified in the SIP RFC. However, in some cases this might be very well the behavior that someone wants.
What loop detection prevents is essentially that an Asterisk instance does not accept an incoming call that was triggered by himself.
This might be necessary, if the Asterisk:
Tries to call himself (I had a good reason to do this)
Asterisk tries to make a SIP call to another SIP peer, but the call is routed back to the Asterisk.
This might happen if Asterisk registers with two or more accounts at an external SIP provider and one of account tries to call the other.
How to disable loop detection
There is no default option provided to deactivate this feature (as this should only be done, if you know what you are doing).
Loop detection is done in
channel/chansip.c in function handlerequest_invite(...)
On line 22325 (Asterisk 1.8) a check is done, if loop detection should be done. You can also search for 482 Loop Detected.
If this if-statement is disabled (add 0 == 1 &&) or removed, no loop detection will be done.
Re-compile and install as I described here.
I am using Asterisk for Transcoding twice in the same instance.
Basically Asterisk fowards an incoming SIP-call to himself (setting SIPCODECOUTBOUND to whatever I needed) and then relays the call to the callee:
I just needed a new phone and decided to go for cool solution: Nokia 7110 (v4.84).
I got one including serial data cable + dock and the only thing missing was: how do I get my contacts on the phone without typing?
The answer was quite simply: export your address book as vCard and send it to the phone via gnokii on an Ubuntu.
Get your address book
Export it somehow: I tried Evolution as well as GMail web-interface (both work).
Get a serial port
Setting up the serial port on my Lenovo X60 was not straight forward, but now it works...
(Really depends on your hardware)
Connect to phone
Use minicom and check if the phone replies to AT commands
Use gnokii to read/write your address bookgnokii --deletephonebook ME 1 200gnokii --writephonebook -o --vcard > addressbook.vcf
The Nokia 7110 has a bug: the vCard-parser is broken...
So, I needed to fix my addressbook: basically remove all not needed data (emails, addresses, birthdays etc.). I implemented a small python-script using vObject.
It reads from stdin and writes to stdout:
cat addressbook.vcf | python script.py
1#!/usr/bin/python 2#encoding=UTF-8 3 4importvobject 5importsys 6importinspect 7 8#Remove entries except in list for one vcard. 9defvcard3_remove_all_entries_except(vcard):10allowedEntries={'version','fn','tel','categories'}11entries_dict=vcard.contents12forkeyinentries_dict.keys():13ifkeynotinallowedEntries:14delentries_dict[key]1516importedVCards=vobject.readComponents("".join(sys.stdin.readlines()))17try:18while(True):19vcard=importedVCards.next()20vcard3_remove_all_entries_except(vcard)21vcard.add('n');22try:23print(vcard.serialize())24exceptExceptionase:25print(e)26exceptStopIteration:27None
Transcoding MKV containers using avconv to MP4, so that the files can be processed with Adobe Premiere.
The following command copies the video stream (should already be in h264) and convert all audio streams to AAC.
All audio streams are sampled to 6 channels (even if the source is only stereo).
Hey,
first of all thanks for building openpgp.js!
Some weeks ago I started using openpgp.js and found it pretty convenient.
However, I missed one feature: the interaction with PGP-Keyserver.
Long story short: As the keyserver protocol (HKP) is basically HTTP, I created a brief implementation in Javascript:
https://gitorious.org/openhkp-js/openhkp-js
Furthermore, I setup a CORS-enabled proxy for some keyservers:
http://g00se.indus.uberspace.de/
First contribution to Asterisk (implemented together with Frank Haase):
For video calls, we would like to set the codecs in the dialplan using *SIP_CODEC. However, if SIPCODEC is set, all codecs except the ONE set are disallowed and thus either audio or video is available.Attached is a patch for 11.4 that allows SIPCODEC to contain a list of codecs , e.g. "gsm,h264".*
I find it pretty annoying to compile PJSIP on all hosts that I use by hand.
It is quite error-prone and the procedure is quite time-consuming.
So, I created the scripts to setup an Ubuntu packet (at the moment only 13.04). It is available as PPA here: https://launchpad.net/~dennis.guse/+archive/sip-tools
I have tables with one radio button per cell and its quite annoying to aim at the radio button completely...
1<tdonclick="2 for (var i in this.childNodes)3 if(typeof this.childNodes[i].click === 'function') this.childNodes[i].click();"><inputtype="radio">Just clickable text</td>
Just one or two things I need to remember about CSipSimple:
Infrastructure:
SipStack runs in background (communication via Parcable interface). It interacts with PJSIP.
Important there is a watchdog timer (about 5s)!
pjsua.java, pjsuaConstants is the SWIG generated interface to PJSIP
Native functions never return boolean, check for pjSuaConstants.PJ_SUCCESS
Be aware of string exchange with the native stack: PjSipService.pjStrToString(...)
UAStateReceiver.java does the call creation and everything related to SipStack
PjSipService.java is deeply integrated with UAStateReceiver.java (for example does recording...)
UI:
CustomDistribution.java defines some things for fast modifying the behavior
Main screen is created in SipHome.java (incl. the slidable tabs)
To remove tabs, just disable tab.add (except for the warning tab and the message tab [message disable in CustomDistribution.java]: may be triggered from outside)
Notifications are handled in SipNotifications.java (but from Sip-Thread)
DialerFragment.java is the dialer incl. call button and account switcher...
Here the re-dial functionality is missing... (press the call button twice without number should redial previous number)
InCallActivity.java :)
Important call setup is done BEFORE launching the InCallActivity via SipManager.ACTIONSIPCALLUI from UAStateReceiver.launchCallHandler(...).
There is even a activity start delay of 2000ms (UAStateReceiver.LAUNCHTRIGGER_DELAY).
I think it's not nice!!!! Because a user may hear sound of before the UI is ready, but there is might be a problem with race conditions...
InCallControls.java is the ui element on the bottom of InCallActivity to control Bluetooth and loudspeaker etc. (Deeply integrated with InCallActivity: sadly NO MVC...)
After years of using my Bluetooth mouse to control Windows Media Center (WMC) from my couch - I figured out that I needed a proper remote control (actually I visited a friend who used the IR remote of WMC). After endless time of searching I found the PS3 remote (Sony employs Bluetooth yeah) and it works with WMC using a small program that translates the game controller HID events to actual keystrokes.
It is called PS3BluMote and written by Ben Barron.
As Ben's website was not reachable, I compiled from using VS2012 - took me about 2min.
And it works perfectly - I only need to figure out good keymapping (WMC key shortcuts are available here). In fact, I recommend to use for play/pause, skip and volume control the windows events (in PS3BlueMote: Media_) and not the WMC shortcuts - in this way also VLC and other players can be controlled.
Here are some additional startup options for WMC: I created a shortcut to go to the music section directly.
Today I encountered two nasty things during Rails development. My idea was to create a generic model class (< ActiveRecord:Base) that on creation create the current timestamp.
It is not possible to override initialize (at least it is doing nothing) as it is an ActiveRecord:Base.
I found the callback after_initialize defined by ActiveRecord, which is however not the correct way anymore. You should use it in macro style (source).
The next problem is that ActiveRecord overwrites the accessors and because ruby is not using the accessors by default if you are in the object, it must be called explicitely.
This works for me:
We wrote our last project paper using Latex which creates very nice looking documents, but is absolutely painful to work in teams.
Even using a code management system like SVN/GIT won't make it really comfortable as you don't have comments and see changes of other editors live.
So, we put our Latex document in GoogleDocs (simply copied the content into a New GDocs Text Document) and shared it with our team. We also formatted the document by applying GDocs styles to our Latex headings, so the text looks structured and easier to work with.
At first we simply copied the GDocs content to a local file and compiled it. In fact, the copy-and-paste task is really annoying and so we developed a small bash script that automatically downloads the latest GDocs version and compiles it locally. So, in any case you need to setup your latex tools correctly, but don't waste your time in the compilation step.
You only need to enable sharing by URL and from this URL copy the document id, which you need to download the file.
Here is the script:
We are using Asterisk (running on FreeBSD 9.0 port stock version: 10.0.0-rc2) as SIP registrar/proxy.
We are using the Android softphone cSipSimple, which also provides SIP SIMPLE messaging functionality. To enable this on Asterisk add to sip.conf:
accept_outofcallmessage=yes and outofcall_message=message (the name of the context handler).
However, we had some trouble setting up Asterisk to really do it. In the message-ctx Asterisk provides the information of the current message as variables/function: MESSAGE(to), MESSAGE(from) and MESSAGE(body).
(First problem)
The first problem is that MESSAGE(to) contains the complete address, e.g. sip:PHONENUMBER@SERVERIP.
If you try to use this address asterisk sends the message to itself and complains on receive that their is no routing for the incoming message.
So, we need to remove the @IP part using the CUT command from the TO and the FROM.
Now we can send a message from one phone to another: MESSAGESEND(CUTEDTO, CUTEDFROM).
(Second problem)
However, we cannot reply as the recipient got as sender address something like sip:UNKNOWN@SERVERIP.
In short use MESSAGESEND(CUTEDTO, CUTEDFROM <CUTED_FROM>) or as example MESSAGESEND(sip:1, SOMEBODY <1>).
The first part of the FROM is the name shown to the user and the second part the reply to phone number (without sip:).
Here is our working context for messaging of the extensions.conf:
1[message]
2 exten => _X.,1,Set(TO=${CUT(MESSAGE(to),@,1)})
3 exten => _X.,n,Set(FROM=${CUT(MESSAGE(from),:,2)})
4 exten => _X.,n,Set(FROM_PHONE_NUMBER=${CUT(FROM,@,1)})
5 exten => _X.,n,MessageSend(${TO}, ${FROM_PHONE_NUMBER}<${FROM_PHONE_NUMBER}>)
6 ;;DEBUG Print the status of the MessageSend
7 exten => _X.,n,Verbose(0, ${TO} ${MESSAGE(from)} ${FROM} ${MESSAGE_SEND_STATUS})
Recently some of friends started to work on their theses and why reinvent a new Word Template every time?
So today, I finally found the time to strip down my master thesis word document and made it a word template.
I used and created it with Word 2010.
It has:
Automatic lists for figures, tables (use stylesheets)
Automatic table of contents (use stylesheets)
Automatic page numbering (small latin for lists and ToC; arabic for text; big latin for the appendix)
Automatic title of the current chapter on each text page.
You need:
* Something to write about
* Know how to use style sheets in word
* Somebody who reads your final text for mistakes
* and at last a covering page
Feel free to use it and don't waste your time creating yet another word thesis template.
And also feel free to modify and extend it.
I am back on working with Depth Cameras and hand gesture recognition - now we are using a Swissranger SR4000 - a TOF camera - instead a Kinect. Here is demo code to get the camera data to OpenCV as well as Point Cloud Library.
1/** 2* Demo program for the SR4k that shows the output (DepthImage and PCL) and can export these as images. 3* Use SPACE to take a picture and ESC for end. 4* @author Dennis Guse 5*/ 6 7#include<stdio.h> 8#include<iostream> 9#include<string>10#include<time.h>1112#include"opencv2/core/core.hpp"13#include"opencv2/highgui/highgui.hpp"14#include"opencv2/imgproc/imgproc.hpp"15#include"opencv2/imgproc/imgproc_c.h"1617//SR4k18#include"libMesaSR.h"19#include"definesSR.h"2021#include"pcl/point_cloud.h"22#include"pcl/point_types.h"23#include"pcl/visualization/cloud_viewer.h"2425usingnamespacecv;26usingnamespacestd;27usingnamespacepcl;2829#define SR_ROWS 17630#define SR_COLS 14431/**32 * Takes a picture with the SR4k and returns the depthimage as well as the point cloud!33 */34cv::MattakePicture(SRCAMsrCam,pcl::PointCloud<pcl::PointXYZ>::Ptrcloud){35SR_Acquire(srCam);36cv::MatdepthImage(SR_ROWS,SR_COLS,SR_CV_PIXELTYPE,(unsignedshort*)SR_GetImage(srCam,0));//0:DepthImage; 1:Amplitude; 2:ConfidenceMap3738floatx[SR_ROWS*SR_COLS];39floaty[SR_ROWS*SR_COLS];40floatz[SR_ROWS*SR_COLS];41SR_CoordTrfFlt(srCam,x,y,z,sizeof(float),sizeof(float),sizeof(float));4243for(inti=0;i<SR_ROWS*SR_COLS;i++){44point.x=x[i];45point.y=y[i];46point.z=z[i];47point->points.push_back(point);48}49returndepthImage;50}5152intmain(intargc,char**argv){53SRCAMsrCam;54SR_OpenETH(&srCam,SR_IP_ADDR);//Add error handling55SR_SetMode(srCam,AM_COR_FIX_PTRN|AM_CONV_GRAY|AM_DENOISE_ANF|AM_CONF_MAP);5657pcl::visualization::CloudViewerviewer("PCLViewer");58while(true){59pcl::PointCloud<pcl::pointxyz>::Ptrcloud(newpcl::PointCloud<pcl::pointxyz>);60cv::MatdepthImage=takePicture(srCam,cloud);61cv::imshow("Depth",depthIamge);6263viewer.showCloud(cloud,"Cloud");6465intkey=waitKey(1);66if(key==KEY_ESC)break;67if(key!=-1)saveDepthImageAndCloud(depthImage,cloud);68}69}
My old Lenovo X60 (wwan ready: antenna an sim slot available) uses the current state of the art UMTS (mini pci express) card from Ericcson. The card orignally belongs to an Lenovo W520 - FRU is 60Y3279.
!I am using the original BIOS (no zender!)
Basically:
Download drivers for the card from Lenovo
Extract drivers (the .exe complains that my X60 is not supported) using InstallShield tools
Cover pin 20 on the card with scotch tape. (Drawback: card cannot be turned off)
Plugin the card (I am using only the main antenna)
Hint:
Even with pin 20 enabled (no scotch) my notebook booted without error 180X and windows showed it in the device manager - but cannot be turned on!
Fn+F5 (Access Connection) does not show the card, but the connection can be configured.
Access Connection can turn the card off (probably via AT commands)
PIN 20: Not my image; credits go to the unknown creator (Update: Link is down.; Link removed).
Any question: Leave a comment with your mail-addr.
PS: In comparison to WiFi tethering with my Palm Pre: the card is awesome fast! (using O2 max. 3.6 Mbit/s)
If you use arrayfun on large arrays with really slow functions it is annoying to wait without feedback how long it can take - so a progressbar (in matlab waitbar) would be nice. One problem is that arrayfun provides no information about the status - there are no callback handlers.
What could be done instead.
Simply write function for arrayfun as inner function of the function which calls arrayfun. In the calling function
you define two variables, one for the number of items and one for the current solved items (starts with 0 and gets updated). In the inner function the work is done and the counter increment, which is visible in the inner function, because it is an inner function. At last update the waitbar.
Here is how it can look:
1functiondoArrayFunWithProgressBar() 2data=magic(35); 3WAITBAR=waitbar(0,'Work in progress'); 4PROGRESS_COUNTER=0; 5PROGRESS_MAX=sum(size(data)); 6 7data=arrayfun(@(item)innerFun(item),data); 8 9close(WAITBAR);1011functionresult=innerFun(item)12%TODO Do the work!13pause(1);1415PROGRESS_COUNTER=PROGRESS_COUNTER+1;16waitbar(PROGRESS_COUNTER/PROGRESS_MAX);17end18end
UPDATE: The performance penalty is massive - MATLAB fails to optimize the code if anonymous functions or function handles are used. I got factor 20... But it works ;)
Today, I needed to write a function in Matlab as accessor to a matrix. I have a matrix which contain mulitple datastreams - one per row. The columns dimension is the time
Because I don't want to change the functions, which evaluate only a subset of provided streams, and I don't want to copy and modify the matrix for every combination, I started to think about an accessor function.
Furthermore the function should reveal the dimensions of the (not existing) data matrix.
I ended up with anonymous functions, because these allow to access variables outside the anonymous function definition like:
1a=22b=23fun=@(x)(a*x+b)
The advantage is that fun can use a and b, but the caller doesn't necessarily know that they exist and are used by fun.
With this knowledge the implementation of providing the correct data was straight forward. The next problem was, that in anonymous function you can't use the if-statement. That's pretty messy.
I found a (solution)[http://www.mathworks.com/matlabcentral/newsreader/view_thread/147044] and adapted it.
1%%Artificial if for use in anonymous functions2%TRUE and FALSE are function handles.3functionRESULT=iff(CONDITION,TRUE,FALSE)4ifCONDITION5RESULT=TRUE();6else7RESULT=FALSE();8end9end
The function that creates the function handles of the accessor function:
At the weekend I found a solution to a long lasting problem of mine. I have a Apple Wireless Keyboard, because two years ago it was the best Bluetooth keyboard on the market (Currently I can't say, didn't checked again). So, I use the keyboard every day mostly for writing text ;), but the device doens't posess a DEL, POS1 and END-Key and thus it is hard to navigate during typing.
Some time ago I had a discussion about (dis-)advantages of physical against non-physical stuff. She argued that non-physical is mostly too abstract for the user and thus not that easy to use in daily life.
We argued about "real" money as physical and credit cards as non-physical example. The advantages of real money are that you see what you have and you can only spend that. The advantages of the credit card are that the payment is easier and payment via internet is possible.
The main disadvantage is that you as user can't see how much money you spend or you have available. The card looks always the same.
Assume that materials are available that could either shrink or change it's color. Using this the credit card will get smaller if you pay with it and slowly reach your limit. Or the card could get orange if are in reaching line of credit and red if your are in.
Thus you as user would "feel" how much money is available and it is much easier to cope with the abstraction from real money.
It is a quite a mess that Mojarra doesn't support h:forms that use enctyp multipart/form-data, because you can't access possible available parts in the JSF Controllers.
The following wrapper extends a HttpServletRequest so that getParameter also uses available data in HttpServletRequest.getParts().
You can than access the HttpServletRequest via
FacesContext.getCurrentInstance().getExternalContext() and use getParts own your own.
1importjava.io.BufferedReader; 2importjava.io.IOException; 3importjava.io.InputStream; 4importjava.io.InputStreamReader; 5importjava.util.HashMap; 6importjava.util.Map; 7importjava.util.logging.Level; 8importjava.util.logging.Logger; 9importjavax.servlet.ServletException;10importjavax.servlet.http.HttpServletRequest;11importjavax.servlet.http.HttpServletRequestWrapper;12importjavax.servlet.http.Part;1314/**15 * The mojarra implementation does not parse POST request that are multipart encoded, 16 * because the parameters are not accessable via <code>getParameter()</code>.17 *18 * This class extends the HttpServletRequest to provide access to the parameters19 * which are encoded accessable via <code>getParts</code>.20 *21 * All parts are made visible that have <code>contentType == null && size < 300</code>.22 *23 * If the request is not multipart encoded, the wrapper doesn't modify the behavior of the original <code>HttpServletRequest</code>.24 * @author dennis25 */26publicclassMultipartHTTPServletRequestextendsHttpServletRequestWrapper{2728protectedMap<String,String>parameterParts=newHashMap<String,String>();2930publicMultipartHTTPServletRequest(HttpServletRequestrequest){31super(request);3233if(getContentType()==null){34return;35}36if(!getContentType().toLowerCase().startsWith("multipart/")){37return;38}39try{40for(Parti:getParts()){41if(i.getContentType()==null&&i.getSize()<300){42parameterParts.put(i.getName(),getData(i.getInputStream()));43}44}45}catch(IOExceptionex){46Logger.getLogger(MultipartHTTPServletRequest.class.getName()).log(Level.SEVERE,null,ex);47}catch(ServletExceptionex){48Logger.getLogger(MultipartHTTPServletRequest.class.getName()).log(Level.SEVERE,null,ex);49}50}5152privatestaticStringgetData(InputStreaminput)throwsIOException{53Stringdata="";54Stringline="";55BufferedReaderreader=newBufferedReader(newInputStreamReader(input));56while((line=reader.readLine())!=null){57data+=line;58}59returndata;60}6162@Override63publicStringgetParameter(Stringname){64Stringresult=super.getParameter(name);65if(result==null){66returnparameterParts.get(name);67}68returnresult;69}70}
At the last friday i stood right before a tricky problem: How can I save a image provided via HTTP post into a database?
I had three problems:
How to upload a file via HTML?
How to access the data at the server side?
How to put in the database using JPA?
The first one was easy, just create a html form add a input field (type='file') and a submit button.
The second one cost me one day. And it was really simple:
Just place the @MultipartConfig annotation at the class definition of the servlet and use HTTPRequest.getPart[s]() methods to access the data as an inputstream.
The last part was straight forward: use a InputStreamReader to copy the data into a byte[] and add @Lob byte[] field to the entity class.
Because I use MySQL it was necessary to change the columnt type from TEXT to MEDIUMBLOB.
Yesterday I recreated my web app project with maven. Now CDI is available and @ConversationScoped is really nice and makes the development a lot easier.
I used Glassfish v3.
Scenario:
You have one windows 7 device with a direct internet connection like UMTS and you won't to share the connection via an ad-hoc wireless network with another device. In my case it is a XDA neo.
Everything happens in the Network and Sharing center.
Properties section of the network device with the uplink:
under sharing active ICS and re-connect the device to internet
Create a new ad-hoc network (use encryption!)
Join with another device the network
Set the wireless ad-hoc network location to Home
Disconnect from the ad-hoc network and rejoin (device with uplink)The internet sharing should now work.
Today I created a ubuntu virtual machines with ubuntu-vm-builder. When I tried to login nothing worked. I searched the web and found only the parameter --username, --password and --name. But I can't recreate two VM using an UMTS uplink :(.
I booted one machine (ubuntu jaunty VM) and used the password reset procedure to get a running root shell. In the passwd I found a user ubuntu. I rebooted and used ubuntu:ubuntu as credentials.
Default username: ubuntu
Default password: ubuntu
Thanks to NO documentation and man pages for ubuntu-vm-builder...
After long time of crawling the web, I have found a solution to use the ekiga.net SIP service from Windows. Many of my friends use skype, but it is an annoying part of software. So I started using ekiga and ekiga.net as provider.
Microsoft itselfs provides a SIP client (netmeeting). The developer of Ekiga provides a nice howto.
I had some spare time and so I started playing with DBUS. I was annoyed that after NetworkManager established a connection I always start the same programs like ekiga, pidgin, firefox and evolution. So I wrote a small python program that start software if the NetworkManager singals an open connection via DBUS. The NetworkManager DBUS-API is available. The hardest part was to find the docs.
In the last summer ('08) I had the time to read that book. A friend of mine (thanks to Thorben) suggested that the book is really worth a try. The cover says: "Tackling complexity in the Heart of Software". And that is a really summary.
Evans describes with short examples situations in software development projects which can lead to critical problems later.
He uses the short stories to analyze the situation, make the problem and cause clear.
Based upon that he describes a pattern (a style to develop software; mostly organizational stuff) to get rid of it.
The first one he suggests is a "ubiquitous language".
In short he says that all people connected to the project should use the same language, so that everyone can talk to everyone about the domain. That is not about technical stuff or infrastructure.
It is mere that all know all what the software should / will be used to.
It's a quite good book with well choosen practical examples and it helped to understand that real development differs from educational stuff in a sense of organization, time and size. It would have been helpful, if I read it earlier.
Scott McNealy the chairmen and a co-founder of SUN visited the TU Berlin on 06-11-08. He visited the university to give a short talk about open source software and why it became and will be a pushing element for technical innovations. Because he is with SUN the content of the talk was mostly about how SUN was, is and will be involved in the development of open source.
The essance of the talk was:
Open Source is good (not only code, also products and especially specifications)
reducing the dependency between the developer and the user
programmers improve their code style (someone else can read your stuff)
Strategy of SUN
He anwsered the question why SUN is doing open-source
Interesting points:
Java
happens transparently (ref: mobile phone and blue-ray players)
is running on 6^9 devices (hope I got it right)
Oracle Enterprise Edition costs 400.000 $ per core(!)
Early on the morning I read my early morning bug reports ;).
It was about an JTree on a JScrollPane. The model of the will be modified during runtime and fires events if something is changes. So far everything looks pretty straight forward and it works.
The problem occured if the tree gots larger than the parent scrollpane, so I believed the scrollpane starts to activate the scrollbars and everything stays cool... But the tree never changed it's size. It simple stayed in the old size and the scrollpane didn't start scrolling. And so some items of the tree were invisible.
The model fires an TreeModelEvent (DefaultTreeModel.nodeStructureChanged) and the tree get's an JTree.treeDidChange() so it can recompute it's size.
This doesn't work out. It was necessary to set the preferred size of the tree to null before excecuting treeDidChange...
Why? I honestly don't know...
Yesterday I got some time to start playing with SIP. I used Ekiga a SIP client for the gnome-desktop. After installation I got an account on ekiga.net and everything went fine. The provided configuration wizard is really cool stuff. The hole action consumed 10 minutes and afterwards I spent 1 hour to get the sound devices working. And it did, but it was really annoying. The only problem now is that my built-in (Thinkpad X60) microphone produces a feedback if I use the internal speakers. The only solution is to use headphones and don't type or click during a call.
At last: sip:500@ekiga.net is a echo service, so you can test your configuration. Next week I will try to get my bluetooth headset running.
Today, I tried to do something useful for my bachelor thesis. I tried to query a Oracle 11G DBMS via a SOAP-based Webservice. Using the instruction from Andrea and Oracle I got the service up and running. The Webservice was reachable under http://localhost:8080/orawsv and presented it's wsdl via http://localhost:8080/orawsv?wsdl.
Now the trouble started:
The URL from the Oracle HTTP-Server is secured via HTTP-Authentification. Ok so I downloaded the WSDL and created the stubs from a local file with the JDK's wsimport. Now I needed to tell the Webservice Client Provider to authenticate if necessary:
Exception in thread "main" java.lang.IllegalArgumentException: faultCode argument for createFault was passed NULL
at com.sun.xml.messaging.saaj.soap.ver11.SOAPFactory11Impl.createFault(SOAPFactory1_1Impl.java:56)
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:108)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:254)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:224)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:117)
at $Proxy32.xmlFromQuery(Unknown Source)
at productcatalogws.Main.main(Main.java:49)
Java Result: 1
I couldn't make anything useful out of these messages. The only thing I found was a dead end: bug_id=6587659.
So I started debugging:
First view the SOAPMessages:
I used the cool charles proxy.
The questions are:
* Does JAX-WS something wrong during the request or is the DB Webservice the bad guy?
* And why doesn't JAX-WS handle the SOAPfault correctly?
Used software: javac --version:
java version "1.6.004"
Java(TM) SE Runtime Environment (build 1.6.004-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode)
Oracle 11G DBMS: Oracle Database 11 g Release 1 for 32-bit Windows.
Today I used my spare time to let the SMTP and the IMAP server of g00se.org using the GSSAPI for authentification.
The necessary cyrus-sasl libaries were already installed. So I really don't know which are exactly required.
I suppose the cyrus-sasl gssapi libary should meet all requirements.
I needed to install the exi4-daemon-heavy instead of the light one.
The the heavy one does support authentification using the cyrus-sasl libary.
I created the principals imap/g00se.org and smtp/g00se.org and put them into the default keytab.
And modified the configuration files of both services to let them propose GSSAPI as alternate authentification mechanism:
Special thanks to the guys who invented modauthkerb. I removed the PAM authentification modules, which I only used as wrapper to get Kerberos auth through PAM and replaced it with modauthkerb.
Here is the small configuration:
The Firefox bundled into my OpenSUSE 10.3 does already contain all necessary configurations.
I only needed to add g00se.org *to *network.negotiate-auth.trusted-uris in about:config.
So he does accept the offer to do GSSAPI authentification with these URIS.
And that's pretty cool.
At least I need to figure a way to get my M$ system use such cool stuff.
Hello! Since I upgraded g00se.org from Debian Sarge to Etch the authentification mechanism of my exim mail server doesn't run properly.
I used as I descriped early the saslauthd to authentificate against the pam.
Everything went fine.
I believed, but a few weeks later (I used all the time my webinterface to send mails.) the exim couldn't use the same credentials as the imap server.
The saslauthd always claimed that my credentials are false and so exim awnsered with a SMTP Error 535: Authentification failure. Tonight I managed to look into the problem and it's source. I checked the saslauthd using testsaslauthd.
If I used: testsaslauthd -s smtp -u XXX - p XXX everything went fine and the saslauthd replied with credentials ok. But if I issued testsaslauthd -s "" -u XXX - p XXX I got a pam authentification error.
I tried the same using exim and same behavior appeared, exim doesn't set the name of the service and so all authentification will fail. The problem is that the saslauthd will try to authenticate against a pam configuration which is not available.
Note: I have in /etc/pam.d/ a file called smtp which defines the pam behavior for my smtp service ;).
As you can see the name of the service is in the first log empty.
I found a solution: you can tell the exim how to call the saslauthd.
(Snip of the authentification part of my exim service):
I started to write a login screen (NEED: two input field [username, password]and two buttons [ok, cancel]).
Since a login is a blocking panel I created a JPanel and put that on a JOptionPane.showDialog(...).
Everything looked quite fine, but the default focus was set on the OK-Button.
So I tried to requestDefaultFocus, but nothing worked. Mark provides a running solution.
Today I would like to say some words about BASE64 encoding and JAVA.
Let me introduce a cool class to encode a string: sun.misc.Base64Encoder
This class seams to work quite all right for some weeks. So, today we transfered our JEE server from a linux to windows (not my idea).
Till now I have assumed that the mythos of the JAVA plattform independence is not only a myth. During the check of the application (the deployed JEE project) it showed up error messages that the base64 coded strings doesn't match.
On the first look everything seemed to be fine. The second showed up that the strings on the windows machine were one (!) character longer.
Two hours later we found the problem: Does RFC 3548 say something about line feeds and carriage return?
So why does the base64 coded strings contain some?
The anwser is: Because the encode method of the *Base64Enconder split the string after some characters (I suppose at char 76 / 77, but I'm not quite sure).
So if you switch the operation system and the new system uses another encoding for the line break, your old base64 encoded data is worthless.
To solve this problem I used the java mail api (cause JEE server needs to implement these):
Today morning I configured heimdal KDC and as storage the openldap slapd. Slapd stores the user information and holds the kerberos authentification information.
The public URI is ldaps://g00se.org. Kerberos realm: G00SE.ORG. KDC: g00se.org The openldap server uses TLS and authenfication and authorisation with the SASL GSSAPI (package (debian): libsasl2-modules-gssapi-heimdal).
First I installed slapd (slapd and the above package).
Added the krb5-kdc.schema.
Configurated SASL support and added authorisation rules.
With slapadd -f "backup.ldif"
I installed my backup (without internal kerberos accounts).
Modified /etc/default/slapd to let the slapd listen on ldaps:// and ldapi://.
Reload the configuration.
Second I installed the heimdal-kdc. Configured the realm. Configured database backend to use the ldapi:// socket and reload it.
Init the realm and create necessary kerberos host accounts (with random keys): kadmin -l
Let nss know that there is a second source which provide authorisation data.
cat /etc/nsswitch.conf
1passwd:compat*ldap*2group:compat*ldap*
That's all! As root you can now check if everything runs: getent passwd and you will see all your local accounts and the provided central ones! I hope everything is cool!!!