Recent Entries 5
- pattern critical 112d agoWhy use Ruby's attr_accessor, attr_reader and attr_writer?Ruby has this handy and convenient way to share instance variables by using keys like ``` attr_accessor :var attr_reader :var attr_writer :var ``` Why would I choose `attr_reader` or `attr_writer` if I could simply use `attr_accessor`? Is there something like performance (which I doubt)? I guess there is a reason, otherwise they wouldn't have made such keys.
- snippet critical 112d agoHow can I check if an object has an attribute?How do I check if an object has some attribute? For example: `>>> a = SomeClass() >>> a.property Traceback (most recent call last): File "", line 1, in AttributeError: SomeClass instance has no attribute 'property' ` How do I tell if `a` has the attribute `property` before using it?
- snippet critical 112d agoHow can I check if an object has an attribute?How do I check if an object has some attribute? For example: `>>> a = SomeClass() >>> a.property Traceback (most recent call last): File "", line 1, in AttributeError: SomeClass instance has no attribute 'property' ` How do I tell if `a` has the attribute `property` before using it?
- pattern tip 124d agoPHP 8.0 Attributes: Replacing DocBlock AnnotationsPHP frameworks historically used DocBlock annotations (/** @Route('/path') */) for metadata. These are plain strings—not parsed by PHP, not type-checked, and break with minification or removal of comments.
- pattern major 124d agoSecure Cookie Attributes: httpOnly, Secure, Path, DomainCookies without proper attributes leak session tokens to JavaScript, get sent over HTTP, or are scoped too broadly, allowing subdomain or path-based attacks.