Ein wenig besinnliches zu Weihnachten. Performance-Analyse auf Oracle Datenbanken. Wenn man heraus finden will welche SQLs viel Zeit verbrauchen, kann man das Query hier verwenden. Es ist ein erster Ansatz und keine absolute Lösung. Aber wenn man Probleme hat, ist es ein guter Einstieg in die Analyse.
select ROUND(disk_reads/decode(executions,0,1,executions)/300) EXTIME, SQL_TEXT
from v$sql
where disk_reads/decode(executions,0,1,executions)/300 >1
and executions>0
order by (disk_reads/decode(executions,0,1,executions)/300) DESC
Oft hilft es am Ende einfach einen Index zu setzen. Aber manchmal muss man tiefer in die Materie gehen.
We have out data seperated in chunks now. Now we have to write a script to send this data to the PHP-script or servlet to save it in a file. This is the elementary part of the the javascript-function and also the simple part. Because we append every chunk to the final file, we can’t work with asynchron requests. If you want to, you have to send also the number of the chunk, and also the final filesize to create a dummy-file and replace the part of the sent chunk. For the javascript the changes are no this big, but the server-side script become more complex.
So.. we will use the synchrone style and work with a simple for-loop to run through our array with the data chunks.
var result=null;
for(var i=0;i<chunks.length;i++){
var last=false;
if(i==(chunks.length-1)){
last=true;
}
result=uploadFileChunk(chunks,filenamePrefix+file.name,url,params,last);
}
return result;
Only the result of the request of the last chunk is returned. Because it is the chunk where the magic (copy from temp-folder to real target folder and create and save entity to database, etc) happens.
I send add a prefix to the filename to create a filename like userid+prefix+filename+fileextension (like *.part or somethin like this). So a user can upload more than one file with the same filename, without cause problems on server side.
But you should also send the original filename as something like "clearname". In this example you can add it to die params-array (params["clearname"]=file.name;) and use it as filename in the db-entity to set this name in header-data on download of this file or in lists of the uploaded files.
function uploadFileChunk(chunk,filename,url,params,lastChunk) {
var formData = new FormData();
formData.append('upfile', chunk, filename);
formData.append("filename",filename);
for(key in params){
formData.append(key,params[key]);
}
Wer einen LG M237WDP an einem PC betreiben möchte muss auf jeden Fall DVI verwenden. HDMI liefert ein extrem matschiges Bild. Bei AMD/ATI Grafikkarten sollte der alternative DVI-Betriebsmodus deaktiviert sein. V-Schärfe und H-Schärfe laufen beide auf 44, danach tauchten bei mir Ghosting-Effekte bei der Schrift auf (Expert 1 Modus im Monitor gewählt).
Farbtemperatur habe ich auch über den Catalyst angepasst, da der Monitor selbst nicht genug Einstellungen hat.
Jetzt stimmen die Farben einiger Massen und auch die Schrift ist ansatzweise scharf.
Now we have a file-object, we need to split it in small chunks to upload this chunks one by one. JavaScript have the ability to work with files. It can’t access the filesystem directly, but the open- and save-dialogs will do every thing we need. To save data for more than one session you can use the indexeddb. But here we need only open,save and drag and drop.
function createChunksOfFile(file,chunkSize){
var chunks=new Array();
var filesize=file.size;
var counter=0;
while(filesize>counter){
var chunk=file.slice(counter,(counter+chunkSize));
counter=counter+chunkSize;
chunks[chunks.length]=chunk;
}
return chunks;
}
The method is very simple. The loop runs as long as the copied size is smaller as the size of the file. With slice(from,to) you have to set the start- and the endpoint, that is read (in bytes). If the endpoint behind the real end of the file no execption is thrown and only the existing part will be copied. That makes it very easy to us. With every run of the loop we add 250000 to the copied-size till our copied-size is greater than the file-size. In ervery run of the loop we copy/slice the bytes from copied-size to copied-size + 250000 and add this slice-chunk to the output array.
Finally we get an array with alle the sliced chunks of the file in correct order.
Yes.. you can calculate the needed count of chunks and than use a for-loop and calculate the start and end for every part. Works great too… but i did it the other way.
var chunks=createChunksOfFile(file,250000);
So we have all chunks each ~250KB. 1MB should have ~4 Parts. Yes.. it’s 1024Bytes per 1KB.. but we keep it simple :-)
A simple file-upload is easy to implement. A input-tag of the "file"-type. Set "method" to "post" and let the action attribute point to the target-page. Don’t forget enctype="multipart/form-data" and every thing is finished.
This implementation is very limited and in modern Web-Apps you want to do more than simply upload files. You want to scale, rotate and process the image. You want to see the progress of the upload and upload more than one file at once in the upload-queue. A few years earlier you had to use flash.. but flash is dead. Today we use HTML5 + JavaScript. With ist you can do what ever you want to do. The File-API helps you to load local files per input or drag and drop. A web-notification informs you when the upload is finished… very helpful if it is a very large file.
This file-upload that is created in this posts is not perfect, but it works in many of my projects and scripts. The target-script can be implemented very easy in PHP or as a servlet.
For a simple test you can use this PHP-script:
PHP:
<?php
//see $_REQUEST["lastChunk"] to know if it is the last chunk-part or not
if(isset($_FILES["upfile"])){
file_put_contents($_REQUEST["filename"],file_get_contents($_FILES["upfile"]["tmp_name"]),FILE_APPEND);
}
?>
for Java you can use this (FileIOToolKit is a class of my own, it simply adds a byte[] to the end of a file or creates the file, if it doesn’t exist):
String filename = request.getParameter("filename");
for (Part part : request.getParts()) {
if (part.getName().equals("upfile")) {
byte[] out = new byte[part.getInputStream().available()];
part.getInputStream().read(out);
As you see, the files aren’t uploaded at once, but in multiple parts. So ist is very easy to track the progress of the upload.
To load a file in HTML5 is very easy. Drag and drop or the OnChange-Action of a file-input element delivers you a event, that contains a list of files.
Here is simple example to get the files from the event. The two events from the input and the one from the drag and drop are different.
var files = null; // FileList object
if(!nodragndrop){
files=evt.dataTransfer.files; //input
}
else{
files=evt.target.files; //drag and drop
}
But we don’t care about this part of loading and starts where we have the file-object. You also can create a binary-blob from an data-URL (from a canvas for example).
Ich weiß, dass der TIOBE-Index nicht immer wirklich aussagekräftig ist, aber er zeigt doch immer ganz gut Tendenzen an. Dieses Jahr ist Java eindeutig der Sieger. 6% Zuwachs im Vergleich zum Vorjahr sind schon sehr viel. Aber das führt mich wieder zu einem anderen Thema und einer Behauptung von mir. "Durch den Verlust der Desktop-GUIs wird Java keinen Schaden nehmen".
In der Zeit wo Java 6% zulegte, verlor Java auch viele Anteile im Bereich der Desktop-Anwendungen basierend auf Swing und JavaFX. Ich würde damit ist widerlegt, dass ohne den Desktopbereich, Java und die JEE-Welt Schaden nehmen würde.
Wenn man dieses Diagramm mit dem aus diesem Post über JavaFX vergleicht, sieht man dass Swing und JavaFX insgesamt einen ähnlichen Verlauf nahmen wie Java nur den letzten Aufschwung nicht mitgemacht haben. Die Stärken und Neuentwicklungen von Java liegen also wo anders und reichen insgesamt aus um Java insgesamt zu Pushen und die Verluste im Desktop-Bereich mehr als auszugleichen.
Java hat und hatte schon immer seine Stärken auf der Server-Seite und da ist wohl auch noch genug Luft nach oben. Konkurrenz gibt es mit PHP und Node.js genug und es wird wirklich spannend, ob PHP mit PHP7 wieder mal etwas zulegen kann. Von der Performance her lag Java schon immer weit vor PHP, aber jetzt sollte PHP etwas aufholen können. Es wird spannend.. auch wenn PHP sicher etwas Zeit benötigt. In der PHP-Welt werden Neuerungen irgendwie immer sehr skeptisch aufgenommen. Die Migration auf PHP7 ist meistens sehr einfach und schnell. Java lebt momentan von Microservices, Reactive-Programming und bietet auch Event-Driven Frameworks wie Vert.x als Konkurrenz zu Node.js.
Ich bin mir unsicher, ob PHP da mithalten kann. WebSockets und Server-Sent Events sind im Tomcat 8 von Haus aus dabei, während man bei PHP da noch mehr basteln muss.
Keine Ahnung ob es schon zu früh ist, aber irgendwie klingt es doch sehr danach als wäre Firefox OS gescheitert. Gefühlt war gerade in den letzten Monaten erst wieder Bewegung in den Firefox OS Markt gekommen. Die Installationszahlen meiner Apps gingen jedenfalls mal wieder nach oben und dümpelten nicht ewig lange auf einem Level herum.
Ich hatte sogar überlegt, doch noch mal die Apps dort wieder zu überarbeiten und vielleicht auch mal was neues dafür zu beginnen, auch wenn ich Projekt-technisch doch sehr ausgelastet bin. Ok Firefox OS hatte bei der Wahl eines neuen Primär-Smartphones keine Change und ich habe mich dann für ein Lumia mit Windows entschieden, aber dennoch hatte ich mal geguckt, was da so angeboten wird. Auch außerhalb des absoluten low-Price Segements und etwas mit besserer Kamera. Gab es leider nichts.
Ich finde es durch aus schade, weil es wirklich einfach war Apps dafür zu erstellen. Meistens musste man eine vorhandene HTML5-App nur um die Manifest-Datei ergänzen und schon war die App fertig. Man konnte zwischen gehostet und gepackt wählen, wobei viele Benutzer wohl gepackte Apps vorzogen, um Traffic zu sparen. Der Vorteil ist auch, sollte der Firefox Marketplace zeitnah keine Apps mehr anbieten (was wir mal für die Smartphone-Besitzer mit FFOS-Smartphone nicht hoffen wollen), kann mit wenig Code selbst noch eine alternative bauen. Etwas JavaScript und eine URL auf die gehostete Manifest-Datei und schon ist der App-Store fertig. Gepackte Apps sind ähnlich einfach zu installieren.
Zu Wünschen wäre meiner Meinung nach, dass sich das App-Format irgendwie durchsetzen kann und man auf die selbe einfache Weise HTML5-Apps für Android, Windows Phone oder iOS anbieten könnte.
Von kompletten Neuentwicklungen werde ich wohl nun absehen, aber meine alten Apps auch weiterhin pflegen. Denn Firefox OS ist ja nicht tot.. nur nicht mehr kommerziell.
Wenn man an Routen im Zend Framework 2 z.B. die Markierung der aktiven Seite im Navigationsmenü fest macht, ist es oft gut zu wissen welche Route greift. Wenn eine Markierung fehlt oder falsch gesetzt ist, kann man sich entweder durch die Routen-Definition suchen und so heraus finden in welche andere Route das Request lief oder man kann sich auch direkt ausgeben lassen welche Route gerade gewählt wurde. Für Debugging eine sehr praktische Sache.
Wenn man mit JSON arbeitet, hat man auch manchmal das Problem, das eine JSON Nachricht nicht umgewandelt werden kann oder eine Nachricht in einem kaputten Format am Client ankommt.
Dann hilft meistens ein Validator um heraus zu bekommen was an dem Format gerade nicht stimmt. Teilweise ein Komma zu wenig oder eine Klammer zu viel. Wenn man versuchen würde das in einem Texteditor oder in der einzeiligen Darstellung im Webbrowser zu finden, kann man sehr lange suchen. Bei solchen Problemen hilft diese kleine Webapplikation sehr:
Auch wenn man JSON per PHP per Hand zusammen stückelt falls man eine automatische Umwandlung verwenden kann, ist sie sehr hilfreich für schnelle Tests zwischendurch.
A few month ago, i wrote a post about the situation between JavaFX and HTML5 and their positions in the fight for the next leading GUI-technology in the Java world. I said, JavaFX is only interessting to improve existing Swing application but not the right thing for the developing new applications.
I can fully agree to this point of view. There are greater problems than the technological difficults and the few bugs and problems with the implementation of some JavaFX parts. The greatest problem is the missing support by Oracle. JavaFX for mobile devices is only supported through 3rd party solutions like RoboVM. Scene Builder is not very stable or bugfree. With only simple changes in a FXML, you can cause troubles that Scene Builder is not able to ... it crashes or only shows an empty screen.
You have to wait month for new versions or simple bugfixes.
Oracles own applications use Swing or are webbased. The change from Swing to JavaFX was often proclaimed, but never came to the surface or was visible in any other way. Swing has an extensive repository of mature and feature-rich components. It isn't easy to replace them in a short time range. A simple migration isn't that simple and would took a lot of work. You know that you can open JavaFX scenes in a SWT application. I used it, but it isn'T realy a good integration. It is only a canvas, where the JavaFX scenes is drawn on. No real interactions between the two worlds. It like the WebView in JavaFX. Yes you could write an application in HTML and JavaScript an use JavaFX as an wrapper.. but.. why? An IE11 should be a better solution than this.
The usage of Swing disappeares slowly, but there no new JavaFX applications to repalce them. There are a few JavaFX fans, but i think they only exist, because Swing is deceasing. Since i begin to programm in Java i wrote a few Swing applications and the first contact with JavaFX was more than disillusioning. Netbeans + Swing working great and every thing works very well. Scaling of the GUI works good. In JavaFX you can implement it too, but it isn't as intuitive as with Netbeans. The CSS-implementation in JavaFX is not comparable with the CSS we know from HTML.
Why JavaFX 2 wasn't accepted well? In my oppion, the reputation was bad, the support was insecure in version 1.0.
When version 2.0 arrives, most developers found a other or better solution with better support and more promising future. So the support from the developer-side was missing and without this every thing only works on a minimal level to save the resources for more promising projects.
JSF 1.x wasn'T that good, but there was no doubt, that it will be supported an new version will be developed. I think that Apache supported JSF, was a big advantage. And the newest versions are great. Maybe JavaFX can go the same way with more support.
So i support the conclusion: If oracle will invest more resources in JavaFX more developers show interest and so it could be a future with JavaFX.
I can't understand the fear that without JavaFX the JEE market could be damaged or it can lose it's impact in the developer-environment. Node.js could be a threat, more than php, but in the last years the JEE-market grow with microservices, middleware-services for android-apps, reactive-development and frameworks like node.js. REST-services, web-portale-solutions, small containers, websockets und push-services in the Tomcat servlet-container. Very nice and the movement doesn't stop till now. The big Topics of the last years.. Desktop-GUIs wasn't a topic. And with the great Java webframeworks, HTML5 and AngularJS the client-side won't be losed. JEE and Web-Clints work great together.
The lose of a few desktop application won't hurt, when you get new shiny web-application based on Java technology.
Manchmal muss man auch etwas anderes machen... auch wenn haufenweise Projekte darauf warten weiter gemacht zu werden und ich das Gefühl habe, als würde Firefox OS noch mal einen Schub bekam. Jedenfalls haben einige Apps von mir im Mozilla Marketplace einen deutlichen Zuwachs an Installationen bekommen.
Das 5 Seconds Photo Projekt braucht mal wieder etwas Zuwendung und einige Verbesserungen. Schootoi.net soll endlich mal in eine Beta-Phase gehen und auch andere Projekte wie mein neustes Projekt und der Adventskalender müssten noch mal etwas Zeit zu geteilt bekommen.
MP4toGif.com sollte mal den GIF-Render auf WebWorkers portiert werden, um da schneller zu werden.
Aber manchmal.. ja manchmal.. muss man auch mal abschalten und einfach einen Schoko-Mintu auf dem Lübecker-Weihnachtsmarkt genießen.
Das JQuery Plugin Chosen ist toll um einfach Selects um Suchen und andere Funktionen zu erweitern. Wer es zusammen mit dem Foundation CSS-Framework nutzen möchte, stößt aber erst einmal auf das Problem, dass es optisch nicht zusammen passt. Aber zum Glück hat sich jemand diesem Problem angenommen und etwas CSS geschrieben, dass eine wirklich gute Integration bietet. Damit sieht es wieder alle toll aus.
Die meisten Beispiele nutzen leider nicht die Möglichkeit Objekte in der Function zu nutzen, die außerhalb erzeugt wurden. Dabei ist das eigentlich ja das spannende daran und nur ein "Order By" ist ja in den seltensten Fällen allein was man möchte.
Also hier ein kleines Beispiel, um direkt dazu zu kommen. Man achte auf das Schlüsselwort use.
if($test!=null && $test->getId()>0){
$rset = $this->select(
function (Select $select) use ($test) {
$select->where->equalTo('test_id',$category->getId());
$select->where->lessThan('test_date','CURRENT_DATETIME');
$select->order('test_date DESC')->limit(20,0);
}
);
}
Die Klasse leitet von TableGateway ab. Deswegen $this->select().