Unity Tidbit: WaitUntil, WaitWhile

If you’ve been working with Unity for any sort of while you’ve probably used Coroutines before. They’re not exactly the bread and butter of using Unity but they’re like the jam or honey you put immediately after. You’ve probably used a lot of “yield return null” to wait for the next frame before resuming execution? I bet you even have used a “yield return null” loop to check a predicate every frame before continuing. I’ve done it myself. I’ve even written a repeating coroutine helper that uses null to check a predicate before running a given action. Well… stop that. Recently (and by ‘recently’, I mean at least a year) Unity now has two new conditions you can use in coroutines: WaitUntil and WaitWhile and they do exactly what you think they do. Just use any of these two instead of your usual “yield return” and put in a function (even a lambda) that returns a boolean then the coroutine will handle the checking by itself. It’ll check every frame if the predicate is fulfilled and will break if it is or isn’t, respectively. The underlying code this represents is exactly the same like you wrote yourself before but now your code can be a lot more elegant. You’re welcome.


Posted in IT, No Category, Programming and tagged , , , by with comments disabled.

Useful C# Features (or “Cool Things You Didn’t Know You Could Use in Unity”)

1. Tuples & Discards! Tuples is something more dynamic languages like JavaScript have been holding over the more static languages for a while. It allows you to do more with less action (higher level ones, that is). While tuples have existed in C# before as a class of their own, they are now getting a proper implementation. It basically makes a complex variable/object without having to predefine it using a class or a struct. You can even use it to return more than one element from a method(!!!). Unfortunately, the Unity editor doesn’t support handling those kinds of returns yet but they are still useful inside your scripts. Discards are those underscores you see in the example below. It allows you to deconstruct a tuple and discard the data you don’t want, only keeping what you actually need in its own named variable. 2. Pattern Matching! Pattern matching allows you to test a runtime type in an if or switch statement and then convert it to that specific type all in a single statement! It also increases the power of switch, allowing you to do a lot more with less and create much more complex testing blocks. 3. Local functions Local functions is currently one of my favorite features in C#. You could already create functions inside functions by assigning a block into an Action or Func variable but now you can just define an anonymous function and not worry about what returns or not returns a value or where Continue Reading →


Posted in IT, No Category, Programming by with comments disabled.

Portugal just became nicer to employees

Portugal recently passed a law they fondly call “Right to Rest”. It contains various measures to help employees have a better work-life balance such as the ability to work remotely when you need to take care of a child or companies contributing to household bills when an employee is working remotely a lot. But the nicest thing about it is indeed the ban on contacting employees after work hours. I’m guessing there is a stipulation about emergencies or people like server administrators and doctors who are supposed to be on call but the fact it’s enshrined in law is just amazing. Kinda makes me want to move to Portugal. :)


Posted in High-Tech, IT, Less Interesting News, Practice, Thinking Out Loud by with comments disabled.

Temp Logs into Documentation

Here’s an idea I had while writing a server application I needed to test on a remote computer with limited debugging abilities… I insert debug logs, temporary logs, before and/or after important sections of flow so I could see in the console what is going on and what is failing. But I wouldn’t want them there when the app rolls into production. And then I thought, people hate writing in-line documentation but it’s quite important. And here I have all these debug logs explaining what is going on. So, instead of deleting them, comment them out. Then I have them for later, if I want, and they pretty much function like in-line documentation. Win-Win!


Posted in IT, No Category, Practice, Programming, Thinking Out Loud, Work by with comments disabled.

קצת גאה בעצמי

היה לי יום טוב היום. זאת אומרת, הוא התחיל בזה שחשבתי שיש לי שעון ואז גיליתי שיש לי אבל, משום מה, הוא לא העיר אותי. אז היפלתי על מעין לטפל במוצארט בבוקר ומיהרתי החוצה. סיימתי עוד פרויקט בעבודה והראיתי אותו לבוס. קיבלתי כמה תיקונים עליהם אני עדיין עובד. בסדר. אבל אני כן גאה בזה שבשביל להשיג כל מיני אפקטים הייתי צריך להשתמש בחבילת תוכנה שכולם משתמשים בה אבל לא הצלחתי לגרום לה לעשות בדיוק מה שאני רוצה. כששאלתי, התשובה שקיבלתי היא ‘יש דרך אבל היא לא כל כך טובה אבל ככה כולם עושים’. אז לא רציתי לעשות את זה ככה. כתבתי גרסה משל עצמי. לא שכתבתי ספריה פופלארית מאפס אבל, אם היא מסוגלת לעשות א’ ועד ת’, אני צריך ח’ וחצי, אולי שני ח’. והיא לא הייתה יכולה לתת לי את זה. אז לקחתי שעה וחצי וכתבתי משהו שעושה שלושה וחצי ח’, כדי שיהיה וזה כבר היה על הדרך. וחזרתי הביתה ועשיתי התעמלות. יום בטן. לא הצלחתי להגיע לגבול הנוכחי אבל הצלחתי לסיים את הקודם בהצלחה. לפחות זה. אני כבר מרגיש יותר טוב. בהחלט יותר ערני ואנרגטי. 😉


Posted in IT, Me, No Category, Programming by with comments disabled.

עבודה חדשה

התחלתי עבודה חדשה. מדובר בחברה נחמדה בתל-אביב. בינתיים, נראה שהאנשים שם מאוד נחמדים. לקחו אותי בתור מישהו שמנוסה עם Unity בשביל לעשות קצת מחקר וניסויים ולפתח תחום שהם רוצים להיכנס אליו. אני מאוד אוהב את האווירה כי אני הראשון ויכול להגדיר את הסגנון. וגם לא מלחיצים אותי ומתייחסים מאוד טוב לזמן שלוקח לעשות דברים. וזה גם נותן לי די והותר זמן לעסוק בפרויקטים הפרטיים שלי. אז כרגע אני בעיקר מנסה להרשים אותם כמה שאני יכול בתקווה שזאת תהיה מערכת יחסים ארוכת טווח.


Posted in IT, No Category, Work by with comments disabled.

איך אפשר להתקין חלונות מחדש בקלות

לאחרונה המחשב שלי התחיל לעשות בעיות. זה התחיל עם התקנה שנדפקה ועל הדרך גם שיבשה לי את ה-Defender והמשיך לכך ש-Visual Studio ו-Unity הפסיקו לשתף פעולה. אז החלטתי להתקין מחדש. אז אני פה כדי להגיד שנכון, לכל המאוחר, לחלונות 10, להביא את המערכת למצב של כאילו כרגע הפעלת אותה בפעם הראשונה, זה ממש קל. להלן, בתמונות.


Posted in IT, Practice by with comments disabled.

The ISAs. They Are Not Here Yet.

Writing, the printing press, industrialisation, the microchip, the internet. There are several inventions that have sliced history at the point of creation, that changed the world so much that you can discuss civilisation has ‘before this’ and ‘after this’. I expect ISA, Intelligent Software Agents, to be the next one in that list. What is an ISA? For those who don’t know, an ISA is like a software butler. Not a robot you order around the house but an ethereal ghost in the machine that can follow general instructions and perform tasks for you. Basically, take a general AI and give it a couple of white gloves and a double tail jacket. And while some of you might be thinking we have Siri and S Voice, the Google Assistant and Alexa. But these are an OK start. We are not at the goal post yet. While I might be able to tell a properly equipped smart home to set my AC to certain temperature or start my coffee maker, I can’t tell a digital assistant to sort my news. This is my benchmark now. Can we have a software agent that sorts my news? What do I mean: I have a news reader on my phone that scrapes certain feeds I set it too. Sometimes I read my news while doing something else, sometimes I want to focus on that, sometimes I listen to it as I walk the dog and have distractions and sometimes I listen to it on Continue Reading →


Posted in IT, Practice, Thinking Out Loud by with 6 comments.

Fuck You, Xamarin

After messing around with tutorials and trying to put something together for about a month and finally running into huge building/libraries/references issues that I couldn’t solve for a few days, I decided to quit Xamarin development. At least, for now. Even planned as a simple 2D application, I’m willing to accept the splash screen and loading times so I can do this handily in Unity GUI. And I know it will compile very easily to Android and, slightly less easily, to iOS. It will definitely be quicker and easier to build.


Posted in IT, No Category, Programming by with comments disabled.

What happened to RSS? 

אני זוכר שבעבר, RSS היה משהו. לכל אתר שמתעדכן קבוע ומכבד את עצמו היה RSS. עדיין, לגדולים, יש אבל… זה כאילו שלאנשים פחות אכפת. אני צריך לעדכן את הרססים של IGN כל כמה חודשים. אני צריך להכריח את YouTube בשביל לקבל רסס. יש אתרים שאנשים פרטיים הקימו להם רסס לא רשמי. ויש לי רססים שלפעמים פשוט נשברים בלי הסבר. אני קצת מתגעגע לזמן בו הקמתי את הבלוג הזה. הכוונה שלי הייתה שיהיה לבן אדם אתר שבו הוא יכתוב מה שעולה לו בראש וכל מה שבה לו להגיד, הבמה הפרטית שלו, וכל מי שמעניין אותו, ירשם לרסס ויקבל עדכון כשיש במקום שנוח לו. ומשום מה, פרחו כל הרשתות החברתיות והרעיון הזה הלך לאיבוד. אני קצת חושש ממה שאולי יקרה לרסס. כי, לדעתי, זאת עדיין הדרך הכי טובה לבן אדם הקטן להתממשק עם זרנוק המידע שהוא האינטרנט.


Posted in IT, Practice, Thinking Out Loud by with 1 comment.