w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Vertically centering elements using translate percentages
Just make some adjustment to your code and make it happen... Demo:- http://jsfiddle.net/DUdzC/4/ CSS:- #experiment-slide-display { width: 100%; height:100%; top:0; left:0; position:absolute; } #slide { height:20px; top:50%; position: absolute; left:50%; width:200px; margin-left:-100px; margin-top:-10px; text-align:center; } .experiment { position: relative; -webkit-transform: translate(0%,50%); -moz-transform: translate(0%,50%); transform: translate(0%,50%); width:100%; } .experiment-title { position: absolute; top:0; left:0; width:100%; } Thanks hope this works for you...

Categories : HTML

in python, mixin is like composition? then why not just use composition?
(Since mixin doesn't give you is-a relationship, it gives you has-a) Wrong, it does give you a is-a relationship. Consider class C(A, B). issubclass(C, A) is true and so is issubclass(C, B). The call C().method_of_B() calls the method of B if it isn't overridden somewhere in the MRO (which can happen with single inheritance too!), and similarly for methods of A. The attribute access C().attr_of_{a,b} gives you an attribute of A or B too (same caveat as with methods). And I read few times, you should prefer composition over inheritance. This rule of thumb exists because many people tend to use inheritance where it isn't appropriate, not because inheritance isn't a useful tool in any case. This applies to Python too. Common (good) reasons include: A is-a relationship would be w

Categories : Python

XML Parsing, Joining elements in iOS
You would want a function once all of the parsing is done. It doesn't look like you gave us the whole XML file, but I'm assuming that your outer tag is <Fixtures> and your inner tags are <Fixture>. Going off that assumption, you can add a check in parser:didEndElement: -(void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { //... if ([elementName isEqualToString:@"Fixtures"]) { [self saveModesToDatabase]; } } -(void) saveModesToDatabase { NSString* allModes = @""; for (Fixture* aFixture in self.data) { NSString* modeString = [aFixture.ChannelCount stringByAppendingFormat:@" %@", aFixture.Title]; // Don't add a line break if it's the last o

Categories : IOS

Parsing empty XML elements in PHP
The way the code was written originally (without $s in front of each variable) you'd probably be getting errors all day. Hope this helps simplify: $array[] = ''; $elements = array(); $propertyOwner = $report->PropertyProfile->PrimaryOwnerName[0]; $elements[] = $propertyOwner; $propertyAddress = $report->PropertyProfile->SiteAddress[0]; $elements[] = $propertyAddress; //... // IF THEN ELSE $array[] = !empty($elements) ? $elements : 'N/A';

Categories : PHP

Parsing multiple elements with Mechanize
You can use: page.search('meta[@name="DC.creator"]')[1][:content] at is equivalent to search(...).first so using the same selector with search and grabbing the second element found will work as long as there are truly two tags that match. If not, you'll get an exception because you can't take the index of a nil value. And, as a FYI, Mechanize uses Nokogiri internally to handle its HTML parsing and manipulation. Nokogiri supports both CSS and XPath selectors so you can use whichever makes it easier for you to find the tag or element you want. I lean toward CSS for readability, but use both. See the Nokogiri tutorials for more information about searching. require 'nokogiri' doc = Nokogiri::HTML(<<EOT) <meta name='DC.creator' scheme='inventor' content='Chen Yonghong' /> <

Categories : Ruby

parsing nested same name elements using jaxb
May be this could help: JAXB endless data structure, recursive binding? @XmlAccessorType(XmlAccessType.FIELD) // add this to avoid FIELD/METHOD conflicts public class Item { private int id; private String name; @XmlElement(name="item")//There is no need for XmlElementRef private List<Item> items = new ArrayList<Item>(); @XmlAttribute(name = "identifier", required = true) @XmlJavaTypeAdapter(CollapsedStringAdapter.class) @XmlSchemaType(name = "NCName") protected String identifier; @XmlAttribute(name = "identifierref", required = false) @XmlJavaTypeAdapter(CollapsedStringAdapter.class) @XmlSchemaType(name = "NCName") protected String identifierref; @XmlAttribute(name = "isvisible", required = false) protected boolean isv

Categories : Java

Parsing two elements with the same name - Pull Parser
Here is the code with your xml.. import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.annotation.TargetApi; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.util.Log; import

Categories : Java

Parsing string to find email within string via Google Apps Script
While there are numerous solutions to this on SO already, the ones I've found need tweaking to provide the simplicity you're looking for. How to find out emails and names out of a string in javascript Regex for email matching Use javascript to find email address in a string Get all email addresses in a string with JavaScript Many more... Here's a simple function condensed from all those other answers - the regular expression is a bit of overkill, actually, but can also be used to validate in many cases. It returns an array of addresses, so if you only want the first one, you would code email = findEmails(string)[0]... but really, you should do some error checking before trusting that. /** * Return an array of all email addresses found in input string. */ function FindEmails(input) {

Categories : Javascript

Parsing a comma-delimited string that contains string items that contain commas
I'll suggest using strtok using comma as the field separator. However, if the first character in the string is a double quote, you should use " as the field separator. If I assume that what you showed is a struct, I wrote the code in C to print the output on separate lines: #include <stdio.h> #include <string.h> int main() { char str[] = "0,1,"foo","blue,yellow,red",27"; printf ( "Input string: %s ", str ); char * substr; char * str_itr = str; char comma[] = ","; char quote[] = """; substr = strtok ( str_itr, comma ); if ( substr ) printf ( "%s ", substr ); substr = strtok ( NULL, comma ); if ( substr ) printf ( "%s ", substr ); substr = strtok ( NULL, quote ); if ( substr ) printf ( "%s ", substr

Categories : String

Parsing a string returned from ckeditor using javascript string methods
There are two facts that you should know about editor.setData. In some cases it is asynchronous (it depends on the type of editor). That's why it also accepts a callback. Therefore any code that is meant to be executed after setData() should be executed in that callback. It never is asynchronous before editor is ready. In this period (between editor initialization and instanceReady event) it works in a different mode - it just caches the set value and on getData() it returns exactly that value. So, as I see on page load you call synchronously setData() and getData() - your function works because you get the value you're expecting to get. But then, when you try to getData() when editor is already ready you get the HTML parsed, fixed, processed and perhaps differently formatted by CKEdi

Categories : Javascript

XML string to be stored as string in variable without parsing by PHP (xml inside JSON)
Once $v is printed, the browser just interprets the tags. If you don't want things like <span> to be treated as actual HTML, you have to escape the string. The easiest way in PHP is with htmlspecialchars(): <?php $v='<?xml version="1.0" ?><span style="font-size:10px">{point.key}</span><table>'; print htmlspecialchars($v); ?> This will escape all the greater-thans and lesser-thans, etc. and output: &lt;?xml version=&quot;1.0&quot; ?&gt;&lt;span style=&quot;font-size:10px&quot;&gt;{point.key}&lt;/span&gt;&lt;table&gt; which should give you what you want in the browser.

Categories : Xml

Parsing Multiple json elements in python
Seeing how the results field (or key) contains a list structure, you can simply iterate it through like the following json_str = { ...other key-values, "results": [{"listing_id":114179207,"state":"active"},{"listing_id":11344567,"state":"active"}, ...and so on] } results = json_str['results'] # this gives you a list of dicts # iterate through this list for result in results: if result['state'] == 'active': do_something_with( result['listing_id'] else: do_someotherthing_with( result['listing_id'] # or none at all

Categories : Python

Parsing XML elements with dynamic namespace prefix in PHP
You should use DOM - personally I believe this is true for the general case because "simple XML" is an oxymoron, but I know others disagree. It is certainly true when dealing with a complex document tree like SOAP. DOM provides getElementsByTagNameNS() (and other relevant NS-targeting methods) which allow you to specifiy the namespace URI (i.e. the thing that should remain static and be known ahead of time) instead of being specific about the prefix. $soapNsUri = 'http://schemas.xmlsoap.org/soap/envelope/'; $myNsUri = 'http://xyz.gov/headerschema'; $doc = new DOMDocument; $doc->loadXML($myRequest); $header = $doc->getElementsByTagNameNS($soapNsUri, 'Header')->item(0); $myHeader = $header->getElementsByTagNameNS($myNsUri, 'myHeader')->item(0); $sourceID = $myHeader->ge

Categories : PHP

Parsing with NSXML parser to same roots elements
You could check for the existence of TotalRecords: -(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ if ([elementName isEqualToString:@"News"]) { NSString *totalRecords = attributeDict[@"TotalRecords"]; if (totalRecords) { app.listArray = [[NSMutableArray alloc] init]; } else { theList = [[List alloc] init]; theList.ThumbImageURL = [attributeDict objectForKey:@"HeadlineImgSrc"]; theList.Title = [attributeDict objectForKey:@"Title"]; theList.URL = [attributeDict objectForKey:@"DateTime"]; [app.listArray addObject:theList]

Categories : Objective C

String gsub - Replace characters between two elements, but leave surrounding elements
You can do it using this character class : [^/] (all that is not a slash) and lookarounds mystring.gsub(/(?<=start/)[^/]+(?=/end)/,"7")

Categories : Ruby

Php parsing table does not return the full list of elements
Actually your data is right. But there is jquery sorting on page loaded. Just different player row places. I copied HTML codes and removed js files, last player was RAMSEY, Aaron

Categories : PHP

Making a List in C# with three flexible elements in one datatype
If you're asking for the syntax to initialize a list with multiple elements at once, then: var l = new List<string>{ "string1", "string2", "string3" .... }; If you are looking for a way to hold three strings in a single list-item, without using Tuples or custom classes, there's no way to do that, I'm afraid. EDIT: Unless you're generating strings - in which case you could generate them in an annonymous type, such as: Enumerable .Range(1, 100) .Select(i => new { string1 = "string1" + i, string2 = "string2" + i, string3 = "string3" + i }); But that's really weird. Also, you could use a list of Lists, such as: var l = new List<List<string>> { new List<string> { "string 1", "string 2", "string 3" }, new

Categories : C#

GORM Composition save error, Could not find matching constructor for: java.lang.String(java.lang.Long)
Not sure how complete your example code above is, but I see a couple of things which may or may not be causing the exception you're seeing. def securityService (in Reservation) should be transient so gorm doesn't try to persist. BTW - did you mean springSecurityService UPDATE: just realize you've declared them as Strings I don't think you can set dates directly like that, you need to parse the String for example Date().parse("yyyy-MM-dd", '2013-07-23')) if you're using GORM autoTimestamp, the lastUpdated field should be a Date not String - otherwise you should disable it if you're not using it finally, is Reservation mapped to a legacy database - is there a reason to have String reservationId vs. default id provide by GORM?

Categories : Grails

How to add elements from sublists with 2 elements (the first element is a string and the second one a number)?
You just need to break out the string versus the number: sum_fire( [[_,N]|Tail], Sum ) :- sum_fire( Tail, S1 ), Sum is N + S1. sum_fire( [], 0 ). So I'm using [_,N] instead of H for the head item because I want what's inside (the number N). I don't care about the string for the sum, so it's _.

Categories : Prolog

Parsing differently named elements as a single list using SIMPLE XML library for android
As ng said before: Use a Converter for this. Simple is brilliant in letting you customize every step of processing (while on the other hand it's possible to let you (de-)serialize even complex structures with some lines of code). So here's an example: A Class that will hold the values from the list: @Root(name = "example") @Convert(value = ListConverter.class) // Specify the Converter that's used for this class public class Example { // This element will be set with the values from 'box-headers' element @ElementList(name = "box-headers") private List<String> values; // This constructor is used to set the values while de-serializing // You can also use setters instead Example(List<String> values) { this.values = values; } //... }

Categories : Java

Error parsing XML, The content of elements must consist of well-formed character data or markup
It looks like you're trying to use a template like in: https://www.blogit.com/Blogs/Help/HelpPage.aspx?page=templatedesign The <$BlogDateHeaderDate$> bit will be replaced by a string like Monday, August 26, 2002. Is this Monday... acceptable text in your template? In your sample you've included two closing tags, but no opening tags.. A complete, basic template would look like: <BlogTemplate> <BlogDateHeader> <$BlogDateHeaderDate$> </BlogDateHeader> <PostSubject> <$BlogItemSubject$ > </PostSubject> <$BlogItemBody$> <$BlogItemAuthor$> <$BlogItemAuthorNickname$> <$BlogItemAuthorEmail$> <$BlogItemAuthorURL$> <$BlogItemDateTime$> <

Categories : Xml

Titanium -> New Alloy Controller
If you look in this link you should be able to see several sample apps. These should help you get started. I have used this and the alloy documentation on their website to get started with Titanium. Hope this helps!

Categories : Osx

Titanium Alloy using jquery
Practically no, but technically yes. No, you can't use it in the bulk of your Titanium code because jQuery requires a DOM and Titanium does not create web-based apps, so there is not DOM. That's why DOM-less helpers like underscore.js are encouraged. That said... Yes, you can use jQuery inside a Ti.UI.WebView in Titanium. As the webviews indeed have a DOM, they can be used in the web-based code contained in the webview.

Categories : Misc

threading in titanium without alloy
setInterval should do it: function updateView() { //your update code } setInterval(function() { updateView(); }, 10000); What is the titanium log error when your app crashes? It might be because of something other than the setInterval.

Categories : Javascript

Titanium Alloy MArkup
You support multiple devices with different screen sizes with the way that you design your app. By using the TSS stylesheets (similar to CSS) you set the look and feel for the formfactor (iPhone, iPad, Android, web, Blackberry, tizen). Android requires a lot more images in the assets folder for the resolution of the splash screen so keeping that in mind when you have your images that you want to use in your app remember to GO BIG! You can scale it down within the app. Don't use images that will work on your phone and when displayed on an android tablet they look like tiny icons. I've been using Titanium for almost a year now and it's just gotten better and better! Without knowing an exact problem it would be hard to answer but you probably need to set your width or height to Ti.UI.FILL

Categories : Misc

org.xmlGetting exception while parsing XML.sax.SAXParseException: The content of elements must consist of well-formed character data or markup
Your XML is invalid row-->Parent-->Child-->Child 1 You cannot have space in XML element name. Your xml element name Child 1 is having a space. XML elements name must follow these naming rules..... Names can contain letters, numbers, and other characters Names cannot start with a number or punctuation character Names cannot start with the letters xml (or XML, or Xml, etc) Names cannot contain spaces

Categories : Java

Liferay Date picker using alloy ui
You can use 'dates' attribute for setting date AUI().use('aui-datepicker', function(A) { var dataInizioDatepicker = new A.DatePicker({ trigger: '#<portlet:namespace />dataInizio', calendar: { dates: [ '${campagna.date}' ], dateFormat: '%m/%d/%Y' } }).render('##<portlet:namespace />dataInizioPicker');

Categories : Java

Alloy.UI not working with JQuery.html
<aui:input> is jsp code, not HTML. You can't use newTextBoxDiv.html('<aui:input type="text" name="textbox' + counter + '" id="textbox' + counter + '" value="" />'); because your browser will not know what to do with it. Keep in mind that jQuery is purely javascript, while AUI combines javascript, components (e.g. DOM classes, CSS) and java JSP support. The <aui:input> and related tags are processed when the page renders (server side) and produce their output. You'd have to either use that output in your dynamically rendered HTML or save the content in a temporary variable, e.g. through the use of the <liferay-util:buffer> tag. Careful: In order to use this result from javascript, you'll have to escape the result properly

Categories : Jquery

Getting ID of clicked TableRow in Titanium Alloy?
Do something like this function rowClick(e) { alert(e.rowData); }; you could aslo get the index as follows function rowClick(e) { alert(e.index); }; Thanks

Categories : Backbone Js

override get method in Alloy model
Here is how i am overriding the set and add methods hope it helps you: exports.definition = { config: { adapter: { type: "properties", collection_name: "careCenter", idAttribute : "CareCenterID" } }, extendModel: function(Model) { _.extend(Model.prototype, { idAttribute : "CareCenterID" // extended functions and properties go here }); return Model; }, extendCollection: function(Collection) { _.extend(Collection.prototype, { add : function(attrs, opts){ var isDuplicated = false; if(attrs && attrs.get){ isDuplicated = this.any(function(model){ retur

Categories : Backbone Js

Filtering a collection in Titanium Alloy
the where function returns an array of models, if does not update the actual collection http://backbonejs.org/#Collection-where var filteredArray = messages.where({convo_id: args.convoId});

Categories : Backbone Js

How to load an Alloy project in Titanium?
If you are using Github and you are using titanium Studio there is a option to import Github projects to your workspace, You just go to File->Import->Git->Git Repository as New Project then you can select the url and copy the Git Repository url from here: Then you click finish in Titanium Studio and that's it. If this is not the answer, then in the repository you can search for the missing files, like tiapp.xml is in the main folder with the manifest and README files.

Categories : Github

Alloy Back Activity in Titanium
Write this piece of code when the window loads: win.addEventListener('android:back', function(e) { console.log("Pressing Back Will Not Close The Activity/Window"); win.close(); });

Categories : Javascript

Adding elements to string array String[] and testing the results in Junit
In your add function, you have the following if-condition: if (getCurrentSize() >= count) { where count is originally 0, and getCurrentSize() returns the value of num (which is 4). The thing is, when you insert the fifth time, count is 4, and this statement evaluates to true. If you want it to fail the fifth time, you need a > instead of a >= (so that when count is 4, it'll evaluate to false) When you change num to 5, the original statement is true (since 5 >= 4), and so the fifth insert succeeds. Side note: Your add function as is (when num is 4) ought to be throwing a IndexOutOfBoundsException right as it tries to insert the fifth time. The fix will also resolve this issue (since you won't be trying to add to thisBag[num], which is one off the end of the array). Again, w

Categories : Java

Titanium Alloy MVC framework--"Model" query
I suggest that you contact the person who wrote the sync adapter that you are using since the functionality described in the code sample is not part of the base Alloy Framework. I would also take a look at some backbonejs documentation on Models and collections to understand that functionality. finally without providing the source code or reference to the sync adapter, it will be really difficult to provide additional information.

Categories : Javascript

Parsing string in C++
You can use boost::split function (or boost::tokenizer) for this purpose. It will split string into vector<string>. std::string line; std::vector<std::string> results; boost::split(results, line, boost::is_any_of(",")); std::string state = results[3];

Categories : C++

string parsing for C++
It's hard to tell from your question what you mean by "position", but it looks like you are trying to do something like this: #include <fstream> #include <iostream> int main() { std::ifstream incoming{"string-parsing-for-c.txt"}; std::string const hash{"#"}; std::string line; for (auto line_number = 0U; std::getline(incoming, line); ++line_number) { auto const column = line.find(hash); if (std::string::npos != column) { std::cout << hash << " found on line " << line_number << " in column " << column << ". "; } } } ...or possibly this: #include <fstream> #include <iostream> int main() { std::ifstream incoming{"string-parsing-for-c

Categories : C++

How to fix parsing int from string?
The second parameter isn't a index but a count. So you should do something like this: // because, you don't want the [, you'll add 1 to the index, int index1 = s.IndexOf("[") + 1; int index2 = s.IndexOf("%"); string outp = s.Substring(index1, index2 - index1);

Categories : C#

Parsing a String [] of csv's
All you really need to do is split the strings and parse to int. List<Integer> ints = new ArrayList<Integer>(); // For each element in jobs array for (int i = 0; i < jobs.length; i++) // For each csv in current element for (String s : jobs[i].split(",")) ints.add(Integer.parseInt(s)); // parse and add to ints for (int i : ints) System.out.println(i);

Categories : Java

Percentages in PHP
$discount = 15; $price = 70.40; $newPrice = $price * (100 - $discount) / 100; If your $discount would be a percentage (between 0 and 1) it would be: $discount = 0.15; $price = 70.40; $newPrice = $price * (1 - $discount);

Categories : PHP



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