Hyston blog
About • Archive • RSS

Shortcuts in ios 13.1

September 30, 2019

Shortcuts is nothing but a frustration to use as programmer tool. I spent two hours writing simple script:

I can write this logic in c# in two minutes. Ten or fifteen, if include creating new project, adding references for reading files and parsing json, reading stackoverflow and making coffee. May be I should have used Scriptable for this, but I was slightly affraid to write a lot of code using just two hurting fingers. And shortcuts integration with scriptable is too slow, it takes at least a couple seconds to call script and get value back. Another issue with shortcuts for me: it just never has what I really need currently. I got clever idea to set down time when i get home until 20, when i put my son to sleep. Guess what? Downtime cannot be controlled by shortcuts.
Another example: overcast have action: Smart skip to next chapter. I wanted to check current time, dumb skip to next chapter, check current time again. If difference is more than 5 minutes, go back. Sounds simple, but, as I guess, callbacks to overcast are cached within one run and every time I call get current running time, I got same result regardless moved I to next chapter or not. Today I have tried to use NFC tags: same issue, sometimes they are working, sometimes iphone shows exception. As I understood, this is 13.1 error, but still this unreliability is annoying. It's like using linux.
Conclusion: never use shortcuts for something conditional, something that use numeric variables. Best way is just quickly tweak some system settings, one or two steps, like skipping next chapter on overcast, turning do not disturb or start timer. For these problems Shortcuts are perfect. upd: at least, in one thing I was wrong: if scriptable return too slow, add Script.complete(); at the end. This makes it way faster!


Debugging in XCode

April 23, 2019

I always praised VS debugger, because it allowed move execution pointer back and forth as well as implement some code in intermediate window. I just didn't know, that xcode also allows do that. Moving execution can be done easily by dragging green line (or which color highlighted currently executed line). Actually, this is just nice frontend for lldb j.
And executing code is possible also in debugger window: lldb p. Would be nice to have separate window for that, but actually more useful would be to read about other lldb options someday.


Cascade delete nullable

April 17, 2019

On entity framework on deletion one-to-many it is possible to cascade delete entities. However, if foreignKey is nullable, this relation should be set to null, and EF does it automatically with one small catch: only if entity is in memory.
If it is doesnt loaded, then it will throw ugly error The DELETE statement conflicted with the REFERENCE constraint. To avoid that, load entity implicitly by any possible method like Include() or using Queryable.Load like that: Context.Entry(parentEntry).Collection(p => p.SubItems).Load();
here We load all SubItems, that have a foreign key to ParentEntry and, when we delete it later, all those keys sets to null automatically. More about this here


Automation ideas

February 25, 2019

When I have bought new iPhone with preinstalled ios 12 and new Shortcuts app, it was naturally for me to start automate everything, that I'm doing on a phone. But, there were not so many:
I have created morning shortcut (turn off sleep mode, show weather & todo list), and evening routine (even simpler: set do not disturb mode, open alarm app).
All automation solutions, that I see in macstories or hear in numerous podcasts did not clicked for me. But the more I'm playing with this, the more I realize, that I can do more with a phone and implement new ways of interaction. Creating new shortcuts or scripts in Scriptable or actions in Drafts is not very easy, or even possible sometimes. The hardest part is to actually find new things to automate and find what can be actually usefully, and not just produce whistles, that were made for fun and neglected on next day. I'll try to make posts time to time to describe what I'm doing and what I got from these scripts.

As quick example, I have added several actions to Drafts. Each of them consist from one step: call callback url to Things to create new todo.

Since I have added these actions, I hardly ever add new tasks directly in Things app. By and large, Drafts app become my input method in phone and I hope to write more about it later.


Blog update

February 24, 2019

I havent done anything to this blog in last year. After fixes in mar 2018 I have added ping endpoint in august (it took me almost 10 minutes, including deployment!), then I have removed file watcher in christmas, because someone from linode contacted me and kindly asked to stop using 100% of cpu all the time.
But I have big plans for this blog in this year and already started by changing way how to push new posts. Previously I have used scp to upload them to server and filewatcher catched them. After I have disabled it, I had to restart app each time, when I post something (that is twice a year). aLthough I have finally remember scp syntax, I want to have something simplier and easy to do using just phone.

Now I store all posts in github (thanks MS, they added private repositories), and add webhook to pull each time something pushed to "publish" branch. This seems not a very complex stuff, but I have added libgit2sharp to project, repository to use it, cleaned code (and posts structure - now it loads from all directories recursively, images in separate folder etc) - and all of it using 20 minutes before sleep time breaks.
I could have played zelda in that time... 😭

btw, this post I have created just to test git sync, do not read it, it is boring


← Next Previous →