I’m really surprised to see that google drive doesn’t have a central place to display “Shared by me”. It only has “Shared with me”. Well, a lot of times I want to see what files have been shared by me and I may want to revoke them so that they don’t get viewed by unwanted personnels. No, there is no way on the UI. Lucky, Google provided a “scripting” functionality so you can write a piece of javascript to do this. I found a script from @labnol which supports 200 files only. And I modified it, for my own purpose, to support unlimited files. My script is here; open it your “google script” and run it. It will take a few minutes and send you an email. ...
Performance tuning with our server
It turns out no matter which company I join, I end up doing performance tuning work. Here’s some funny thing about what we encountered at Ariba. Memory Issue Our company is using its own ORM (Object-Rational-Mapping) technology and it seems to be a little out-dated. We were using a “framework” in our code to convert an object to another object (for the OData protocol, called OData-fication). It seems our framework is triggering a “reconstitution” of objects - which eagerly loads all the objects related to the current object being inspected. Considering the complex business logic of procurement system, usually it loads thousands of objects. This can cause a delay of a few seconds (since usually, if you get a list of objects, it will be multiplied). The solution was kind of simple, create a new Pojo and copy only the required fields of the object then pass the Pojo to the framework. ...
Reset a wrong push to gerrit
Someone did a very bad thing to our code system - merged a developing code to master branch. Luckily it is the weekend no one else is pulling the code. But to do a git hard reset on a remote gerrit is not as simple as I thought. In fact, it is not complicated either - all we need to do is to delete the master branch and recreate it with the proper commit ID. From the “branch” tab of gerrit, we should be able to do that. If the master branch doesn’t have a checkbox, we need to edit the HEAD to be pointing to another branch, then you can delete your remote master branch. Of course, we need the proper SHA1 ID to recreate the master. I didn’t check Jenkins and I hope it will be fine. ...
Some ridiculous behavior of ios and android
There a few things that are really weird and undocumented which will cost you hours to figure out. Just to list a few: on android, 9 patch pictures are often used as background. However, if you set any padding to your view (e.g., ), then your content padding of the 9 patch will not be working. on iOS, for UICollectionView, if somehow your cell view size is greater than the property cell size, then none of your views will be shown. in fact, the cellForItemAtIndexPath: is not called at all even if you returned a non-zero value for the numberOfItemsInSection: method. on iOS, if you want to align the text in a label on the top, there no easy way. however, you can achieve it by adding extra “\n” to the text, like “\n\n\n” if your label is set to 3 lines, then your text will be top aligned.
10 seconds delay in custom NSURLProtocol
My new company is using something called cordova - not a very cool one but serves the purpose. The native experience of an app cannot be matched by cordova, not to mention the heavy javascript framework we are using. One big challenge we are facing is how to debug the client-server issues. I come up with an idea of intercepting all the HTTP(s) calls by using a custom NSURLProtocol implementation such that I can print all the http request and response into log file. This sounds like a simple stupid idea but it works generally good until when we start to send POST request to server in the UIWebView. The time required to post anything to server is almost exact 10 seconds. Also, the request will be considered failing from the javascript perspective. This breaks most of our features and one of my engineer worked till 2AM then figure out my change is causing the problem and I have to back out my change. ...
Objective-C super simple notes
pointers are generally objects. NSArray* array –> then array is an object. call object’s method by square brackets: [array size] id type means “Object” in java. id a = @“string” means Object a = “string” in java. nil is similar to null in java. however, it is safe to call [nil someMethod], it will not crash, but it will return null. may result in strange behavior. NSString can be initialized using @ character, and it is in Unicode. NSString* s = @"Some string" ...
When the disk is slow...
In one of our product, we use tokyo tyrant, a variant of memcached to store data. The reason includes two folds, one is it supports persistence so that if the server dies, it can be recovered; second is it supports a master-master replication, instead of the master-slave replication of memcached. In general, it is a pretty amazon component, the performance is also superb in most cases - thousands TPS easily. By the way, on the java side, we have the Staged Event Driven Architecture which separates the read and write to the tokyo tyrant database. By nature there will be queues attached to threads that containing the data to be processed. ...
Export private key from java keystore (JKS)
I was working with one of my servers to add SSL support (PS, There is free SSL certificate being issued by CAs - and on the other hand, how dangerous the world is!). I generated the CSR using the java keytool with a JKS format. However, when I need to export the JKS file to a DER format for nginx, the keytool doesn’t have a way to export that. I have to develop something by myself and here’s the jython script. ...
In case of 40G JVM core dump
Recently we upgraded our JDK from 1.5 to 1.6 and of course we are using the latest greatest JDK from Oracle: 1.6.0 update 21. After that, some weird thing happened. One of our component which runs on Weblogic servers, crashes around twice a day, generating a 40G core dump file on the disk (which causes a disk usage problem as well!) At the first thought, it looks like there is a memory leak in our code, but wait - the maximal possible Java heap size is defined as 4G (by -Xmx), plus all other stack, JVM itself, everything together should be something around 5-6G, why we have a core dump of 40G? This has to be from some native code! ...