Skip to main content

Posts

Recent posts

Encoding multi-dimensional value into 1-D with preserving closeness

After a very long time, this will be my first post. I hope that it will not be the last, and the rest will come. For a project about taxi trajectory prediction, I have applied k-NN algorithm on coordinate sequence of taxi trips. Did I have promising results? Well, it is arguable, but I have discovered some good techniques. One of them is Z-order curve (Figure 1). Figure 1: Four levels of Z-ordering (taken from Wikipedia  page) I was looking for a technique to decrease dimensionality of 2-D coordinate representation (lat-lon) into 1-D . But on this 1-D value, I would like to apply k-NN algorithm. For this purpose, 1-D values must preserve the closeness of two different coordinates. If I do linear ordering of latitude and longitude values, I couldn't achieve this goal, because closeness will depend on only one value which is placed on the right-most. Let's assume I do linear ordering as lat-lon:

[Kernel] What if Initialization Function Fails

Currently, I am working on a school project about kernel programming. To enhance my knowledge about kernel programming, I am reading the book named 'Linux Kernel Programming'[1]. Thanks to its authors, it is a great book. The first thing I have realized is that kernel programming has different characteristics from user-space programming. One of them is the following one: "You must also consider what happens if your initialization function decides to fail, but some part of the kernel is already making use of a facility your module has registered. If this situation is possible for your module, you should seriously consider not failing the initialization at all. After all, the module has clearly succeeded in exporting something useful. If initialization must fail, it must carefully step around any possible operations going on elsewhere in the kernel until those operations have completed."[2] This is written about module-loading races. It sounds so interesting to

Pinpic : a new mobile app

I am happy to announce that I have published a new application on Google Play, named as Pinpic. It is under photography category. It is a very useful and user-friendly application to specialize photos by pinning anything on them. What it does may seem quite common but in practice it has new and unique features. What are they? Well. Pinpic enables users to write on pictures as many as they want with different properties. Their style(e.g. italic, bold, text color, alignment etc) are easily configurable. It not only has great fonts for latin alphabet but also supports Cyrillic, Hangul, Katakana and Hiragana with many fonts. What if I want to use my own drawings on a photo? Pinpic is here for you. You can draw any thing as many as you want. By resizing, changing thickness and color of lines, drawing style; you can make your drawings more enthusiastic. This feature is just on the way. Wait, there is more. Motifs are great arts to pin on your photos. They will definitely create so cool

[Android] How to fill outside of drawing with Paint

Android provides many drawing actions via paint. It has several features which provide great flexibility. I have needed a feature nowadays, such that a user can draw shapes or lines. At the end of the job, a user should be able to change color of outside part of drawing. Figure 1 : Example output For this picture, the drawing is obvious, its color is black. Filled place is the whole view that contains the drawing but the shape itself and its inside. The code below will result this functionality when used in onDraw() method:

Xposed - How to hook a method with primitive-type parameter

Xposed Framework is a great tool to take actions which Android SDK doesn't provide for developers. One of the great hacks that you can do is hooking a method. You can see parameters given to a method, with many other properties of it. There are some tutorials on Internet, but in this tutorials, they show hooking method without parameters or with class parameters. Its code is: findAndHookMethod("com.android.settings.Settings", lpparam.classLoader, "updateHeaderList", List.class, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { //your code } });

Get metadata from pdf via Mupdf library in Android

In this link , one of my previous posts, I have explained how to add mupdf library as a module into an Android Studio project. You can either start with this guide or directly continue to this post. The target file to edit is  mupdf.c . This file contains ndk functions in order to be called from java part. We will just add a ndk function to fetch metadata of a pdf file. Because mupdf library has a functionality to provide it, we don't need any further coding.