Recently I was talking with a friend who has a 3 year old daughter about how to best rear a child. My own son is 5.5 years old.
Whenever my son has a question with a non-trivial answer, e.g. what resources are needed to build an umbrella in the game Don't Starve, my reaction is "let's ask the internet" and I show him that most questions have an answer when you know how to look for it. I don't want to be the father who knows everything but rather who knows how to find things out.
Of course, there are much more to discovering the truth, like asking correct questions and honing his bullshit detectors, than these simple exercises. He needs to grow up a little for that.
Wednesday, May 23, 2018
Wednesday, May 09, 2018
İlginç bir ifade
Bugün bir dokümanda gördüğüm ilginç bir ifade:
...nazik yardımlarınızı rica etmekten şeref duyarız.
Friday, April 27, 2018
Transient field initialization when using GSON
When you use GSON to deserialize a JSON string in your Java code, the class has to have a non-argument constructor in order for the transient fields to be initialized properly:
The output of the above code is as follows:
The output of the above code is as follows:
ClassWithImplicitNonArgConstructor
----------------------------------
json = {"val1":500}
value1 = 500
value3 = 3
intArray = [1, 2, 3]
ClassWithOnlyArgumentConstructor
--------------------------------
json = {"val1":1}
value3 = 0
intArray = null
ClassWithExplicitNonArgConstructor
----------------------------------
json = {"val1":1}
value3 = 3
intArray = [1, 2, 3]
Thursday, March 15, 2018
Solving Processing path problem
Today I downloaded Processing 3.3.7 and when I ran processing.exe, I got the error message "Problem while trying to get the sketchbook" and nothing happened, Processing did not open.
I guess it is due to the fact that my windows documents folder is not in it's default location.
After searching the internet for half an hour, I found a solution (inspired by this and this):
I guess it is due to the fact that my windows documents folder is not in it's default location.
After searching the internet for half an hour, I found a solution (inspired by this and this):
- Locate preferences.txt. On windows 7, it is in c:\Users\<userName>\AppData\Roaming\Processing\
- Add the following line to preferences.txt: sketchbook.path.three=.
- Save preferences.txt and run processing.
Sunday, February 18, 2018
How to use engineering standards
When I mention engineering standards I either get blank stares or yawning in response. During my career spanning more than two decades, I saw that engineers usually fall between two extremes, heroic or bureaucratic:
What benefit do standards provide? They never guarantee the quality of a complex product but if applied correctly, they save the company from simple mistakes. The majority of resources are usually expended on creating the same problem and solving it again a million times. Standards also ease information exchange between engineers. When introduced to the organization for the first time, they increase short term cost but can be profitable in the long run. But never forget that "A Fool with a Tool is Still a Fool".
For high quality complex products, you need good engineers in a company that already has workflows and documentation practices in place. If your product is not complex and you don't care if your company exists for the next 5 to 10 years, you can throw away the standards and just focus on hiring good engineers.
Very few people are in the sweet spot of wise engineers who understand project needs and tailor standards accordingly. Examples of questions related to standards only wise engineers can answer:
For high quality complex products, you need good engineers in a company that already has workflows and documentation practices in place. If your product is not complex and you don't care if your company exists for the next 5 to 10 years, you can throw away the standards and just focus on hiring good engineers.
Very few people are in the sweet spot of wise engineers who understand project needs and tailor standards accordingly. Examples of questions related to standards only wise engineers can answer:
- What is the safety level of the project? This needs a good understanding of the statement of work / technical specification prepared by the customer and affects everything that follows. It might be the difference between going bankrupt and finishing the project successfully.
- Which standards and sections of standards are applicable? This also depends on the safety level.
- Which documents can be combined?
- When a project is already close to completion and due to last minute certification concerns adherence to standards have to be demonstrated to an independent assessor: Which document should be created first? This priority is very important, because most probably, you won't be able to prepare all the documents at the time the assessor shows up on your doorstep. If you have prepared the most important docs, you might gain time and sympathy instead of being labelled as clueless morons.
Tuesday, January 09, 2018
Android Studio nightmares
Today I tried to build an Android Studio that was written by someone else three years ago. After some initial progress I got stuck with Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception. After hours of struggle and fruitless trials, I finally looked at the details of the Gradle stack trace and saw that the top message was Execution failed for task :app:mergeDebugResources and the bottom message was com.android.builder.png.AaptProcess$NotifierProcessOutput.out.
My problem was due to an image file name ending with .9.png. I changed the ending to .png and the problem disappeared. Thanks Gradle for the cryptic concurrent.ExecutionException (!) This sort of unhelpful error messages is a typical theme when developing Android apps, especially when dealing with legacy code. You can get stuck for days on problems that you could not have foreseen.
My problem was due to an image file name ending with .9.png. I changed the ending to .png and the problem disappeared. Thanks Gradle for the cryptic concurrent.ExecutionException (!) This sort of unhelpful error messages is a typical theme when developing Android apps, especially when dealing with legacy code. You can get stuck for days on problems that you could not have foreseen.
Saturday, December 30, 2017
Practical application of the dot product
I recently had to write an algorithm to decide whether two trains (whose movement directions are known) are moving towards each other or not.
When two trains move towards each other the angle between their direction vectors is larger than 90 degrees. If the track was a straight line the angle would be close to 180 degrees, but tracks are not always straight.
- Calculate the dot product of the train direction vectors. This is equal to cos(angle).
- If 90 < angle <= 180 (-1 =< cos(angle) < 0), the two trains are moving towards each other
Note 1: If the track is bending more than 90 degrees, this algorithm will not work:
Subscribe to:
Posts (Atom)






