How to access module version in Crystal Lang? - crystal-lang

I see that a frequent convention is to add a file often named version.cr or named after the module it is attached to. Inside of that file, there is a definition of the module with VERSION = "[semver]". How can I access that version?

Using the namespace operator ::, this can be achieved with Module::VERSION where Module is the name of the module you're trying to access it from.

Related

Can't find FinishMonsterBuffer() method

I created a table following the flatbuffers tutorial and compiled it to C++ code. Say, its name is Doc.
In the tutorial, it is said:
Regardless of whether you used CreateMonster or MonsterBuilder, you
now have an offset to the root of your data, and you can finish the
buffer using:
FinishMonsterBuffer(fbb, mloc);
However, I can't find any method named FinishDocBuffer. The generated Doc class only has one method named Verify() in addition to getters. The generated DocBuilder class only has one method named Finish(). And there's only one function named CreateDoc() defined outside of those two classes.
Did I do something wrong, or should the official doc be updated?
FYI, I'm using latest flatbuffers code cloned from the git repo.
Update:
I found the example code didn't call any Finish*Buffer() method either.
Found the reason. I need to add this line to my doc.fbs file:
root_type Doc;

Vtiger Crm : Add new module and associate with exsiting module

I have created a new module for e.g. Resources Assigned and associated with existing module e.g Project through module designer (https://github.com/sardoj/VTModuleDesigner). Now i want to show new module 'Resources Assigned' in summary section of existing module 'Project'. I tried but is is not working properly. So what are the steps to show new added module in summary section of existing module.
you could use the related entities function on vtlib, this could work for you:
https://wiki.vtiger.com/index.php/Vtlib_Related_Entities
also you need a field to relate the two modules
if you need more help, please let me know

RequireJS: same module with different names

Is it possible to use the same module under different names in RequireJS? (Mostly interested in optimized version)
Example
I depend on an AMD-compatible library that depends on lodash. I already have underscore in my code and I want that library to use it instead of lodash.
Of course I do not want modify library's source. So I modify the require.js configuration:
paths: {
'underscore': 'vendor/underscore', // that's for my code
...
'lodash': 'vendor/underscore', // that's for the new library
}
And now when trying to build, r.js throws the unfortunate:
The following modules share the same URL.
This could be a misconfiguration if that URL only has one anonymous module in it:
/.../underscore.js: lodash, underscore
Is there a way to register the same module under 2 or more different names?
In general it is not safe to load Underscore for code that requires Lodash. The one exception is if you are 100% sure that the code in question used Lodash in its Underscore-compatible mode.
If you have determined that it is safe in your specific case, then I would handle your specific problem by using a map:
map: {
"*": { 'lodash': 'underscore'}
}
This tells RequireJS that everywhere lodash is required, give back underscore instead.
The method above returns a single module instance if lodash or underscore are required. It would not work in a case someone would want to load the same module code twice under two different names and would want to keep module state separate. For instance, a module which is meant to register names. If someone would want to load this module under names foo and bar and keep the two registries separate so that what is registered in foo is but not registered in bar is not in bar (and vice-versa) then they would need two module instances and thus would have to do something else than use map.

What do the handlers mean in django-achievements documentation?

What do the accounts.handlers and backend.handlers found in the documentation mean?
To register it into the engine just use the ‘ACHIEVEMENT_CLASSES‘ attribute in your settings like that :
#==========================================================================
# Achievements conf
#==========================================================================
ACHIEVEMENT_CLASSES = ['accounts.handlers', 'backend.handlers']
The file where the classes are defined are not important, but try to avoid conflicts of
naming by avoiding to use the name achievements.py.
The handler is the file where you write your achievement classes, like it says in the prior step, Create your first achievement.

How do I create application scope variable django?

How can I create an application scope variable which is loaded when the django app starts, be in memory and accessible by all.
Basically I want to reuse the variable through out the application without reloading it.
Thanks
You could add it to your settings.py file. Or, add it to the __init__.py file inside the app directory.
Are you referring to something like an environment variable? You could load it via init...
__init__.py
import os
os.environ['APP_VAR_WHATEVER'] = 'hello world!'
Python has three levels of namespace — local (specific to the current function or class method), global (specific to the current module), and built-in. That is, Python does not really have project-wide global variables.
If it's a read-only variable you want, you could use settings.py to define the value and import settings from all other modules that want access to the variable.
If it for both reading and writing, I would likely use the database backend I'm already using with Django, instead of a python variable.
If you could provide a more detailed description of what you're trying to achieve, perhaps we could come up with a better suited solution.