Like in the image below, while most .js files turn out to be javascript files, some in the same project choose to be text files although they still have .js on the file name. The content is also in correct javascript syntax and I can't tell what went wrong.
Does anyone have an idea how to fix this?
The most common explanation is they are .txt files. In other words, it means that the file's full name is something like index.js.txt.
Can you check the file type? You can quickly do that by:
Right-click on the file name;
Select the option "copy path";
Past it in some .txt file. Check if you obtain something like this: C:\{some-path}\index.js.txt
If you still see index.js check the file type. Sometimes when new files are created, the operating system does not create that file with the extension type that we define in the file name.
The solution is just to create another file, ensure that the operating system detects the file type, copy the content to this new file, and delete the old one.
Related
Is there a way to get all of the available files in a certain path with javascript?
An example would be that the user would type a place of a folder into an <input> like "C:\Program Files" and JavaScript would get some array of all the available folders in their Program Files folder.
No, JS doesn't have access to the file system / hierarchy. Server side JS is a different story but I think you don't mean to ask about it.
I've been looking at the atom-beautify site and example .jsbeauifyrc, .editorconfig, and uncrustify.cgf files.
I've also reviewed the options for atom-beautify. I know I'm supposed to specify where the config file is located in the atom-beautify settings. I've tried putting a .jsbeautifyrc file, an uncrustify.cfg file, and both files in the same directory I specify in the atom-beautify settings. It doesn't have any effect. The default settings are used. I'd like to make some old C++ code look more uniform for my current project and future projects my group is working on.
Which file am I supposed to use?
What must I include in each file?
Where should this/these file(s) be located?
How do I specify the path?
Are there any other changes I need to make that I'm not aware of?
To sum up, I want to use uncrustify from within the Atom editor (using the atom-beautify package) to make my C++ code look nice.
Make sure uncrustify is installed on your computer, and accessible from CLI
In the settings for atom-beautify, go under the C++ section and type uncrustify.cfg as a Config Path
Place the config file name uncrustify.cfg in the root folder
Try beautifying your code, it should be using your config file now
you have to add PathVariable of uncrustify.exe (From Source AtomBeatify : https://atom.io/packages/atom-beautify ) on your system , when you upload you code to Atom click on ALT+CTRL+B it will beautify you Code .
Download zip On Windows, download the latest version of Uncrustify here: https://sourceforge.net/projects/uncrustify/files/latest/download
Extract zip The program is a standalone exe, so just extract the downloaded uncrustify-...-win32.zip file anywhere. For this example, I'll use C:\Uncrustify. So, the uncrustify.exe would be in that directory.
Add directory to PATH System Environment Variable In Windows 7+: Type Winkey + env - Select "Edit the system environment variables"
On the Advanced tab, click the Environment Variables button at the bottom. In the System variables section at the bottom, click the Path variable, then click the Edit... button.
Click the New button, and type C:\Uncrustify, or the directory that you extracted uncrustify.exe to.
Important: Click OK to close the dialog boxes or your change will not save. Verify
In a CMD window, typing where uncrustify should return the path to the uncrustify.exe.
In my case it shows C:\Uncrustify\uncrustify.exe Close Atom and reopen it. Now you should be able to atom-beautify and it will use Uncrustify to format your selection
I need to know if there is a way to retrieve the real file extension without parse the filename.
In my code I split the file using the function split(filename, ".") then i get the last element of the array that the function returns.
Now, if I create a .pdf file called, for example test_file.pdf, the previous method works perfectly, but if i rename my file to test_file(without extension) I cannot retrieve the extension even if I know that the file is a PDF.
For example, if i rename test_file.pdf to text_file.jpg how can I recognize that the file is still a pdf and not an image file with .jpg extension?
I would like to know if there is a way to obtain this information, maybe using file metadata or other information related to the file.
I'm looking for a Javascript solution because I have to check the extension when I upload the file using a form (client side) but even a Java solution could be fine, can you help me?
Thank you in advance!
Look at this post and the marked answer: Get real file extension -Java code
I guess it's just what you need.
I want to create a Chrome extension that contains a text file with static data (a dictionary of English words) and I want the extension to be able to parse that file. I've only managed to find FileReader class, but it looks like it's made for reading user-selected files, while in my case I always want to read the same exact file included in extension's package. As a workaround, I can convert the file to a Javascript array of strings declared in some .js file included in the manifest, but in that case the whole contents would be loaded into memory at once, while what I need is to read the data line by line. Is there any way to do this?
You can go the FileReader route, since you can obtain the Entry of your package directory with chrome.runtime.getPackageDirectoryEntry().
However, an easier way is to just make a XHR to your file using chrome.runtime.getURL() with a relative path. The first way is useful when you want to list files, though.
i'm confused as to how i could implement epub.js.
(https://github.com/futurepress/epub.js/blob/master/documentation/README.md) i'm having a hard time understanding the documentation since i'm new. I tried following the demo files and folders and the "basic" example file but i noticed the paths direct to a folder named "OPS" which has a file for every chapter and others.
so i'm stuck on what to do with the .epub files and how to get a folder like that given my epub files.
simply change file extension of .epub to .zip and unpack yours books. When you done that, edit this part:
var Book = ePub("url/to/book/"); // With default options
where and give it path to your book.