Skip to main content

Posts

Showing posts from 2020

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 in …

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 instructi…

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 there. My net…