w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Load only part of Ravendb document array item
If the only difference between products is the translations, I would go with a different model. The product document would have categoryId, price and all the rest of the product info. Assuming a product is saved under products/1, you can then save additional documents under IDs like products/1/en, products/1/es etc and store the translated strings there. You can then use ResultTransformers to inject the translated strings into the end result of queries.

Categories : Dotnet

Store new document to specific collection in RavenDB via REST
While metadata is returned in the @metadata section, that's not how you send it in. That's because you don't have control over every metadata value. For example, passing in an etag wouldn't make sense. Instead, for the metadata values you can control, send them in the HTTP headers. $headers = @{"Raven-Entity-Name"="Entries"} Invoke-RestMethod -Headers $headers ...

Categories : Powershell

RavenDB get ID of newly stored document
The Id property of the Product class must be of type string instead of integer. Then you will be able to retrieve the autogenerated id after the operation: Product p = new Product() { Title = "My Fancy Product" }; RavenSession.Store(p); string id = p.Id; More information can be found in the documentation (Document IDs section): In the example above we had a string Id property for BlogPost, and left it blank. It is this property that will be used as the "primary key" for this document. Note how RavenDB generated an ID for us, "BlogPosts/1", based on the default convention which we will discuss in a second. If there is no Id property on a document, RavenDB will still generate a unique ID, but it will be retrievable only by calling session.Advanced.GetDocumentId(objec

Categories : C#

RavenDB - wait for document creation
Well, I'm not sure what mechanism you are using for event processing, but I have been in a similar situation with something like NServiceBus. I don't think this exactly a RavenDB problem. You would probably have the same issue if you were writing to a SQL Server database. The generalized problem is, Create and Update events are fired off, but they are received and processed in the wrong order. What to do? Well the general advice is that your event handlers should be idempotent, and should retry when failed. So if Update is received first, it will throw an exception and be scheduled for retry. Then Create comes through, then Update retries and all is good. Specifically blocking and waiting in the handler for the Update event is not advised, because if you had several of these then t

Categories : C#

separate chinese part and english part from a text document
You can do with regex, the part that validate the pattern with alphabetic english character go to a part, and the part that dont validate to the other part. I supose that the two parts are in different parts (not mixing both partd), perhaps if they are mixed you could have the problem of the common characters (, . ? etc...), perhaps for this characters you could see the before and the next character. I think that this can be a possibility probably there are best ways to do that. Edit: I supose that is a txt, but in another format only pass to txt before.

Categories : Java

RavenDB namespace change on document object throws "Unable to cast object" Error
Putting aside the rename and what might have worked before, the error matches the query you are attempting. You are indexing documents of type RewardProviderLog, and retrieving them directly as type ImportMonitorViewModel. You say all of the properties are the same in both classes, but that alone won't get RavenDB to duck-type them for you. You have to be a little more explicit. This will probably work: model = (from log in session.Query<RewardProviderLog>("ImportMonitorLogs") orderby log.lastRun descending select log).As<ViewModels.ImportMonitorViewModel>().ToList(); Or if you want slightly cleaner syntax (IMHO), this is equivalent: model = session.Query<RewardProviderLog>("ImportMonitorLogs") .OrderByDescending(x=> x.lastRun)

Categories : C#

In PHP MVC, in which part do I interact with an excel document?
an excel document contains bussiness logic. so definetly a Model. short explenation. each excel document represents a entity of some sort. on each entity you want to perform the same logic.

Categories : PHP

Show only part of document in editor
You might try the Eclipse folding plugin at: http://kosiara87.blogspot.com/2011/12/how-to-install-coffee-bytes-plugin-in.html With a download at: http://sites.google.com/site/bkosarzyckistorage1/eclipse-folding-plugin.tar.gz It lets you define identifiers for start and end region, and then put them in your document to control visibility by region (apparently line based, rather than finer-grained, but that what most people tend to want). In the "User Defined Regions" tab use e.g.: Start identifier: region End identifier: endregion In code: //region SomeName your code //endregion SomeName There's a thread on this in What code folding plugins work on Eclipse 3.6? I haven't used it myself but it might fit your needs. It might also be incompatible with current versions of Eclips

Categories : Eclipse

Can I'm get part of mongo document by find conditions?
You can't do this with simple find, but you can use aggregation framework: db.<coll>.aggregate({$match:{"name" : "John"}}, {$unwind:"$phones"}, {$match:{"phones.type":'mobile'}}) where is your collections with phones UPD Thank to @asya-kamsky for information. Here is version with $elemMatch, but I don't want to steal your opportunity to think by yourself. I made a spoiler, if you totally lost with this question:

Categories : Mongodb

Jquery keypress event applied to part of document
You could check to see if any element on the page has focus and, if it does, prevent the function from firing. http://api.jquery.com/focus/

Categories : Jquery

Read specific part of an INI file C#
and i know im using the INI file not properly but this is the easist way. I think that this is NOT the easiest way, try something already implemented: GetPrivateProfileSection. There are 2 useful windows API to read/write ini files: GetPrivateProfileString WriteProfileString check them out!

Categories : C#

Need a specific part of a user input
This code should do the same: var inPar = userIn.replace(/^.*((.*)).*$/, '$1'); I don't understand much about chemical formulas, so I don't know what a more dynamic approach should look like. Sorry.

Categories : Javascript

Click on a specific part of an ImageView
OK I resolved my problem by using this sample : https://github.com/chrisbanes/PhotoView/blob/master/sample/src/uk/co/senab/photoview/sample/SimpleSampleActivity.java I can now zoom and touch/detect specific parts of the screen. It works very well !

Categories : Misc

Get the last character before a specific part of string in PHP
If you have the position of matched needle, you just have to substract - 1 to get the character before that. If the position is -1 or 0, there's no character before. function char_before($haystack, $needle) { // get index of needle $p = strpos($haystack, $needle); // needle not found or at the beginning if($p <= 0) return false; // get character before needle return substr($hackstack, $p - 1, 1); } Implementation: $test1 = 'this is a test'; $test2 = 'is this a test?'; if(char_before($test1, 'is') === ' ') // true if(char_before($test2, 'is') === ' ') // false PS. I tactically refused to use a regular expression because they are too slow.

Categories : PHP

updating a file in specific part only in php
In case if file is relatively small (easily fits in memory), you can use file() function. It will return array, which you can iterate, etc. If the file is larger, you'll need to read it in the loop using fgets(), writing data to the new temporary file and replacing original file with it after you're done

Categories : PHP

preg_replace() Only Specific Part Of String
You could do this with a simple string replace: $image[0] = str_replace('/wp-content/uploads/', '/', $image[0]); Or if you want to use a regular expression: $image[0] = preg_replace('~(http://.*?)/wp-content/uploads/(.*)~', '$1/$2', $image[0]);

Categories : PHP

Parsing specific part of XML file
Since you never declare the namespace (xmlns:gpxtpx="http://www.topografix.com/GPX/1/1") it is never going to match. The xml fragment you provided is not well formed due to the lack of the namespace. If the fragment posted is snipped from a larger document, consider switching to XML API's rather than string manipulation. If that is the entirety of the XML you receive from an outside system, add it to a root node which you can declare the schema in: <root xmlns:gpxtpx="http://www.topografix.com/GPX/1/1"> <!-- put your xml fragment here --> </root>

Categories : C#

How Do I Get The Specific Part For Each Email Using imap_fetchstructure()
I have found this which does an amazing job at solving this issue: http://www.electrictoolbox.com/php-imap-message-body-attachments/

Categories : PHP

Get a specific value in an xml document with c#
Try to use LINQ to XML, it's very straightforward. Example is given below: var doc = XDocument.Parse(xml); //use XDocument.Load if you have path to a file string minSell = doc.Descendants("sell") .First() .Element("min") .Value; Console.WriteLine(minSell); //prints 166.22

Categories : C#

Is it possible to make a picture of a specific part of your website?
Not sure how this plays out, but you may be able to take advantage of the <canvas> element and draw the <div> there. Then canvas has export options to convert to jpg, png, etc.

Categories : Javascript

Can I change specific part of data in cookie
The answer is yes, it is possible. You can simply read the JSON string, call $.parseJSON(string) to get it back as an object, change the property you want and save it again with JSON.stringify(object);

Categories : Json

Read a specific part of an HTML file
That depends on what you mean by "part". The most usefull approaches: If you know a unique string that starts and finishes that part, e.g. and , you can load the complete file into a string, search the occurence of the first string, search the occurnece of the second one, then take the substring inbetween. If you have less information, you might need regex. If your HTML is valid XML, load it into an xml object and use xpath or alike... you see, the answer much depends on what you have, and what you want to achieve.

Categories : PHP

Read a specific part of a txt file for each line
You can do this with a simple perl script. For windows, perl can be downloaded from activestate. Linux usually already has perl installed. To use: install (or already have) perl copy the script below into a text file Save the file using a simple name of your choice with an extension of .pl (ex: parser.pl) Save the source file into the same directory and name it 'input.txt' From a cmd window execute: perl parser.pl The results of the script will be created in a file called 'output.txt' (in the same directory) and if the file exists will be overwritten. The script assumes that: the text your looking for starts with Man or Woman the ENG text does not appear in the text you are looking for, only at the end. the language text is always ENG. IF not replace ENG with (?:ENG|OTHER1|OTHER

Categories : Misc

How To write to a specific part of a text file c#
Just right-pad the parts to be the correct length (make sure it is not longer, and decide what to do if that occurs). Concatenate the parts and write it as a singe line.

Categories : C#

Extracting a specific part of a URL using regex in JavaScript
no need for regex, just split it var link = "http://www.test.com/abc/hhhhhh/a458/example"; var linkParts = link.split("/"); //If the link is always in that format then a458 or whatever //would replace it will be in index 5 console.log(linkParts[5]);

Categories : Javascript

Delegate specific part of build to slave
Delegating part of a job to a slave is something that would have to be done external to Jenkins, for example, using ssh. However, as @kan indicates, you most likely want to extract the native library build as a separate job and then have that job execute on a particular slave, or any slave that meets a specific criteria. To do this, my suggestion would be to use Labels in the node configurations to determine which slaves can be used for building that particular job. In Jenkins > nodes > <slave node>, use the Labels property to set one-word labels that indicate your specific requirements, such as the OS or processor type. Then, in the jobs that are node-specific, check Restrict where this project can be run and set the Label Expression to something that meets your criteria.

Categories : Jenkins

Detecting specific rectangular part of the image
Try to add one pre-processing step to enhance contrast by histogram equalization (remember that you first need to convert the color to one domain that luminance component is separated from color, then you equalize that luminace component), you can also use one clustering algoritm to make that work for you, but, keep in mind that image pre-processing is essential to have good results. BTW, you can train one correlation filter to detect these rectangles (for example MACE).

Categories : C++

How to remove the specific part of UIScrollview in objective c
UIScrollview is basically a canvas to add content such that you put it inside and set the scroll area it will show the content and scrolls to the size defined. Considering that fact itself the delete can be considered as "Removing the contents from the scroll view." So what you can try out is to look forward and put all the content that must be removed to a single place holder view and remove the view accordingly.

Categories : IOS

Jump to a specific view, which is already part of the storyboard, programatically
You can do this with segue. First, in your storyboard, "control + drag" from the presenting view controller (the "self" in your code) to your destination controller (your GalleryViewController). This segue is not associated with any subview or widget. Second, in the attribute inspector, give it a name "ToGalleryVCSegue", and set the type to "Modal". Last, in the code, simply do: [self performSegueWithIdentifier: @"ToGalleryVCSegue" sender: self];

Categories : IOS

Hide a div that is part of all pages on one specific wordpress page
It'd help to have a link to the page or a more detailed example of its HTML source, but what seems probable is that the element you want to hide isn't a direct child of the body element, in which case the selector given in your CSS excerpt won't address it properly. Instead, try: body.page-id-46 * #static-footer-image { display: none; } which will address an element of ID static-footer-image which is anywhere under the body element, instead of having to be a direct descendant (i.e., <body>...<div id="static-footer-image"></div>...</body>).

Categories : PHP

How to delete a specific part of an html file in Python
Simply use string methods to split the html text and take the first part; str.partition() works much simpler: file.partition('Item&nbsp;2')[0] If you wanted to keep the Item&nbsp;2 text too, use: ''.join(file.partition('Item&nbsp;2')[:2]) There is no need to use a regular expression here; you are matching literal text. Regular expressions is a wonderfully expressive and powerfool tool, but don't use it if there are simpler alternatives. Demo: >>> 'Some text with Item&nbsp;2 in it'.partition('Item&nbsp;2')[0] 'Some text with ' >>> ''.join('Some text with Item&nbsp;2 in it'.partition('Item&nbsp;2')[:2]) 'Some text with Item&nbsp;2'

Categories : Python

to select cell with specific part with disclosure button
If you are not using any background Image for your TableViewCell than use this delegate method of UITableView: - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor = [UIColor redColor]; } If you are using background Image for your TableViewCell than use this in cellForRowAtIndexPath: UIImageView *selBGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage.png"]]; cell.selectedBackgroundView = selBGView; And for the position of discloser button you have to set autoResize property from IB file

Categories : Iphone

how to eliminate an specific part of html file in python
I'd use BeautifulSoup to parse the HTML and modify it. You might want to use the decompose() or extract() method. BeautifulSoup is nice because it's pretty good at parsing malformed HTML. For your specific example: >>> import bs4 >>> text = """<A href="#106">Item&nbsp;2. <B>Item&nbsp;2. Properties</B> this is an example this is an example""" >>> soup = bs4.BeautifulSoup(text) >>> soup.b.next_sibling.extract() u' this is an example this is an example' >>> soup <html><body><a href="#106">Item 2. <b>Item 2. Properties</b></a></body></html> If you really wanna use regular expressions, a non-greedy regex would work for your example: >>> import re >>> t

Categories : Python

Java add line to specific part of text file
You want a do-while loop: do { //code } while (expression); Source: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html You probably want something like this: int[] done = new int[100]; int randomquestion; do{ randomquestion = (int)(Math.random() * 83 + 1); if(done[randomquestion] != 1) { //ask random question //if answer is correct, set done[randomquestion] = 1 //else just let do-while loop run } //check if all questions are answered } while (!areAllQuestionsComplete(done)); Here is the method areAllQuestionsComplete(int[]): private boolean areAllQuestionsComplete(int[] list) { for(int i = 0; i<list.length; i++) { if(list[i] != 1) { return false;//found one false, then all fals

Categories : Java

Wrap specific part of string with HTML element
Easiest way to achieve this is: $('h1').each(function (_, el) { var $this = $(el); var h1Content = $this.html(); $this.html(h1Content.replace(/(d+)/, '<span>$1</span>')); }); This assumes you want the first number. DEMO

Categories : Javascript

How do I replace only a specific value in an XML document without changing anything else?
Given your xml is in the string messageToSantise, you can try the following: Using XmlDocument: (classic XML parsing common in older versions of the framework, and your only choice on older versions) XmlDocument messageDoc = new XmlDocument(); messageDoc.Load(messageToSanitise); messageDoc.SelectSingleNode(path_to_node).Value = replacementValue path_to_node can be used with the appropriate XPath expression. To get the xml string back out of the XmlDocument, use the messageDoc.OuterXml property. string messageToLog = messageDoc.OuterXml; Using XDocument: (xml parsing via a LINQ style mechanism, supported in new versions of the framework) XDocument messageDocument = new XDocument(); messageDocument.Parse(messageToSanitise); messageDocument.Element(path_to_element).value = repla

Categories : C#

Find document with array that contains a specific value
As favouriteFoods is a simple array of strings, you can just query that field directly: PersonModel.find({ favouriteFoods: "sushi" }, ...); But I'd also recommend making the string array explicit in your schema: person = { name : String, favouriteFoods : [String] }

Categories : Mongodb

Change color of specific part of DataGridView or entire column in C#
You can set the row colour by setting DefaultCellStyle property. In the following example we are iterating through each row and checking cell[0] value and if the condition is true then setting the row backcolor and forecolor foreach (DataGridViewRow row in mydataGridView.Rows) { string RowType = row.Cells[0].Value.ToString(); if (RowType == "Some Value") { row.DefaultCellStyle.BackColor = Color.Green; row.DefaultCellStyle.ForeColor = Color.Green; } }

Categories : C#

MySQL replace final part of a string after specific character
You can combine MySQL's TRIM() and SUBSTRING_INDEX() functions: SELECT TRIM(TRAILING SUBSTRING_INDEX(path, '/', -1) FROM path) FROM my_table See it on sqlfiddle.

Categories : Mysql

Getting and setting the value of a specific part of a large multi-dimensional array
Probably you're better off using a multidimensional array: int[, ,] a = new int[2, 2, 3]{ { {1,2,3}, {4,5,6} }, { {7,8,9}, {10,11,12} } }; int x = (int)a.GetValue(0,1,2); // this returns 6 int[] nArray = new int[] { 1, 1, 0 }; x = (int)a.GetValue(nArray); // this returns 10

Categories : C#



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