Protected and private methods in Rails

For models, the idea is that the public methods are the public interface of the class. Public methods are intended to be used by other objects, while protected/private methods are to be hidden from the outside. This is the same practice as in other object-oriented languages. For controllers and tests, just do as you please. … Read more

What is DOM reflow?

A reflow computes the layout of the page. A reflow on an element recomputes the dimensions and position of the element, and it also triggers further reflows on that element’s children, ancestors and elements that appear after it in the DOM. Then it calls a final repaint. Reflowing is very expensive, but unfortunately it can … Read more

Private constructor in Kotlin

You can even do something more similar to “emulating” usage of public constructor while having private constructor. class Foo private constructor(val someData: Data) { companion object { operator fun invoke(): Foo { // do stuff return Foo(someData) } } } //usage Foo() //even though it looks like constructor, it is a function call

Package protected alternative in Kotlin

Kotlin, compared to Java, seems to rely on packages model to a lesser degree (e.g. directories structure is not bound to packages). Instead, Kotlin offers internal visibility, which is designed for modular project architecture. Using it, you can encapsulate a part of your code inside a separate module. So, on top level declarations you can … Read more

How do I check if an element is really visible with JavaScript? [duplicate]

For the point 2. I see that no one has suggested to use document.elementFromPoint(x,y), to me it is the fastest way to test if an element is nested or hidden by another. You can pass the offsets of the targetted element to the function. Here’s PPK test page on elementFromPoint. From MDN’s documentation: The elementFromPoint() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)