w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How to find documents by some conditions for its linked documents
As JohnnyHK commented, the type of query you want to do is a relational type query and document database such as mongodb simply do not support them. Fix your schema to put that tag data directly in the link schema (nesting or "denormalizing" from a relational standpoint, which is OK in this case), then you can query it: var LinkSchema = new Schema({ name: String, tags: [String] }); With that Schema, your query will work as you expect. To address the comments below. This is a document database. It's not relational. There are trade-offs. Your data is de-normalized and it gives you some scalability and performance and you trade off flexibility of queries and data consistency to get them. If you wanted to rename a tag, a relatively rare occurrence, you'd have to do a whopping 2 databas

Categories : Node Js

Strategy for keeping separate Databases in Sync
I know I've done with this with messaging in the past - specifically JMS with ActiveMQ. I would send the updates to a NoSQL store (Mongo) by using a queue. This way messages could accumulate in the queue and if the connection to the NoSQL store ever got severed, it could pick up where it left off. It worked really well because ActiveMQ was really stable and simple to work with. I've always seen this done with diffs like you mentioned. You introduce date fields all over and then keep track of the latest sync. The nice thing about this approach is that it easily allows you to replay transactions by modifying the last sync date. One last piece of advice ... write good tools around pumping data from point A to point B (in this case SQL to NoSQL). I wrote several tools to bulk load the NoSQL

Categories : SQL

Reading the next line in the file and keeping counts separate
Several things: 1. use hash instead of declaring each element. 2. assignment such as $G = (0); is indeed working, but it is not the right way to assign scalar. What you did is declaring an array, which in scalar context $G = is returning the first array item. The correct way is $G = 0. my %seen; $seen{/^([A-Z])/}++ for (grep {/^>/} <INFILE>); foreach $gene (keys %seen) { print "$gene: $seen{$gene} "; }

Categories : Perl

COUNT(*) or separate table for keeping track of total?
Creating a separate table is denormalised design, but it might be justified if not doing it would significantly impact performance. If you do choose to do this, then it becomes your job to keep the table of metadata updated properly, which is an additional burden and set of things that can go wrong. For MySQL it matters what storage engine you are using. InnoDB performs poorly with COUNT(*) queries IIRC. For MyISAM it does not matter so much.

Categories : Mysql

Any Advantage to Giving All Collections a Separate Root Node in XML Documents?
I can see no reason to have the extra hierarchy, if there is only one per parent node and they have no attributes or special data of their own. I would just have subcategory directly under category and article directly under subcategory. I personally like to keep things clean and simple :) EDIT: I agree with @JimGarrison, if you had other data at that level, which from your example you don't seem to have, then grouping them under one node would have had an advantage.

Categories : Xml

Meteor: Embed documents inside a document or separate them into each collection object and link them?
Separate collections for students and classrooms seems more straightforward. I think just keeping a 'classroom' or 'classroomId' field in each student document will allow you to join the two collections when necessary.

Categories : Mongodb

MongoDB merge 2 very similar collections. Existing documents - update, new documents - insert
The most efficient in terms of queries would be to bulk update all the dates that need to be updated in one go per date and bulk insert all those documents that need inserting. Given you have 95% the same documents where you want to update A.dateLastSeen to be B.dateLastSeen. With single updates that would be: ~66,500 updates. Leaving ~3,500 inserts. Loading all B and A in memory - then processing is one possibility. You could create a bulk insert list and append anytime a doc from B is missing from A. Also a bulk update dictionary keyed by dateLastSeen containing a list of Documents to update. Depends on the probability of any matching dateLastSeen values to see if this is really worth it. Alternatively, simplify it an accept the high query cost and start processing B in batches o

Categories : Mongodb

How to update only the non-existing documents and delete the old documents which doesnot exist now using mongoimport
Basically you want to keep only collection in your export right ? If so, take a look at the following options: --drop Modifies the restoration procedure to drop every collection from the target database before restoring the collection from the dumped backup. --upsert Modifies the import process to update existing objects in the database if they match an imported object, while inserting all other objects. If you do not specify a field or fields using the --upsertFields mongoimport will upsert on the basis of the _id field. More information on mongorestore

Categories : Mongodb

Changing the file name of a Sqlite3 database connection, while keeping keeping entire data
You cannot just change the file name of a database. Python's built-in database API does not have any mechanism to copy databases; you would have to copy the file itself, which is not possible for in-memory databases. If you use APSW instead, you can use the backup API.

Categories : Python

Guvnor is not keeping assets in Database as said in Documentation. Its keeping in File System
Thanks Thomas for the guidance. i tried out Clustering of jackrabbit in repository.xml and it worked for me. Now I have two member Guvnors in a clustered environment. Both poiting to same DB for fileSystem, persistentManager and DataStore. Now What I did for testing is brought one cluster node down and make some changes in the other one. Now brought the second node alive and running and could see my latest assets even the changes made by other node was also available. So this resolves my issue of keeping assets in DB to avoid backingup repository directory. Now I can depend on Database.

Categories : Database

Why won't CloudFormation execute my command?
Your commands block should be nested inside the config block, at the moment it is at the same level in the hierarchy. "AWS::CloudFormation::Init" : { "config" : { "files" : { "c:\Packages\WebDeploy_amd64_en-US.msi" : { "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi" } }, "commands" : { "1-installwebdeploy" : { "command" : "msiexec.exe /i c:\Packages\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart" } } }, }

Categories : Amazon

Why won't my CloudFormation script download a file?
Jonathon, I tried your template and the file downloaded successfully for me. You can check the cfn logs on the instance. They are in c:cfnlog. My cfn-init.log shows: 2013-07-19 21:30:18,269 [DEBUG] Parent directory c: est does not exist, creating 2013-07-19 21:30:18,269 [DEBUG] Writing content to c: estgoogle-logo.png 2013-07-19 21:30:18,269 [DEBUG] Retrieving contents from http://www.google.com/images/srpr/logo4w.png 2013-07-19 21:30:18,316 [DEBUG] No mode specified for c: estgoogle-logo.png 2013-07-19 21:30:18,316 [WARNING] Unsupported OS for setting owner/group: nt And my cfn-wire.log shows: 2013-07-19 21:30:18,269 [DEBUG] Request: GET http://www.google.com/images/srpr/logo4w.png [headers: {'Accept-Encoding': 'identity, deflate, compress, gzip', 'Accept': '*/*', 'User-Agent': 'pyth

Categories : Amazon

AWS - Automatic deployment (.NET) to CloudFormation stack
cloud-init is used with windows too. See the documentation for bootstrapping Windows stacks.

Categories : Amazon

Is it possible to create a SNS subscription with CloudFormation without creating a topic?
As you already discovered, AWS CloudFormation doesn't provide the expected AWS::SNS::Subscription resource (yet) and I'm not aware of this being possible by any other means, unfortunately - guess the rationale is that both are either managed within a template or externally, but your use case is sound and I can see no fundamental reason why this shouldn't be available (maybe they'll add it at some point, AWS is usually expanding their APIs over time to address such inconsistencies/missings).

Categories : Amazon

Installing Windows applications/extensions with Amazon CloudFormation
For your example of WebDeploy, you could add this: "C:\Webdeploy\WebDeploy_amd64_en-US.msi" : { "source" : "http://download.microsoft.com/download/1/B/3/1B3F8377-CFE1-4B40-8402-AE1FC6A0A8C3/WebDeploy_amd64_en-US.msi" } as a element of this section of the template "WindowsServer": { "Type" : "AWS::EC2::Instance", "Metadata" : { "AWS::CloudFormation::Init" : { "config" : { "files" : { You could then add this command: "1-installwebdeploy" : { "command" : "msiexec.exe /i C:\Webdeploy\WebDeploy_amd64_en-US.msi ADDLOCAL=ALL /qn /norestart" } to the list of commands.

Categories : Amazon

Mongodb delete documents without associated documents
So each chat has a field visitor_id and you want to delete only visitors whose _id does not appear as a visitor_id in a chat? You would have to loop over all visitors, check last_activity for each, and if it is a candidate for deletion, do a find() on chats with that visitor's _id. If it turns up no documents, you can delete that visitor. When you iterate over all visitors, you do that with a MongoDB cursor (the result of a find()). The cursor is implemented in such a way that you can safely delete documents from the underlying collection while iterating over it. The trick is that you don't attempt to express everything in a single remove() call. You iterate, check, and delete as part of the iteration. You want to make sure that the find() inside the loop is very fast, by adding an ind

Categories : Mongodb

ECM : Migration of documents referencing other documents
(Disclaimer: I work for a company which have a lot of experience in these kind of migrations and we have special tools for them.) You need a mapping between the old (SharePoint) and new (LiveLink) paths of the documents. A simple two-step migration process is the following: Copy the documents from SharePoint to LiveLink and fill the mapping table during the migration. The links in LiveLink could be changed to point to a dummy LiveLink node, left empty. Fix the broken links in LiveLink with the mapping table.

Categories : Sharepoint

Generating subnet CIDR blocks programmatically in CloudFormation templates (or adding integers together)
My solution for these kinds of issues was to use a legitimate programming language to compile a template into a CloudFormation JSON document. I used PHP 5.4, Twig and Symfony Console, but YMMV. Essentially, you do the math ahead of time in the programming language, then use that data as you write-out your JSON document.

Categories : Amazon

Mongodb : find documents including references to sub-documents [node-mongodb-native]
MongoDB doesn't support joins so you have to query for the User details separately. If you're using node.js, Mongoose provides a populate feature to help simplify this so you can do something like the following to pull in the user details: Files.find().populate('Users_id')

Categories : Mongodb

overloaded operators keeping variables updated instead of keeping the original variables
You need to stop modifying the original value: const TwoD operator + (const TwoD& rightSide) const // add this ^^^^^ { // create a new object suitable to hold the result TwoD result(MaxCols); for (int l = 0; l < MaxCols; l++) { // set the values in the result result.outerArray[l] = outerArray[l] + rightSide.outerArray[l]; cout << endl; } // and finally return it return result; }

Categories : C++

Creating the row in the second table of two linked tables (linked via a fk) not working
ps should be ps2 ps2.setInt(1, cd_id); ps2.setString(2, section); ps2.setString(3, pack); ps2.setDate(4, (java.sql.Date) startDate); ps2.setDate(5, (java.sql.Date) endDate);

Categories : Java

Data-centric application: separate database tables for separate organizations a good idea?
I was wondering whether rather than have a single set of tables, it would be much safer to have a separate set of tables for each client, all running within the same database. If you want to do this, you have a separate set of tables for each client, running in different logical databases. It's easier for the DBAs to manage. You're basically admitting that you can't depend on your application code to keep the firms separate when sharing the same database tables. Since each firm will have around 20-40 tables, will the number of tables tend to explode in magnitude with number of users, thus slowing down the database altogether? You're either going to have 20 - 40 tables for each firm, or 20 - 40 large tables for all the firms. The amount of storage will be about the same either

Categories : Database

SVNKit to find diff between two files stored at separate locations with separate revision numbers
Your code looks correct. But prefer using the new API: final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final SvnDiffGenerator diffGenerator = new SvnDiffGenerator(); diffGenerator.setBasePath(new File("")); final SvnDiff diff = svnOperationFactory.createDiff(); diff.setSources(SvnTarget.fromURL(url1, svnRevision1), SvnTarget.fromURL(url2, svnRevision1)); diff.setDiffGenerator(diffGenerator); diff.setOutput(byteArrayOutputStream); diff.run(); } finally { svnOperationFactory.dispose(); }

Categories : Java

What is the most stable and Pythonic cross-platform way to separate a string of path,filename,ext into three separate variables?
I tend to use os.path module, which has several versions depending on the OS that you're running. But importing os.path should always give you the right one. If you can you could check the OS you're using manually: import platform platform.platform() and then import the appropriate path toolkit from os. But it sure is a lot easier to just go import os.path. So what would be of interest to you is: os.path.basename(path) # To get the name of the file with extension. os.path.basename(path).split('.')[0] # To get just the name. os.path.dirname(path) # To get the directory leading to the file. Hope this helps. CAVEAT: I give no guarantee this is THE best way to do it.

Categories : Python

Can you host a sub-domain on a separate server with a separate hosting account?
Of course, it's possible. All you have to do is to create a DNS record IN A pointing to the IP of your new server. See here, for example: http://content.websitegear.com/article/subdomain_setup.htm

Categories : Ruby On Rails

many small documents or less big documents
Using keys as values, like you do in: 'username1':['user1','user2','user3'], is a bad idea as you can not do a indexed query where you look for documents that have a specific sender. This works: db.messages.find( { 'username1' : { $exists: true } } ); But it is not going to be fast. It is probably wise to keep your first option, with one document per message and sender. Then you can just do: db.messages.find( { sender: 'username1' } ); Adding a new recipient to this document can be done with: db.messages.update( { 'msgid' : '867896', sender: "username1" }, { 'recipient': { $push: "user4" } } ); You can make MongoDB use the same index for both queries as well, by having: db.messages.ensureIndex( { sender: 1, msgid: 1 } ); Other hints You need to be aware that you

Categories : Mongodb

how to set separate link styles in separate divs in HTML
Add classes to your div's View_1 .view_1 a:link { color: #CB4C2F; text-decoration: none; } .view_1 a:visited { color: #CB4C2F; } .view_1 a:active, .view_1 a:hover { color: #B60A00; } View_2 .view_2 a:link { color: #B5B5B5; text-decoration: none; } .view_2 a:visited { color: #808080; } .view_2 a:active, .view_2 a:hover { color: #FFFFFF; }

Categories : CSS

how to construct a string of physical subnet ids to create db subnet group on the fly in a cloudformation script?
I run into the same issue, after working with AWS support I understood that List of String does not mean what we initially thought. Also, if you want to place the DB inside a VPC you must not use AWS::RDS::DBSecurityGroup objects. Here is a full sample, it took me a while to get it working: "dbSubnetGroup" : { "Type" : "AWS::RDS::DBSubnetGroup", "Properties" : { "DBSubnetGroupDescription" : "Availability Zones for RDS DB", "SubnetIds" : [ { "Ref" : "subnetPrivate1" }, { "Ref" : "subnetPrivate2" } ] } }, "dbInstance" : { "Type" : "AWS::RDS::DBInstance", "Properties" : { "DBInstanceIdentifier" : { "Fn::Join" : [ "", [ { "Ref" : "AWS::St

Categories : Amazon

Compairing two separate columns on two separate sheets
code 1 Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Target.Column <> 8 Then Exit Sub Dim lastRow As Long Dim rng As Range, cell As Range lastRow = Range("H" & Rows.Count).End(xlUp).Row If lastRow < 2 Then lastRow = 2 Set rng = Range("H2:H" & lastRow) For Each cell In rng With Sheets("data") a = Application.VLookup(cell.Value, .Range("H2:H" & .Range("H" & Rows.Count).End(xlUp).Row), 1, 0) If IsError(a) Then cell.Interior.Color = vbYellow Else cell.Interior.Color = xlNone End If End With Next Application.EnableEvents = True End Sub code 2 Private Sub Worksheet_Change(ByVal

Categories : Excel

Separate check box value to separate text area
It doesn't have to be so messy as you describe. Besides, I don't know how it is working for you as the structure of html is clearly broken in the current state. Following is a bit of updated code, which I believe is equivalent to what you are trying to achieve with your snippet. DEMO JS: var itemsAdded = Array(); function moveNumbers() { var text = this.value; var i = itemsAdded.indexOf(text) if (i >= 0) itemsAdded.splice(i, 1); else itemsAdded.push(text); document.getElementById("result1").value = itemsAdded.join(" "); if (i < 0) itemsAdded.push(text); document.getElementById("result2").value = itemsAdded.join(" "); } $(function () { for (i = 0; i < 10; i++) $("<div>Checkbox" + i + "</div>").appendTo(document.body) .

Categories : Javascript

Linked Lists in another Linked list
In your function start, you are going through two List of type T. But then, you're concatenating a whole list with a value of the other list, while you're concatenating two lists in your Concat method. Also, you are passing the parameters by copy, which probably not something you want to do. I think what you meant to do is something like that : void Start(List< List <T> > & L, List<T> &NewList) Passing by copy means that your program send a copy of the parameter to your function. It means that the list you pass will be copied (which can be pretty heavy, if your list is big), and that only the copy will be modified. On the new version of the Start function that I gave you, you can notice that I added &. It means that the value is passed by reference. B

Categories : C++

linked list, need to delete all occurences of one given integer in linked list, i am not sure where i am going wrong
Looks like you assign pointers a bit wrong when deleting elements inside collection (not first one). Try to use assignment: trailCurrent.link = current.link; instead of just: trailCurrent = current.link;

Categories : Java

Separate check box out put value to separate textbox
I don't know what you are trying to achieve but when wanting to get the value of checkboxes you can get their values simply for example: <html> <head> <script> function check(id) { if ( document.getElementById(id).checked){ var vl=document.getElementById(id).value; document.getElementById("txt1").value += vl; } } </script> </head> <input type="checkbox" id='1' onClick='check(1)' value="5*7-">5*7 <input type="checkbox" id='2' onClick='check(2)' value="5*8-">5*8 <input type="textbox" id="txt1" name=one> </html>

Categories : PHP

How do I separate the posts in a custom post type WP query into groups of 3, and then separate those groups of 3 into sets of 2?
Try to make increment on inside the while loop , <?php $args = array( 'post_type' => 'portfolio' ); $loop = new WP_Query( $args ); $i = 0; echo'<div id="wrap_6_posts">' . " " . '<div id="wrap_3_posts" class="top-row">' . " "; while ( $loop->have_posts() ) : $loop->the_post(); if ($i % 6 == 0 && $i > 0) { echo '</div>' . " " . '</div>' . " " . '<div id="wrap_6_posts">' . " " . '<div id="wrap_3_posts" class="top-row">' . " "; } else if ($i % 3 == 0 && $i > 0) { echo '</div>' . " " . '<div id="wrap_3_posts" class="bottom-row">' . " "; } echo '<article class="portfolio-post' . ($i % 3 == 0 ? ' first' : '') . '">' . " "; ?> <h2 class="headline portfolio-headlines

Categories : PHP

How do I change a singly-linked list to a doubly-linked list?
You add an extra Node field to each Node that holds its previous Node Insertion Pseudocode: insert(Node n, index i) { currentIndex = 0 currentNode = head while (currentIndex < i) { currentNode = currentNode.next currentIndex++ } n.prev = currentNode n.next = currentNode.next currentNode.next = n }

Categories : Java

Merge two ordered linked lists into one ordered linked list
Since you're checking if the NEXT value is null, when you hit your last value, you'll break out of your merge while loop. Outside of this while loop, you should just append the other list onto the other one. So if List1 runs out of elements and List2 has 3 more, instead of walking through List2, just make (end of List1)->next = (Where you left off in List2). Also, don't return in the merge function. You don't need to. since yoru lists already occupy space, you're just switching around where their pointers are pointing. Once all the pointers are done, just return from the function an access List1/List2 like you normally would (except you need to figure out which List contains the first pointer, so just return 1 or 2) also, you don't ever set merge to a value I don't think

Categories : C

Linked List inside a linked list with templates
There are some issues in your addTeam function: template<class data> void LinkedList<data>::add(data a) { Node<data> *nodePtr; nodePtr=new Node<data>(a); // this should not be necessary, do that in the constructor of Node nodePtr->setNextPointer(0); if(head==0) // if head is empty { head=nodePtr; // make the new node the first node // this is not necessary, nodePtr already has been set up above // not to have a next node // head->setPreviousPointer(0); // make the new node point to null } else { // this check will never fail; what do you want to check here? if(nodePtr==0) // if head is null { last=0; // if list unoccupied _last is null }

Categories : C++

Java linked list within a linked list
What I would do is, instead of having a linked list of linked lists of books, just have a linked list of late books within your user class. Then you can add methods to add/delete books from the list as you see fit. This approach makes more sense to me because the late books are essentially owned by the user, and this way you don't have to keep track of a user's late books by matching indices and tying them to another linked list.

Categories : Java

Insert a linked list into another linked list
You can start like this: node *replaceChar(node *head, char key, char *str) { node *cur, prev; for (cur = head, prev = NULL; cur != NULL; prev = cur, cur = cur->next) if (cur->ch == key) { node *hstart = toString(str); for (node *hend = hstart; hend->next != NULL; hend = hend->next) ; if (prev == NULL) head = hstart; else prev->next = hstart; hend->next = cur->next; free(cur); } } My assumptions: Your node struct is like: sturct node { char ch; struct node* next; }; toString(str) works perfectly fine.

Categories : C

Fragmenting documents
Have to tried writing your documentation in LaTex. In this tool you can write simple scripts or create reusable components, which you can use in other documents too. Here is the link to get more information.

Categories : Misc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.