Skip to main content

Posts

Showing posts from 2020

Diet diary

  I really like play with food. I eat a lot of stuff and try different diets. After the last one, which was supposed to make me feel great, my LDL levels went to values I didn't think were possible at all. My doctor after seeing my tests and hearing my diet story said I don't need another diet, I need medicine treatment. But if diet made my condition, diet will take me out of it. I met with dietician and got request to log everything I eat, divided in 2-3 hour slots. As a person who prefers computers to pen and paper, I tried to find app that would fill my needs. There are plenty of apps to track food, but they all seem too complicated. You need to select every ingredient of every meal, I don't need to know how many calories my food has, I need to store somewhere that between 9 and 12 I have eaten slice of bread with pesto. That's it. Completing this task in most of the apps is just not worth the effort. So I decided to make my own app. I can log whatever I want there. ...

Extract module from swift app

Can the architecture of a mobile application be transformed into a more modular one? In the backend it always pays off but does it pay off in a mobile application? Is it worth to cut functionality into independent modules if we use them in one application anyway? Does it make sense to hide them behind another layer of abstraction? Is it finally possible to do it in a convenient way that helps us instead of standing in the way? The traditional approach is to use CocoaPods. Each framework has its own repository from which we pull the sources and create a project with the pods. Everything is cool except one detail, I would like to be able to edit the sources of my modules in the place where I use them and compile them without any additional actions, i.e. from the point of view of using the code the fact that the components are in another repository is invisible. I wanted to use the Swift Package Manager and its packages. SPM is also very much like cocoapods when it comes to using componen...

Swift, architecture, asynchronousness

Asynchronous calls are one of the elements that have a strong influence on the structure of the whole application. However, they are often treated as a necessary evil or even avoided, if possible. At the same time, iOS itself and the swift language syntax provide tools to make asynchronous calls easier to use. Swift, like JavaScript asynchronous calls are based on callbacks. This means that when calling an asynchronous function, one of the arguments is another function (or code block) to be called when the asynchronous work is finished. Although the action is different from a synchronous call, the code is nevertheless similar. For example: func syncFunction() -> String { //some work here return "result" } //call sync let x = syncFunction() print(x) func asyncFunction(callback: @escaping (String) -> Void) { DispatchQueue.global().async { //some work callback("result") } } //async call asyncFunction() { res...

Repairing Foscam camera

Since one incident, I've bought cameras to observe the area around my house. One of them (the first one I bought) is produced by Foscam, model FI9900P V1. Unfortunately, my camera broke on the last day of warranty. I packed it quickly and sent it to get the warranty repair. The repair lasted over a month, but the camera didn't work anyway, was as broken as before sending it.  I decided to face the repair myself. With no experience in repairing similar things, it is really hard to find the point where to start. In my case, I've been plugging the camera and watching the wireshark network traffic to see if the camera is trying to retrieve an address from dhcp (there was not a single packet), if it will configure itself on APIPA addresses in the absence of dhcp, or if I can finally connect to it on the default ip. Nothing. The next step was to update the firmware. I contacted foscam company, described my problem and asked for help. I got a file with the firmware and ins...

Wear out or Rust out ?

“We must all either  wear out  or  Rust out , every one of us. My choice is to  wear out .” — Theodore Roosevelt. I've wanted to do this for a long time. I have watched online courses, read books, but somehow I couldn't get down to anything concrete. I had no idea, and writing another hello world is not as fun as it used to be. Fortunately, there was a problem to solve. I have a large collection of photos. It comes up to 1TB and still contains a lot of duplicates. I remove them "on the fly", which means in practice that if you remind me, I look for them and remove them until I get bored, which is quite fast. I even have an automated script in python that catalogues them and also (at least in theory) removes duplicates. But I dreamed of something else. I would like to have a program that will read all the files, count their cryptographic hashes, save them in the database, and every time a new file is added there, it will immediately check if it was not already...