I'm working on proyect with Nodejs. I work with .env file and I came up with a question.
I guees that I can't do this.
My .env file
#time in seconds
TOKEN_TIME_LIVE=(60*10)
How to operate on an .env file? Through what method can I do?
Sorry the ignorance and thanks for the help.
In .env file you can't use mathematical operations and can only store constant values and if you want to change it dynamically than you can change it in your project file by using any user defined function or any other method you can use to change the value of the constant by accessing the variable using process.env.TOKEN_TIME_LIVE.
I'm sure it would help solve your question, In case I'm wrong any where please correct me and clear my misconception.
Related
I'm trying to make a node application that uploads .schem files but I don't know how to use the fs import to read the file without modifying it. When I try to read and write the file again the data gets modified and world edit in minecraft can't read it.
Can someone please help me with this?
As you can see here the .schem files are saved using NBT, and its structure.
the nbt format is using binary format (comparing to json that you can read and modify easily). so you probably want to use an existing library, i have never programed in node.js but i found this, if it helps
I've been working in Netbeans for about 6 months now, everything was working fine.... this morning however, I started a new project and for some reason there is no way to make cross-file autocomplete work.
I defined some global variables in one .JS file, some functions as well.
In another .JS file I try to reference the global or to call a functions, auto complete does not work. Heck I write the function down completely and properly and when I ctrl + click it, it will not take me to the declaration.
Both files are in the same project, both are linked to my Index.html.
I tried deleting the cache, didn't work.
I opened older projects (ones I worked on last week) and both the global variables and the functions that are written cross-files are visible....
Any clue what to do?
EDIT: Apparently there is issues with file names. If the name of the file is "config", "config2", "aaaaaconfig" the Navigator does not recognize anything in it as declared content... if I name the exact same file "blabla" it starts working... rename it to "config" again and it stops again...
Okay so after dangling with this for a long time, I've figured it out.... apparently the .js file must NOT have "config" in it's name. Putting it as answer so that others might find it. It is possible that this issue comes with any language, which is why most PHP coders have issues.... BDConfig is a pretty standard name for a PHP file for DB connections.
I am trying to set up a key system in the application I'm building. I have a code that has this logic:
$('.key-test-button').on('click', function(){
if ($('.key-test-input').val() === "MYKEYHERE"){
$('#hidden-div-instructor').show();
}
});
And My Idea was to replace "MYKEYHERE" for a hidden value on my code that I would store as a environment variable. I know how to do that for APIs for example, inside rails, but Im not familiar how I could access this variable inside my javascript/jquery script. I would love if someone could give me a insight. Thanks you.
As #davidhoelzer mentioned, you can't do this with pure js (as far as I know)... you could, however, change the .js file to .js.erb and use ruby to access/manipulate your environment variable that way.
I would like to ask you - I have javascript code and I need into this part of code transmit variable with data from database. This variable is in controller. How can I do it?
I tried something like (in *.js):
$("#div").append('<%= escape_javascript(#test) %>hhhhhh');
or
$("#div").append('<%= #test %>hhhhhh');
But the codes above not works... Could you help me, please, how to do?
Thank you, Manny
If you are rendering a response to AJAX-call, that code should go in your_action.js.erb file. Otherwise, if it's just inline JavaScript, place it in your_action.html.erb under app/views/your_controller directory.
Correct me if I understood you wrong.
I have two 'define' in two separate js files.
def1.js and def2.js
define("mydefname1",["file1",...]});
define("mydefname2",["file2",....]});
I have another require statement where i check if the two definetions are loaded.
require(['def1','def2'], function(){alert('loaded')});
this works fine..
but if I try
require(['mydefname1','mydefname2'], function(){alert('loaded')});,
it does not work.
Is there a way I could actually use mydefname1 and mydefname2.. i.e. the module name to load them, and not the file name?
As far as I know, that's not possible. What I usually do is format my file names to include my module name, so I can include it that way.
For a metaclass name Overlay, the file name would be class.Overlay.js and my require/include functions would take my module name and build the file name from it.
As I understand it, RequireJS recommends that you avoid manually assigning module names - see here: http://requirejs.org/docs/api.html#modulename
FWIW, have you played around with the "path" configuration option? I don't think you can use it to do exactly what you are looking to do but it may offer an acceptable alternate approach. See here: http://requirejs.org/docs/api.html#config
Hope it helps!