Is there a built in function to find the operating system? - imagej

So I want to navigate the file system from within a Fiji script, and create files. macOS uses / as a separator while windows uses \ as a file separator. I can't for the life of me find an easy way to do this given the poor search ability of the documentation.
For example, in Matlab, I can use a built it variable filesep or ispc() or ismac() to find out.
Is there a similar function in imageJ?
Thanks

I just found the answer. Using Fiji, you can use File.separator.
See further documentation here

Related

How to read and write id3v1 and id3v2 tags in Elixir

I would like to scan music files and read/write metadata using Elixir (this whole project is about learning Elixir - so please don't tell me to use Python!). As I understand it, I have two choices: call a system utility or (as no libraries exist in Erlang or Elixir that I am aware of) write an Elixir library. For m4a files, I make a system call to MP4Box and it writes an xml file to disk. I then read in the file, parse it, and load the data into a database.
def parse(file_name) do
System.cmd("MP4Box", ["-diso",file_name])
Ainur.XmlParser.parse(xml_file_name(file_name))
|> get_tags
end
Very slow, especially for thousands of files. And I want it to run at start up everytime to check for changed/new files.
Now I am trying to do the same for mp3's with id3 tags. I tried libid3-tools on Ubuntu and it only found the id3v1 tags. eyeD3 only found id3v2 tags. My mp3's have both so I need to make sure there are the same (I suppose I could delete the id3v1 tags, but I have been led to believe that id3v1 tags are needed on legacy equipment).
Are there any Erlang or Elixir libraries for music metadata? If not, are system calls to ubuntu utilities my best choice (any recommendations on which ones)?
Or do I need to write a library to obtain reasonable performance? If so, is there an existing library in a functional language that I could try to port?
Or is it possible to call a library written in another language directly from Elixir (without the system call)?
You can always use erlang NIFs (http://erlang.org/doc/tutorial/nif.html) to wrap an external library
In this project we have a module written in Elixir which extracts ID3 tags from mp3:
https://github.com/anisiomarxjr/shoutcast_server/blob/master/lib/mp3_file.ex
To use:
id3 = Mp3File.extract_id3("./test/fixtures/nederland.mp3")
I've implemented ID3v2 tag reading (not writing) in Elixir. It's on GitHub and Hex.
Support is very basic; I implemented the bare minimum to support my use case. There's lots of bugs, but all the building blocks are there to fork/improve/contribute.
You could also try directly reading the binary of the file to find the tag in question.
Check the File.stream/3 docs to get started.

How to debug epub?

I've written an ePub generator by using ZipArchive in .NET and looking at the spec (in Wikipedia) & a example.
It doesn't work! But I only get a generic error so I'm unable to fix anything from here.
Where could I go to upload my ePub and be told what is wrong with it? Or is there a tool that is better for it? I'm currently using Adobe ePub reader...
I realize this is an old question, but in case others come across this I wanted to contribute. The IDPF which is responsible for the ePub standard has a tool for checking ePubs called epubcheck. It can be found at https://github.com/IDPF/epubcheck.
In addition, they have their own online validator that uses epubcheck. It is located at http://validator.idpf.org/
I found an online validator tool at http://www.epubconversion.com/ePub-validator-iBook.jsp.
There are two basic black box approaches.
First: Generate a file and put it into a validator.
Second: Take a set of in- and output without using your code (other generator, example, do it manual). Then use a file comparison tool (maybe extract zip first).
Here is a good offline checking tool for Windows, Mac or Linux OS:
http://www.pagina-online.de/produkte/epub-checker/
It's a great tool which even i used to validate and generate epub files also clearly give errors if any.

Java: How to open a library?

I want to open libraries, because currently I want to see the algorithms used for drawing, modify them and implement them in my program. For example: I have tried to create an algorithm on my own for lines. But I failed. And even if I had succeeded, I fear that it might not give the same result as the algorithm in the libraries. And I don't want this to happen. That's why I want to copy the algorithms used for the methods in libraries. And I really hope that this will help me create the application I'm currently working on and with other applications in the future.
I tried to open the libraries with a code editor. But I had troubles finding the libraries- I don't really know where are they placed nor in what files are their codes stored.
How to open a Java library? Or is there a place in the Internet where the code is uploaded?
It sounds like what you want is to get inside the standard Java libraries (so you can see the code for methods like Graphics.drawLine()).
You can download the source files from the same place you got the JDK, if you are on Windows or Linux. For the Mac, see this question. You can even set up Eclipse so that you can debug into that source as if it were your own code.
However, you will probably not find line-drawing code in Java in these libraries - the Graphics implementation will almost certainly use native methods, and may just call existing methods in the OS.
If you are specifically looking for line drawing algorithms, another option would be to look at the Wikipedia page for the Bresenham (aliased) or Wu (antialiased) algorithm.
Edit:
The part of a Graphics2D call that actually puts pixels on the screen is probably inside a system call and therefore the source would not be available.
A java vector graphics library like Batik might have source for some of these algorithms, but probably relies on the Graphics2D calls for most of them. So, you might look for a comprehensive vector graphics library written in a language other than Java, where those graphics calls do not already exist by default.
Alternately, checking the table of contents for a computer graphics book might point you at a variety of algorithms that you could look up on Wikipedia.
For any given library:
Make sure to obey all licenses when using another's code
If you are referring to the Java SDK source code, you can find it here: http://grepcode.com/
If the project is open source, you can usually just get the source from the project website. No problem, though make sure to obey their license.
If the project is NOT open source, well, then you're in a pickle licensing wise, so I do NOT endorse this, however, you would need to use a Java Decompiler such as JD-Gui
As far as what drawing algorithms to use, there are so many different ones (obviously, people have been trying to draw quickly for many many years), your best bet is to figure out exactly what you need to do and then search for that specific need separately. There isn't really a good repository of ALL of them, except maybe wikipedia.
If you are using the libraries they are on your classpath. Check out how to figure out your classpath in whichever IDE you are using and you can find the JARs you depend on. If they are packaged with sources all you need to do it unjar them and look at the sources.
If you don't have access to the sources you can get the code using a Java Decompiler.
If you are trying to look at a standard Java library, see the other answers about getting the source to the JDK.
If you are interested in an open source library (such as something maintained by the Apache project), look on the site of the project for a 'source jar' which you can open with a standard zip utility.
If the library you want is not open source or you cannot find the source for it, you can try to decompile it. If you are using Eclipse, try this decompiler.

simple search engine

I am trying to write program its like a simple search engine, in this program the user is supposed to enter a search keyword into an edit box and then he can click the search button, and the program is supposed to open a specific text file from the directory and find a matching word to that keyword in this text file. I am using Delphi 2007. thank you
Basically you need to find a string in another string. Take a look at this algorithm: http://en.wikipedia.org/wiki/Knuth-Morris-Pratt_algorithm
If you are on a unix system, send a call to grep. If you are on a windows system, install grep for windows.
You might want to look at the source code for the open source project GExperts. It contains a text search engine (grep) that works very well.
I have written something similar in C# - Searcharoo.net - you can download the source code from there.
What might be more useful, though, are the articles that I wrote describing how it works... This description of how Version 1 might be of some use - although I'm probably biased since I wrote it (back in 2004).
Your question is pretty open so I'm not sure if this will help - particularly since I don't know Delphi and how different it is to C# - but hope it helps...

Source code search with Google Desktop

Is there a indexing plugin for GDS that allows for source code search? I see some for specific types (Java, C++, ...) and one for "any text". These are nice, but I would like one that allows for many/configurable extensions (HTML, CSS, JS, VB, C#, Java, Python, ...). A huge bonus would be to allow for syntax highlighting (http://pygments.org/) in the cache.
I just found Dropout and it seems to work great. Put Dropout in any folder and it will index all files in that folder. I put it in my Projects folder and it crawled all my code. Very fast and flexible search. Dropout
You could use OpenGrok or some other code-specific search engine instead.
I wrote a quick review of some of them some time ago.
It has been a long time, but the last time I tried to use Google Desktop Search for searching code, I found it quite inappropriate for that task, as I outlined at [http://perlmonks.org/?node_id=490310], the gist of which is that GDS (silently) only indexed a tiny fraction of many source code files (and made it quite a challenge to figure out why searching so often failed to find so much of what was in source code files).
I found Copernic Desktop Search worked better on code files (but I also had trouble with later versions of it being buggy in not finding all matches so I've been staying with version 2.1.1). But these days I don't use it much (mostly because I don't have permission to install such things on the laptop provided by my new employer).
You can try out Larry's Any Text File Indexer. You can specify a list of extensions at install time and it will do full text search on those file types.
Im just giving this a go:
http://desktop.google.com/plugins/i/java.html?hl=en
..also you can search for things in your Java tree using the following syntax in Google Desktop:
<YOUR SEARCH> filetype:java under:"C:\hft\trunk"
..where I keep my code in "C:\hft\trunk"
This is not a Google Desktop plugin, but works for what we need.
We have started using http://svnquery.tigris.org/ and it seems to work and is very fast. I wish it supported multiple repositories per site. We have a repository per project, so currently I have to create a virtual directory for each project we have. Not a show stopper, just something we need to automate in our project setup script.

Resources