Search This Blog

31 March 2018

Sentinel image capture software

I have updated the Sentinel project. It now has a Desktop application as well. You can checkout the project at GitHub:


Now you can directly download an application without the need to build the project yourself. There is a Downloads directory that has an Android application and a Desktop application for Windows, Mac OS and Linux.
As you can read in the readme of the project repository, for the Eclipse project we are not using Maven, because one of the libraries has issues resolving from Maven and instead of having some of them with Maven and that one not, we decided to go for manual dependency resolution for all of them.

(Sentinel for desktop)

The images or videos will be recorded in the current working directory of the application.

27 February 2018

Page security


Some time ago I noticed a problem with the security on some of the pages of a bank.
If we visit this address https://www.<blurred :)>.bg/bg/debitni-karti/page/10 , we see the result on image1 - green padlock and green text in the address bar of the browser, which informs us that the communication with this page is secured with an Extended Validation SSL certificate.

(image1)

If we continue browsing to the site and go to the pages for card products,  for example: https://www.<blurred :)>.bg/bg/page/3301#nasheto-predlojenie , we no longer see the green padlock and green text, but a gray padlock with a yellow triangle and exclamation mark. If we click on it we click on it it says that the connection to the page is not secure and the reason is that some of the content is not served over https - image2, image3, image4
(image2)

(image3)

 
 (image4)

If we look at the source code of the page we see that three of the images on that page are with URLs over http protocol. If we try to access these images we see that they are not available and that the server redirects us to their new location which is over https protocol. So the browser is making an unnecessary request over http just to get a response code 302 and a "Location" header with the new address of the image.
So the images have been removed from http and they are only accessible by https, but they have just forgotten to update some of the pages "src" attributes, and the browser is making an unnecessary http request.
(image5)


Needles to say I have informed the bank of their insecure pages and they have immediately solved the issue, of-course not missing to send a "Thanks" my way, which is always nice to hear.

I remember pointing out a problem with the e-commerce pages of a PC parts store, which prevented them from being loaded - the user had to manually reload the page if it was opened as a new tab. They fixed it after a week or so, but didn't even bother to say "Thank you". 

But here we see www.<blurred :)>.bg having a lightning fast reaction and this is what is expected when it comes to core business :)

17 February 2018

A * (A Star pathfinding)

    The repository contains a Java Eclipse project and Xcode iOS application project.
With the iOS application we can set the size of the maze and create it by touching on the squares to turn them from an empty walk able space into a wall square. We can set the start and end location and we can swipe on the map to scroll it in all directions if it can't fit on the screen, and we can pinch to zoom in and out in order to make the whole board visible or to make it easier to click on the board. Initially the size of the board is the number of squares that fit in the view size. We can set the number of squares we want the board to be in the "Width" and "Height" input fields and press on the "Create" button and we will get a new board with the desired number of squares.
    The Java implementation doesn't have a UI. We give it the maze in the ConstantsA class and we get the result in the console.


The start and end location are the squares with green color, the red colored squares are the walls and the yellow colored squares is the path.


Repository of the project at GitHub:

21 September 2017

Digital life

    Let’s code a little JavaScript project.
We have a world/ labyrinth / map and some creatures that roam in it. The world is described with walls and movable space. The creatures can use only the movable space to move and cannot move through the walls. The creatures have a field of vision of 1 square around them.

We will use some symbols to denote each one of the objects in our world:
    wall - *
    movable space - white space (space " ")
    creature - o

We will store the world in a two dimensional array. This way we can denote a location in the world with:
    world[x][y]

We could have used a one dimensional array. Then a location in the world would be:
    index = y * width + x
    world[index]



Here is the small repository of the project:

09 September 2017

Marvin framework on Android

    If you remember our Sentinel application, we considered using Marvin Framework for the image comparison, but it uses some Java packages that are not available on Android.
    Now we take a second look at it.
    Well it turns out that we don't want to port it, because it is using awt and that is a lot of work that we don't want to do right now.
    But here is an example of using Marvin Framework on Android. We are using the GrayScale filter. We have updated the instance variable "image" of the MarvingImage class to use a Bitmap instead of a BufferedImage:
// Image 
protected Bitmap image; 
And here is the code to apply a GrayScale filter:
1:          File fileOut = new File(getCacheDir(), "image.png");  
2:          BufferedInputStream inputStream = null;  
3:          FileOutputStream fos = null;  
4:          try {  
5:            inputStream = new BufferedInputStream(getAssets().open("ic_launcher.png"));  
6:            fos = new FileOutputStream(fileOut);  
7:            byte buffer[] = new byte[8192];  
8:            int length = 0;  
9:            while((length = inputStream.read(buffer)) > 0) {  
10:              fos.write(buffer, 0, length);  
11:            }  
12:            fos.flush();  
13:          } catch (IOException e) {  
14:            e.printStackTrace();  
15:          } finally {  
16:            if(inputStream != null) {  
17:              try {inputStream.close();} catch (IOException e) {/* do nothing */}  
18:            }  
19:            if(fos != null) {  
20:              try {fos.close();} catch (IOException e) {/* do nothing */}  
21:            }  
22:          }  
23:    
24:          String filePath = fileOut.getPath();  
25:          Log.i(TAG, "filePath=" + filePath + ", absolutePath=" + fileOut.getAbsolutePath());  
26:    
27:          //Change the ivar  
28:          // BufferedImage image  
29:          //int MarvinImage with Bitmap  
30:          Bitmap myBitmap = BitmapFactory.decodeFile(filePath);  
31:          int[] pixels = new int[myBitmap.getWidth() * myBitmap.getHeight()];  
32:          myBitmap.getPixels(pixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());  
33:          MarvinImage image = new MarvinImage(myBitmap.getWidth(), myBitmap.getHeight());  
34:          image.setIntColorArray(pixels);  
35:    
36:          GrayScale grayScale = new GrayScale();  
37:          grayScale.load();  
38:          MarvinImagePlugin imagePlugin = grayScale;  
39:          //MarvinImagePlugin imagePlugin = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.color.grayScale.jar");  
40:          imagePlugin.process(image, image);  
41:          image.update();  
42:    
43:          //implement the  
44:          // MarvinImageIO->loadImage  
45:          // MarvinImageIO->saveImage  
46:          //so that they don't rely on the javax package  
47:  //        MarvinImage image = MarvinImageIO.loadImage(filePath);  
48:  //        MarvinImagePlugin imagePlugin = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.color.grayScale.jar");  
49:  //        imagePlugin.process(image, image);  
50:  //        image.update();  
51:    
52:          int[] colorArray = image.getIntColorArray();  
53:          Bitmap bitmap = Bitmap.createBitmap(colorArray, myBitmap.getWidth(), myBitmap.getHeight(), Bitmap.Config.ARGB_8888);  
54:          mImageViewMain.setBackgroundDrawable(new BitmapDrawable(bitmap));  

Building the application


    When I am working with a technology, I am like - how other people think and say it is difficult, it is easy stuff.
    And when I look in to a new language or technology stack, I am like - oh I have all these tools and things, now I understand why someone would say it is difficult, because it is.
    And after a few days or weeks when I am over the hump, I am again to my old self - it is not difficult at all, I can't believe I considered it to be difficult, and how can anyone say it is.
Keep hustling.





07 August 2017

Shortcut application


    You have a nice website or web application that is responsive and all, but you also want presence on the Google app store. There are solutions to package your nice web content or application into an Android application, but we consider this would put you into a disadvantage. You either build a native application or just direct users to your web application that is build to run in the browser, that is were its strength is. But still you want present on the store. Well then just create an application that will redirect users to your web application in the browser of the device.
    Here is an example in the link. You could modify it by changing the icons, the application name and the URL it opens in the browser and you are good to build and upload to the store: