PDF Reader Core for iOS vfr.org | Scito te ipsum

While Loop output data live (VB.net) XML Reader

Background Story: I have a huge XML file (about 57 GB and increasing about 250 MB / week) which i need to read through and parse data to a database. So far I've been able to setup a XML reader in a while loop which can read each element at a time and output the data I need. I've also added an element counter and a limit of 600 elements in the loop. This works perfect and I'm able to get the first 600 elements of the total of 8.7 million elements in about 2sec. Then I changed the limit to loop the first 2000 elements and now it had to run for 20 sec. At 3000 elements it took almost 50 sec but the estimate from the first test showed it should have taking only 10 sec.

I've noticed that the while loop waits for the all the elements to run through before it displays it in my application. When I press the button nothing happens until all the data is ready. This is probably why it's getting exponentially slower and slower, as the application has to store each variable somewhere while the loop is active. The intention of the XML reader was to not store all the information in memory at once, but it looks like thats exactly whats it's doing now anyways.

QUESTION: Is there someway i can force the application to output the data to a database after each loop and therefore don't have to store anything in memory?

Here is my XML and the Vb.net code I've modified to my project. I can post my exact code if you need it, but it's very similair:


<api id="M:Microsoft.VisualBasic.Strings.Mid(System.String,System.Int32)">
  <apidata name="Mid" group="member" subgroup="method" />
    <namespace api="N:Microsoft.VisualBasic" />
    <type api="T:Microsoft.VisualBasic.Strings" ref="true" />
<api id="M:Microsoft.VisualBasic.Strings.Mid(System.String,System.Int32,System.Int32)">
  <apidata name="Mid" group="member" subgroup="method" />
    <namespace api="N:Microsoft.VisualBasic" />
    <type api="T:Microsoft.VisualBasic.Strings" ref="true" />

Button Click:

        Dim reader = Xml.XmlReader.Create("..\..\reflectionData.xml")

    While reader.ReadToFollowing("api")
        Dim api = TryCast(XElement.ReadFrom(reader), XElement)

        If api Is Nothing Then Continue While

        ' Get information from the <api> element.
        Dim ns = api.<containers>.<namespace>.@api
        Dim containingType = api.<containers>.<type>.@api
    End While


Source: (StackOverflow)

React - 'Uncaught TypeError: Cannot read property in reader.onload

When I run code below

console display:

Uncaught TypeError: Cannot read property 'component' of undefined

but the test code can display:

ReactDOM.findDOMNode(this.refs.component).innerText = 'ddd';

What's problem?

var reader = new FileReader();

reader.onload = function(e) {
  console.log('onload: ' + e.target.result);
  ReactDOM.findDOMNode(this.refs.component).innerText = e.target.result;                   

reader.onerror = function(stuff) {
    console.log("error", stuff);
    console.log (stuff.getMessage());

ReactDOM.findDOMNode(this.refs.component).innerText = 'ddd';
console.log('readAsText:' + reader.readAsText(data[0]));

Source: (StackOverflow)

can cljc single-file macro definitions to work with clojurescript?

I have clojurescript successfully importing macros from other namespaces. But I wonder whether a single-file construction is/should be possible with clojure 1.7, such that a macro can be defined and used. What I have tried does not work, but maybe I've missed a detail someplace.

(ns cljc.core)


(defmacro list-macro [x y]
  `(list ~x ~y)))

(defn foo [a]
  (println (list-macro a a)))

(foo :a)

This form fails with list-macro being undefined when compiling cljs; if I remove the :clj guard around list-macro, then defmacro is undefined within the cljs compilation. Is there a way?

Source: (StackOverflow)

How to use csv reader object multiple times

I am doing a python project.I opened a new csv files and its contents are

 A     |  B
  1.  200 | 201   
  2.  200 | 202
  3.  200 | 201
  4.  200 | 203
  5.  201 | 201
  6.  201 | 202

And what I am doing is...

def csvvalidation(readers):
    for row in readers:
        print row
def checkduplicationcsv(reader):
    datalist = []
    for row in reader:
        print row
        content = list(row[i] for i in range(0,3))
with open("new.csv", "rb") as infile:
    reader = csv.reader(infile)
    first_row = next(reader, None)  # skip the headers

The problem is I can print the values only one time.The csvvalidation() function reader is not working.How can I use the reader object multiple times.I can't print its row values.What can I do?Please give me a solution.And I am not aware of seek() (I think that its pointing to the same reader again).So I tried infile.seek(0) after the first function but no use.nothing happens

Thanks in advance.

Source: (StackOverflow)

Many writers one reader without concurrency

I'm programming in java, and I have a List<LogEntry> logwhich is shared between different threads.

These "writers" threads are already synchronized between them, so only one thread at time can add or remove elements from log

However, because of the distributed algorithm that I'm trying to implement, there are portion of log which are "safe", which means that they cannot be modified neither by the writers or by the reader (which I introduce below) . This portion of log is indicated by the field int committedIndex, which is initialized to 0 and increase monotonically.

In conclusion, writers modify the elements in log in the range (commitIndex,log.size()), while there is a reader which get the elements in log contained in the range [0,commitIndex]. The reader starts to read from the first entry, then read the next one until he reaches log.get(commitIndex), then it stop and goes to sleep until commitIndex is increased. It updates a field lastApplied which is initialized to 0 and increases monotonically in order to remember the last logEntry that he read before going to sleep.

As you can see there is no need to synchronize the reader and the writers, since they access different portions of log.

My question is: how can I "wake up" the reader's thread when commitIndex is increased? I'd need something like this (executed by a writer):

if(commitIndex is updated)
     //wake up reader

And the reader:

public void run() {
        //go to sleeep...
        //now the reader is awaken!
            //do something with log.get(lastApplied)

Obviously I terribly simplified my code in order to make you understand what I want as better as possible, I'm sorry if it's not clear enough (and don't hesitate to ask me anything about it). Thanks!

Source: (StackOverflow)

Repeated values in list in while(reader.Read()) {}

public List<reports> getMyReports( int user_id )
    string cs = ConfigurationManager.ConnectionStrings["ReportDB"].ConnectionString;
    using (SqlConnection con = new SqlConnection(cs))
        SqlCommand cmd = new SqlCommand("getAllReportsByUserID", con);
        cmd.CommandType = CommandType.StoredProcedure;
        List<reports> repers = new List<reports>();
        //users[][] liser = new users[][];
        SqlParameter user_id_parameter = new SqlParameter("@user_id", user_id);
        reports report = new reports();
        SqlDataReader reader = cmd.ExecuteReader();
        while (reader.Read())
            report.id = Convert.ToInt32(reader["id"]);
            report.title = reader["title"].ToString();
            report.description = reader["description"].ToString();
            report.anonymous = (bool)reader["anonymous"];
            report.location = reader["location"].ToString();
            report.status = reader["status"].ToString();
            report.category = reader["category"].ToString();
            report.date = (DateTime)reader["date"];
            report.picture_url = reader["picture_url"].ToString();
            report.admin_id = Convert.ToInt32(reader["admin_id"]);
        return repers;

I have the top function that calls the following stored procedure:

CREATE Proc [dbo].[getAllReportsByUserID]
@user_id int
  from reports 
  where user_id = @user_id

I have tested the procedure individually and it works fine. Yet, when I test the WebService created above I get a list with the last value duplicated along the whole list.

Can someone please help me figure out why do I get the same (last)value repeated over and over again?

Source: (StackOverflow)

How to get float value with SqlDataReader?

In my database, I have NextStatDistanceTime value as a float. When "float time = reader.GetFloat(0);" line excecuted, it gives an error of

system invalid cast exception

How can I get float value from sql command in this code?

Here is my code:

using (SqlConnection conn = new SqlConnection(@"<myconnectionstring>"))
    float totaltime = 0;
    for (int i = startStationIndex; i < endStationIndex; i++)
        SqlCommand command = new SqlCommand("SELECT NextStatDistanceTime FROM [MetroDatabase].[dbo].[MetroStation] WHERE StationIndex = " + i + "", conn);
            using (SqlDataReader reader = command.ExecuteReader())
                while (reader.Read())
                    float time = reader.GetFloat(0);
                    totaltime = totaltime + time;
        catch (Exception ex)
            result = ex.Message;


Source: (StackOverflow)

What does this "#" mean in this Clojure context?

I stumbled upon the official Om example under "examples/mixins", there's a definition as this:

(def MyComponent (let [obj (om/specify-state-methods! (clj->js om/pure-methods))]
    (aset obj "mixins" #js [TestMixin])
    (js/React.createClass obj)))

What does "#js" mean? I couldn't find any Clojure documentation on symbol "#" when it's used in this way.

Source: (StackOverflow)

Android camera2: java.lang.IllegalStateException: maxImages (1) has already been acquired, call #close before acquiring more

Hello having trouble to fix this issue.

I already have a imageReader.close called inside the ImageAvailable callback but still having the error:

java.lang.IllegalStateException: maxImages (1) has already been acquired, call #close before acquiring more.

Code I have is here:

private ImageReader.OnImageAvailableListener imageAvailableListener = new ImageReader.OnImageAvailableListener()
    public void onImageAvailable(ImageReader reader) {
        Image img = mReader.acquireLatestImage();



ps. I also use the argument reader as well but not seem to solve the problem

Source: (StackOverflow)

read specific line in csv file , python

In an CSV file with python we can read all the file line by line or row by row , I want to read specific line (line number 24 example ) without reading all the file and all the lines.

Source: (StackOverflow)

Getting a reader for a byte array

I'm trying to test some code which takes a reader. I've got a function:

fn next_byte<R: Read>(reader: &mut R) -> ...

How can I test it on some array of bytes? The docs say that there's a impl<'a> Read for &'a [u8], which would imply this should work:

next_byte(&mut ([0x00u8, 0x00][..]))

But compiler disagrees:

the trait `std::io::Read` is not implemented for the type `[u8]`

Why? I explicitly said &mut.

Using rust 1.2.0

Source: (StackOverflow)

Load pdf on foreign url with pdf.js

I am trying to load pdf from another server to the viewer of pdf.js in my server.I got error "PDF.js v1.4.20 (build: b15f335) Message: file origin does not match viewer's"

I already checked many answer, many of them said that pass the pdf url through a proxy like:- link

After searching a lot i found that they release a new patch in which they have lock down any CDR request, correct me if i am wrong:-Here is the link

but in their user manual they specified that it is possible here is the link

I tried all method but not able to enable CDR on my server and many methods didn't work.

Please help me to resolve this issue. My Basic idea is to show pdf(which is hosted on 3rd party server) on my pdf reader(that i made it from pdf.js).

Source: (StackOverflow)

Golang read multiple times from same reader

I want to use request.Body(type io.ReadCloser) which is containing a image.

I dont want to use ioutil.ReadAll() as i want to write this body directly to the file as well as want to decode it, so i only want to use the reference to the content to pass to further function calls,

I tried creating multiple instances of reader for example shown below

package main

import (

func main() {
    r := strings.NewReader("some io.Reader stream to be read\n")
    a := &r
    b := &r


but in second call it always results into nil.

Please help me how can i pass multiple separate reference for the same reader?

Source: (StackOverflow)

C# xml reader, same element name

I'm trying to read an element from my xml file. I need to read an string in an "link" element inside the "metadata", but there are 2 elements called "link", I only need the second one:

<desc>February 18, 2015. Corn</desc>
    <link rel='nofollow' href="http://snow.traceup.com/me?id=397760"/>
<link rel='nofollow' href="http://snow.traceup.com/stats/u?uId=397760&amp;vId=1196854"/>
<keywords>Trace, text</keywords>

I need to read this line:

<link rel='nofollow' href="http://snow.traceup.com/stats/u?uId=397760&amp;vId=1196854"/>

This is the working code for the first "link" tag, it works fine,

        public string GetID(string path)
        string id = "";
        XmlReader reader = XmlReader.Create(path);
        while (reader.Read())
            if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "link"))
                    if (reader.HasAttributes)
                        id = reader.GetAttribute("href");
                        MessageBox.Show(id + "= first id");
                        return id;
                        //id = reader.ReadElementContentAsString();
            return id;

Does anyone know how I can skip the first "link" element? or check if reader.ReadElementContentAsString() contains "Vid" or something like that?

I hope you can help me.

Source: (StackOverflow)

Change default reader in common lisp

I wrote some function that could replace the function read of common lisp

(defun my-read (stream &rest args)
  (declare (ignore args))
  (funcall (my-get-macro-character (read-char stream))))

Is there a way to use this function as default reader?

Source: (StackOverflow)