How do you structure i18n yaml files in Rails?

I’ve found that the best overall strategy is to somewhat reproduce the file structure so that given any translation, I can immediately find where it was called from. This gives me some kind of context for making the translation. The majority of application translations are found in views, so my biggest top level namespace is … Read more

Arrow Operator vs. Dot Operator [closed]

The ‘arrow’ operator is syntactic sugar. bar->member is the same as (*bar).member. One reason for the difference is maintainability. With the arrow operator distinct from the dot operator, it becomes much easier to keep track of which variables are pointers and which are not. It might be possible to always use . and have the … Read more

Where should utility functions live in Django?

Different question but same answer: My usual layout for a django site is: projects/ templates/ common/ local/ Where: projects contains your main project and any others common contains things you may share across sites, or are at least not project-specific, like if you need to download django-profile and django-registration rather than having it directly in … Read more

Can I define a function inside a C structure? [duplicate]

No, you cannot define a function within a struct in C. You can have a function pointer in a struct though but having a function pointer is very different from a member function in C++, namely there is no implicit this pointer to the containing struct instance. Contrived example (online demo http://ideone.com/kyHlQ): #include <stdio.h> #include … Read more

Struct Inheritance in C

The closest you can get is the fairly common idiom: typedef struct { // base members } Base; typedef struct { Base base; // derived members } Derived; As Derived starts with a copy of Base, you can do this: Base *b = (Base *)d; Where d is an instance of Derived. So they are … Read more

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