Tuesday, September 28, 2021
Drug addiction..
Hereby, we refer to any type of addiction: drugs, alcohol, smoking, fast food etc. At the low level, the root cause for addiction is fear of not getting a pleasure from the addition object. If we understand how to fight fear, we understand how to fight addiction. Finally, we need to find out that fear is unreasonable and there is nothing to afraid of.
What laptop to buy:
HP EliteBook 8460p - very reliable. I had a strong personal positive experience with it.
Sunday, September 26, 2021
Kotlin tips and tricks...
0_Unsorted_
Read more: official reference and meta programming
Optional parameters for class:
class Yuh(optionalParameter: String = "" )
If optionalParameter is not passed, it equals to "" by default.
How to pass a class as a parameter
val c = MyClass::class
goToActivity(OneMainActivity::class.java)
How to get a class of an object
var classOfMyObject = myObject!!::class.java
(yep, in Kotlin .java is to be added for some reason, at least that option works for me, even though the class of the variable is a Kotlin class not the Java one)
Ternary operator
Execution:
if(expressionAInBrackets) expressionB else expressionC
Assignment:
var v = if (a) b else c
How to iterate through the class properties
MyClass::class.memberProperties.forEach {
log("name ${it.name}: = ${it.get(objectOfMyClass)}")
}
Kotlin operators to manage nullable values and types: ?, ??, !, !!
Official Kotlin reference is here.
Safe call
Safe call on the left side of expression:
println(b?.length)
This returns b.length if b is not null, and null otherwise.
Safe call on the right side of expression:
person?.department?.head = managersPool.getManager()
If either `person` or `person.department` is null, the function is not called.
Saturday, September 25, 2021
Software design tips and tricks....
0_Unsorted_
Convert switch statements into classes.Flexibility
Goals:
- Easy to change. When change is needed, it should be done in one place instead of multiple places.
- Easy to debug. Problems should be easy to find.
- Easy to read and understand.
Solution:
- Small functions. Split big functions into multiple small functions, split big process into small steps.
- Single responsibility. Every function should do only one task.
- Prefer composition over inheritance. Credits to this stackoverflow answer.
- Loose coupling of components.
- DRY ( do not repeat yourself). When value is used multiple times, it should be assigned to a variable.
Readability
Goals:
- to make the code understandable
Solution:
- Everything from the "Flexibility" section supra.
- Prefer meaningful variable names instead of comments.
Friday, September 24, 2021
Sunday, September 19, 2021
Saturday, September 18, 2021
Friday, September 17, 2021
Thursday, September 16, 2021
Thursday, September 2, 2021
Toyota Tundra tips and tricks
0_Intro
Mostly the text below was copied and pasted from the official Toyota Manual.
Engine oil selection
Oil grade: ILSAC multigrade engine oil
Recommended viscosity: For 5.7 L V8 (3UR−FE) engine, SAE 5W−20 or 0W−20 engine oil may be used. However, SAE 0W−20 is the best choice for good fuel economy, and good starting in cold weather.
The 5.7L V8, uses 7.4 quarts of 0W20 or 5W20 oil. It is approximately 7 liter.
Resetting the engine oil maintenance data
The engine oil maintenance data must be reset after replacement of the engine oil.
Reset the data by the following procedure:
1. Turn the ignition switch to the “ACC” or “LOCK” position with the trip meter A reading shown. Mode names are shown right on the knob under the steering wheel. (For details, see “Odometer and two trip meters” on page 186 in the Manual.)
2. Turn the ignition switch to the “ON” position while holding down the trip meter reset knob. Hold down the knob for at least 5 seconds. The information display indicates “MAINT REQD RESET MODE COMPLETE”, the master warning light turns on and the tone sounds.
If the system fails to reset:
- perform the above procedure again
- make sure that starting position is "trip A", not e. g. "trip B" etc. We can switch it by single pressing the knob on the dashboard.
Oil filter type
Subscribe to:
Posts (Atom)