How to look ahead into a file? - r

I'm asking myself and you how to look ahead into a file without reading it. At a first glance the seek function seems to be appropriate. The documentation says:
seek with where = NA returns the current byte offset of a connection
(from the beginning), and with a non-missing where argument the
connection is re-positioned (if possible) to the specified position.
But at the end of that page I found the following warning:
Use of seek on Windows is discouraged. We have found so many errors in
the Windows implementation of file positioning that users are advised
to use it only at their own risk, and asked not to waste the R
developers' time with bug reports on Windows' deficiencies.
So is there any save way to look ahead?

Related

Gremlin.NET Query Compilation Error: Unable to find any method 'hasNext'

The line: g.V('1').out('knows').hasId('2').hasNext()
This exact line works in the Gremlin console.
I have not read in the documentation that hasNext does not exist in Gremlin.NET. Am I missing something, or is there simply another way to do this in Gremlin.NET?
This method is really missing in Gremlin.Net right now. While this is not explicitly stated in the documentation, the documentation does list all terminal steps implemented by Gremlin.Net:
ITraversal.Next()
ITraversal.NextTraverser()
ITraversal.ToList()
ITraversal.ToSet()
ITraversal.Iterate()
hasNext is also such a terminal step but as you can see it is missing in this list.
The only workaround I can think of for situations like this is to use the count step and then check in your application whether the returned count is greater than zero:
var count = g.V("1").Out("knows").HasId("2").Count().Next();
var exists = count > 0;
In some cases it could also make sense to limit the number of vertices going into the Count step as you aren't interested in the exact count but only want to know whether at least one vertex exists:
g.V("1").Out("knows").HasId("2").Limit<Vertex>(1).Count().Next();
This is also the proposed workaround in the ticket for this feature: TINKERPOP-1921.
It does not exist yet:
https://issues.apache.org/jira/browse/TINKERPOP-1921
The main reason is related to the fact that hasNext() is a Java Iterator semantic that was not applied to .NET. Gremlin Language Variants (GLVs) like .NET are given some latitude in terms of how they interpret the language so as to provide the most at-home feel for developers using it. In other words, if you are using the .NET GLV you shouldn't feel as though you are coding in Java, but should instead feel write at home with the standard .NET semantics.
That said, it could be argued, as it is in the issue I've referenced above, that something like hasNext() is a common form of Gremlin as a query language and should thus be available in all GLVs. So, we will consider those options as we come across them.
For .NET I guess you would try to check Current as discussed here.

When multiple resumes cmi.core.score.raw is improper

When I make multiple resumes attempt to a single course the cmi.core.score.raw score is not updated properly.
Suppose there are 5 sections in the course. If the user successfully completes the 2 sections, then exits the score is proper (say 30). While the user resumes the course, it starts with the proper position and even if the user correctly answers all the question correctly, the score is not updating to 100 ( it saves as 70-80 ). It shows the result as failed which is wrong since the user has answered all the questions correctly.
I thought it may be due to the suspend_data max limit posed by SCORM 1.2, but the course resumes at the correct location every time. So I am confused about what may be causing this behavior?
I also tried the same course in scormcloud, there also the same issue persists.
Are there any settings which we need to take care while creating the SCORM 1.2 package which may have caused this issue?
Has anyone faced this issue previously? I googled and couldn't find the appropriate answer. Any help would be appreciated.
Update: I'm attaching the scromcloud launch history image which will clearly show the score value at launch start and end.
The SCO is typically responsible for conducting the "math" portion since it maintains the cmi.core.score section of the student attempt.
You're correct to assume something with the suspend data may not be giving the SCO's capability of determining a history of correct/incorrect but deeper analysis would be required within the logic of the SCO to find out if it fully supported being put back in a position it left off in.
SCORM 1.2 was mostly a 'optional' standard in regards to the support of the Student Attempt. And even though the standard often states there are character limits it typically was optionally enforced by the LMS.
So something to possibly evaluate whats going on within the SCO while using it on a LMS would be to try out the bookmarklet on https://cybercussion.com or see if you can locate the deeper logs on SCORM cloud which show the actual data being stored. Its always possible the suspend data is obfuscated but since you said SCORM 1.2 I'm going to say doubtful. It may be semi-human readable.
Fail that we'd need to dig into the SCO code base to determine how it "puts itself back" after obtaining the suspend data. To do that I'd search the code base for "cmi.suspend_data" to maybe help locate it.

Is it possible to include the os library in lua 4.0?

I'm stuck using the 4.0 version of lua which does not seem to support the os library. Is there a way to include this library into my project?
Or get another way to use the functionality contained within pertaining to date time calculations?
Preferably by using a *.lua file and not a *.c file since I don't have complete access to the code.
When I run the following line,
print(os.time{year=1970, month=1, day=1, hour=0})
I get an error stating:
attempt to index global 'os'(a nil value)
As #Colonel Thirty Two said it's not possible to use the os library. So the time() funciton is not available for me.
Adding to the (totally correct) currently accepted answer (that if "os" access was not allowed to you, you're generally done), there's some very slight chance the Original Programmer may have provided you with some alternative facilities to do your thing (fingers crossed). In a perfect world, those would be described in some kind of a User's Manual for your scripting environment. But if the manual was lost to time (or never existed in the first place), you might possibly try your luck at exploring any preloaded libraries by digging through the result of the globals() Basic Function. (At least I hope that's how it was done in 4.0 too.) That is, if the Original Programmer didn't block globals() for you too...

Oracle Report layout issue?

I am a novice user of Oracle Report Builder, so forgive me if the answer should be obvious.
I am attempting to run a 9i report, and I keep getting an error that appears like there is an issue with frames overlapping. I have two versions and both are getting the same error. One version is the report I want. The other is a stripped down version with only a couple fields, to narrow down what might be causing it.
Terminated with error: <br>REP-271187990: Virtual Memory System error. REP-0200: Cannot allocate enough memory. cavaa 22 REP-0002: Unable to retrieve a string from the Report Builder message file. REP-271187990:
Occasionally, it kicks out the message below when I try to run it, with no other accompanying details. The select runs and returns the desired results, and the function returns the ref cursor results as expected. The package is valid and compiled, so the query itself should be fine. There is only one query in the report, and I have tried various things, including stripping the report to narrow down the source of the error, with no luck. Any ideas to try would be appreciated.
Terminated with error: <br>REP-1401: 'qr_1refcurds1': Fatal PL/SQL error occurred.
It turns out that the problem was with data returned from my refcursor.
In the package spec I had one of the fields wrong field in the table.field%type declaration.
For those experiencing a similar error I would suggest:
If you have your SQL in functions, as opposed to right in the report, check your package spec to ensure your field order matches usage in the body.
If you have any overlapping frames in your report, this message can also come up. Check the object navigator for any hidden frames. They can be totally invisible, and the only way to know for sure is by checking in the navigator. Hint - Give meaningful names to your fields and text labels, so you can see what's contained in each frame. Also check the source of container frames is... but that's another REP error to enjoy.
Depending on setup, the first time you load a report it may error out referring to one of your queries. That happens after compile. Just try again, and every time going forward it's fine.
Consider the server patches mentioned above if your SQL statements are dynamic.
Feel free to add to this list if you know of others.
According to Oracle Support Note 430044.1 -
MS Windows: Reports 10g with Ref Cursors Fails with REP-200 and REP-65
Virtual Memory System Error [ID 430044.1]
This is a known Oracle Reports bug for MS Windows Platform.
Bug 5584001 DYNAMIC REF CURSORS DON'T WORK IN VERSION 10.1.2.0.2
REPORTS BUILDER
There are step by step instructions in the Oracle Note to apply the patch to resolve this issue. Also note, this problem is specific to MS Windows.
The suggested Oracle One-off patches are-
One-off patch 4505133
One-off patch 5634746
Log-on to Oracle Support, download the two patches and follow the step by step instructions mentioned in Note 430044.1 to apply the patch.

How to query the containing partition of a file with KDE/Qt4?

I'm using KDE, and I'm toying with the idea of hacking the code for Dolphin File Manager (and potentially Konqueror if necessary) to get context-sensitive drag and drop behaviour (i.e. files are moved within the same partition, or copied if they're moved across partitions or the source is read only).
To do this, I think I'd need to find out the containing partition of the source and destination (easy enough on Windows using the drive letter, but on Linux, as mount points can be almost anywhere, it can't be reliably derived from the file path), and compare them.
Does anyone know how I can find out the partition that contains a given file?
It must be possible - I know Nautilus provides this sort of behaviour, but I'm not familiar enough with GTK to track down the appropriate section in the source code to see how its done...
Qt doesn't provide API for this. For POSIX, have a look at stat.
For KDE, you can use KIO::stat() to get mostly the same info as POSIX' stat function but asynchronously.
The device id should be in the field UDS_DEVICE_ID of the result.

Resources