pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
28,843,910
0
<p>Basically, in mathematics, there is a concept of "<a href="http://en.wikipedia.org/wiki/Lebesgue_measure" rel="nofollow">Lebesgue Measure</a>". This assigns values to length, area, volume, etc. by manipulating the interval <code>[0,1]</code>.</p> <p>Here's an intituitive explanation. A point at <code>x</code> can be represented as a limiting case of the interval <code>[x,x+h]</code> as <code>h</code> approaches <code>0</code>. The measure of the point, <code>(x+h) - x = h</code> as <code>h</code> approaches <code>0</code> is therefore <code>0</code>.</p> <p>However, if we take a line segment--say, <code>[0,1]</code>--and decompose it into <code>n</code> intervals <code>I[k]</code> with <code>k</code> being over the integers from <code>0</code> to <code>n-1</code>, each will take the form <code>I[k] = [k/n, k/n + 1/n)]</code>. If we let <code>n</code> go to infinity, each of the <code>I[k]</code> can be modeled as a point because <code>1/n</code> is approaching <code>0</code>. If we take the measure of each point, we get <code>1/n</code> as <code>n</code> approaches infinity, or zero. On the other hand, if we sum the measures of the points, we get <code>1/n * n = 1</code>, the measure of <code>[0,1]</code>.</p>
32,009,931
0
How to update message components associated with <p:commandButton ajax="false">? <p>I need your assistant in updating the <code>&lt;p:message&gt;</code> component in a JSF page once the non-ajax <code>&lt;p:commandButton&gt;</code> is clicked. Currently in the case, I need to validate if the employee number is null, then show the error message in the message component, else, nothing to be shown. But now,the form is not showing anything once the <code>&lt;p:commandButton&gt;</code> is clicked.</p> <p>Below is the JSF code:</p> <pre><code>&lt;h:form id="form"&gt; &lt;p:inputText value="#{pdf.refNo}"/&gt; &lt;p:message id="message" for=":form:cmd2" showDetail="true"/&gt; &lt;p:commandButton id="cmd2" value="Validate" ajax="false" actionListener="#{pdf.validate}"/&gt; &lt;/h:form&gt; </code></pre> <p>And the Java bean is:</p> <pre><code>public void validate() { if (refNo.equals("") || refNo == null) { FacesContext.getCurrentInstance().addMessage(":form:cmd2", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error!", "Please enter the Employee No.")); } } </code></pre> <p>So is the above code is correct and how to show the message once the button is clicked?</p>
217,275
0
<p>Use <code>==</code> on objects to perform identity comparison.</p> <p>That is what the default implementation of <code>equals()</code> does, but one normally overrides <code>equals()</code> to serve as an "equivalent content" check.</p>
14,192,355
0
<p>As already mentioned, you can instruct <code>RAND</code> to generate numbers directly as single precision, and it's definitely best to generate the numbers in a decent sized chunk. If you still need more performance, and you have Parallel Computing Toolbox and a supported NVIDIA GPU, the <code>gpuArray.rand</code> function can be even faster, especially if you select the philox generator like so:</p> <pre><code>parallel.gpu.RandStream('Philox4x32-10') </code></pre>
21,486,408
0
How to merge xml app.config files outside of the build process <p>I would like to use app.config files for settings, but I don't want to have to select different build configurations to select which settings to use, I would rather everything build in release and then just the app.config file be different when the application is deployed.</p> <p>What is a good way to merge two xml files together so that I can deploy the correct settings to the correct environment? I have found several solutions that are based on selecting different build configurations and the transform happens at build time, but I want the transform to just be from a command line utility that my deploy script can run</p>
26,002,460
0
<p>I would not have them answer "Yes" then type in the new value. Just have them type in the new value if they want one, or leave it blank to accept the default.</p> <p>This little function lets you set multiple variables in one call:</p> <pre><code>function confirm() { echo "Confirming values for several variables." for var; do read -p "$var = ${!var} ... leave blank to accept or enter a new value: " case $REPLY in "") # empty use default ;; *) # not empty, set the variable using printf -v printf -v "$var" "$REPLY" ;; esac done } </code></pre> <p>Used like so:</p> <pre><code>$ foo='foo_default_value' $ bar='default_for_bar' $ confirm foo bar Confirming values for several variables. foo = foo_default_value ... leave blank to accept or enter a new value: bar bar = default_for_bar ... leave blank to accept or enter a new value: foo=[bar], bar=[default_for_bar] </code></pre> <p>Of course, if blank can be a default, then you would need to account for that, like @jm666 use of <code>read -i</code>.</p>
8,190,868
0
<p>I am using the same book and had the same issue, I remove Ruby 1.9.3-p0 and install Ruby 1.9.2-p290, it is working now</p>
23,967,955
0
<p>use the following function</p> <pre><code>left(@test, charindex('/', @test) - 2) </code></pre>
3,562,303
0
<p>To hav transparency, you need an alpha channel, on your texture, but more important, in your framebuffer. This is done with SDL_GL_SetAttribute, for example:</p> <pre><code>SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); </code></pre> <p>This will request a framebuffer with at least those sizes, and you'll be able to use blending. Remember to enable blending and set a blending function.</p>
19,209,924
0
<p>I have been working on a vim plugin for android development: <a href="https://github.com/hsanson/vim-android" rel="nofollow">https://github.com/hsanson/vim-android</a>. Still work in progress but it has most functionality needed for android development using vim.</p> <p>I still have some issues to solve but most are not related to the plugin:</p> <ul> <li>Gradle errors from aapt report the wrong file. This makes jumping to the error from the quickfix window a pain as it opens the wrong file.</li> <li>I cannot make javacomplete work correctly. When auto completing a class I wrote it gets stuck in "Searching..." and when auto completing a library or external JAR method javacomplete spits hundreds of errors making it impossible to use.</li> </ul>
39,262,726
0
<p><strong>XLS</strong> is either a typo for <strong>XSL</strong> or a reference to Microsoft's <a href="https://products.office.com/en-us/excel" rel="nofollow">Excel</a> spreadsheet <a href="https://en.wikipedia.org/wiki/Microsoft_Excel#File_formats" rel="nofollow">format</a>.</p> <p><strong>XSL</strong> <a href="https://www.w3.org/Style/XSL/" rel="nofollow">refers</a> to a family of W3C recommendations related to XML transformation and presentation:</p> <ul> <li><strong><a href="https://www.w3.org/TR/xslt" rel="nofollow">XSLT</a></strong>: A language for transforming XML documents.</li> <li><strong><a href="https://www.w3.org/TR/xpath/" rel="nofollow">XPath</a></strong>: A language for addressing parts of an XML document.</li> <li><strong><a href="https://www.w3.org/TR/xsl/" rel="nofollow">XSL-FO</a></strong>: An XML vocabulary for specifying formatting.</li> </ul>
36,605,426
0
<blockquote> <p>So, if now i need to make a ssl request i will have to use HttpsURLConnection (?) and create a request.</p> <p>My question is -How does HttpsURLConnection know about the encryption algorithm and then encrypts using that?</p> </blockquote> <p>Yes you have to use HttpsURLConnection. But you dont have to do it explicitly. <code>new URL("https://google.pl").openConnection();</code> is more then enough.</p> <p>In Server Hello, server anounces what encrypiton it can accept. All encryption methods have to "announce" themselves so the server knows how to interpret them. So when you initiatle the connection, servers says what it can handle, client choose one of the cipers and ciper the data using it. At the beginning of the connection, client announces what suite will it use.</p> <p>This information can be public to this is not a problem that this is sent as plaintext. The point is, to exchange the symetric key between client in server in private way, so the rest of communication can be ciphered usint that key.</p> <blockquote> <p>How is session maintained? How does HttpsURLConnection know that this connection has already been initiated and handshake procedures have already been completed?</p> </blockquote> <p>Well SSL stands for Secure Socket Layer. It means that data transmit and received is ciphered, decrypted on raw socket(streams) level; You can open SSL connection to transmit data from point to point not only via Https</p> <p>There is no "session". As long as you open a connection, you got 2 streams. Input and Output. As long as those are open, you can write data or read from them. Once they are closed, you will have to initiate another connection.</p> <p>Every Http request is a new connection (unless Keep-Alive is sent). JsessionId for example, or php's sessionid is to identity that you are the same client that made requests earlier so it can "simulate" constant connection.</p>
10,038,683
0
<p>I got some tips from the internet, and following is the steps to get iOS acceptable p12 key and certification file:</p> <ol> <li><p>convert XML to PEM<br> Shell> compile XMLSpec2PEM.java<br> Shell> XMLSpec2PEM rsa.xml<br> save the output result to rsa.pem<br> (borrow from <a href="http://www.platanus.cz/blog/converting-rsa-xml-key-to-pem" rel="nofollow">here</a>)</p></li> <li><p>convert PEM to RSA Private Key<br> OpenSSL> rsa -in rsa.pem -out rsaPrivate.key</p></li> <li><p>Generate a certification request<br> OpenSSL> req -new -key rsaPrivate.key -out rsaCertReq.crt<br> (input some basic certification data)<br></p></li> <li><p>Sign certification of the request<br> OpenSSL> x509 -req -days 3650 -in rsaCertReq.crt -signkey rsaPrivate.key -out rsaCert.crt<br></p></li> <li><p>Convert the certification file format to DER (iOS acceptable format)<br> OpenSSL> x509 -outform der -in rsaCert.crt -out rsaCert.der<br></p></li> <li><p>Generate PKCS12 Private key(iOS acceptable format)<br> OpenSSL> pkcs12 -export -out rsaPrivate.pfx -inkey rsaPrivate.key -in rsaCert.crt<br></p></li> </ol> <p>No further steps, files generated in step 5 and 6 now can be used in iOS!</p> <p>reference of OpenSSL instructions:<br> <a href="http://blogs.yaclife.com/?tag=ios%E3%80%80seckeyref%E3%80%80raw%E3%80%80key%E3%80%80rsa%E3%80%803des" rel="nofollow">http://blogs.yaclife.com/?tag=ios%E3%80%80seckeyref%E3%80%80raw%E3%80%80key%E3%80%80rsa%E3%80%803des</a></p> <p><a href="http://devsec.org/info/ssl-cert.html" rel="nofollow">http://devsec.org/info/ssl-cert.html</a></p>
31,124,220
0
<p>As @Warren pointed out, anderson_ksamp is not available in scipy version .12.1. It is a relatively new addition to scipy.</p> <p>I'm <strong>not</strong> a fedora user. That said, it sounds like installing scipy using pip is your best bet. </p> <p><strong>Step one:</strong> install dependencies. Check Muneeb's answer for information on how to <a href="http://stackoverflow.com/questions/7496547/does-python-scipy-need-blas">install blas and lapack on fedora.</a> It should be as simple as:</p> <blockquote> <p>sudo yum install lapack lapack-devel blas blas-devel</p> </blockquote> <p><strong>Step two:</strong> install scipy using pip. </p> <blockquote> <p>sudo pip install --upgrade scipy</p> </blockquote> <p>This process will take a long time. Get lunch. You should have a working copy of scipy when you get back.</p> <p><em>Note, if you don't have pip, run the following command:</em></p> <blockquote> <p>sudo yum install python-pip</p> </blockquote>
1,201,230
0
SharePoint > Custom Page-Library & PageLayout <p>I have a custom page-library which a custom content-type and a page-layout all inside a site-definition. </p> <p>Works as expected. The only thing I cannot get around is that if I upgrade the solution with the page-lib, ctype, page-layout via stsadm everything is updated except the page-layout.</p> <p>New fields in the ctype --> no problem Changed views in the page-lib --> no problem</p> <p>Updated PageLayout --> ERROR</p> <p>The page-layout section:</p> <pre><code>&lt;!-- specific page-layout to display LKW data --&gt; &lt;File Url="CustomPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" &gt; &lt;Property Name="Title" Value="$Resources:CustomLayouts,Title;" /&gt; &lt;Property Name="MasterPageDescription" Value="$Resources:cmscore,PageLayout_BlankWebPartPage_Description;" /&gt; &lt;Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" /&gt; &lt;Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png" /&gt; &lt;Property Name="PublishingAssociatedContentType" Value=";#$Resources:FieldsCTypes,cTypeDisplayName;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900D38AAFB8072F441984BC947D49503947;#" /&gt; &lt;/File&gt; </code></pre> <p>The relevant section in the onet.xml:</p> <pre><code>&lt;Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;Custom" Path=""&gt; &lt;File Url="Default.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"&gt; &lt;Property Name="Title" Value="$Resources:Layouts,DisplayName;" /&gt; &lt;Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;"/&gt; &lt;Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomPage.aspx, $Resources:PalfingerPlatformsOrderRoot,LKWpageDefaultTitle;" /&gt; &lt;Property Name="PublishingPageContent" Value="" /&gt; &lt;/File&gt; &lt;/Module&gt; </code></pre> <p>The strange thing is, if I just have a page-layout with no underlying page-library I can update the page-ayout. The problem only occurs if I use a custom page-layout inside a custom page-library.</p> <p>I did some Google search and found a hint - the problem could be that the page-layout is unghosted. I checked this with a small sample code:</p> <pre><code>SPFile file = folder.Files["Default.aspx"]; if (file.CustomizedPageStatus == SPCustomizedPageStatus.Customized) { file.RevertContentStream(); } </code></pre> <p>After executing the code the Page-Layout is upgraded and uses the new page-layout.</p> <p>The Problem is that this is no real solution for me because I have approx. 1000 site-collections using the site-def. and the page-layout. Updating all of them is quite painful. Does anybody know a solution for this?</p>
13,840,672
0
<p>check this .... it's good article it will help u <a href="http://www.androidaspect.com/2012/09/android-webview-tutorial.html" rel="nofollow">http://www.androidaspect.com/2012/09/android-webview-tutorial.html</a></p>
5,601,412
0
<p>It's actually doing exactly what it should. <a href="http://msdn.microsoft.com/en-us/library/yw97w238.aspx" rel="nofollow"><code>Server.Execute()</code></a> basically will insert the second page's content into the first page, including ViewState.</p> <p>To remedy your problem, are you able to disable ViewState on the page that's being called (demo.aspx)?</p> <pre><code>&lt;%@ Page Language="C#" EnableViewState="false" CodeBehind="demo.aspx.cs" </code></pre>
7,262,750
0
<p>Assuming that <code>listings</code> is indexed on id:</p> <p>If your id is an integer:</p> <pre><code>SELECT listings.id, listings.price, listings.seller_id, sellers.blacklisted FROM listings INNER JOIN sellers ON sellers.id = listings.sellers_id WHERE listings.price &gt; 100 AND sellers.blacklisted = 0 AND listings.ID LIKE CONCAT(CEIL(RAND() * 100),'%') LIMIT 4 </code></pre> <p>and if it's ascii</p> <pre><code>SELECT listings.id, listings.price, listings.seller_id, sellers.blacklisted FROM listings INNER JOIN sellers ON sellers.id = listings.sellers_id WHERE listings.price &gt; 100 AND sellers.blacklisted = 0 AND listings.ID LIKE CONCAT(CHAR(CEIL(RAND() * 100)),'%') LIMIT 4 </code></pre> <p>basically my advice to speed things up is dump the order by. On anything over a few records you're adding measurable overhead.</p> <p>ps please forgive me if concat can't be used this way in mqsql; not entirely certain whether it'll work.</p>
15,527,578
0
Generate dynamic select lambda expressions <p>I am somewhat new to expression trees and I just don't quite understand some things.</p> <p>What I need to do is send in a list of values and select the columns for an entity from those values. So I would make a call something like this:</p> <pre><code>DATASTORE&lt;Contact&gt; dst = new DATASTORE&lt;Contact&gt;();//DATASTORE is implemented below. List&lt;string&gt; lColumns = new List&lt;string&gt;() { "ID", "NAME" };//List of columns dst.SelectColumns(lColumns);//Selection Command </code></pre> <p>I want that to be translated into code like this (<code>Contact</code> is an entity using the EF4):</p> <pre><code>Contact.Select(i =&gt; new Contact { ID = i.ID, NAME = i.NAME }); </code></pre> <p>So let's say I have the following code:</p> <pre><code>public Class&lt;t&gt; DATASTORE where t : EntityObject { public Expression&lt;Func&lt;t, t&gt;&gt; SelectColumns(List&lt;string&gt; columns) { ParameterExpression i = Expression.Parameter(typeof(t), "i"); List&lt;MemberBinding&gt; bindings = new List&lt;MemberBinding&gt;(); foreach (PropertyInfo propinfo in typeof(t).GetProperties(BindingFlags.Public | BindingFlags.Instance)) { if (columns.Contains(propinfo.Name)) { MemberBinding binding = Expression.Bind(propinfo, Expression.Property(i, propinfo.Name)); bindings.Add(binding); } } Expression expMemberInit = Expression.MemberInit(Expression.New(typeof(t)), bindings); return Expression.Lambda&lt;Func&lt;t, t&gt;&gt;(expMemberInit, i); } </code></pre> <p>When I ran the above code I got the following error: </p> <blockquote> <p><em>The entity or complex type 'Contact' cannot be constructed in a LINQ to Entities query.</em></p> </blockquote> <p>I looked at the body of the query and it emitted the following code:</p> <pre><code>{i =&gt; new Contact() {ID = i.ID, NAME = i.NAME}} </code></pre> <p>I am pretty sure that I should be able to construct the a new entity because I wrote this line explicitly as a test to see if this could be done:</p> <pre><code>.Select(i =&gt; new Contact{ ID = i.ID, NAME = i.NAME }) </code></pre> <p>This worked, but I need to construct the select dynamically.</p> <p>I tried decompiling a straight query(first time I have looked at the low level code) and I can't quite translate it. The high level code that I entered is:</p> <pre><code>Expression&lt;Func&lt;Contact, Contact&gt;&gt; expression = z =&gt; new Contact { ID = z.ID, NAME = z.NAME }; </code></pre> <p>Changing the framework used in the decompiler I get this code:</p> <pre><code>ParameterExpression expression2; Expression&lt;Func&lt;Contact, Contact&gt;&gt; expression = Expression.Lambda&lt;Func&lt;Contact, Contact&gt;&gt; (Expression.MemberInit(Expression.New((ConstructorInfo) methodof(Contact..ctor), new Expression[0]), new MemberBinding[] { Expression.Bind((MethodInfo) methodof(Contact.set_ID), Expression.Property(expression2 = Expression.Parameter(typeof(Contact), "z"), (MethodInfo) methodof(Contact.get_ID))), Expression.Bind((MethodInfo) methodof(Contact.set_NAME), Expression.Property(expression2, (MethodInfo) methodof(Contact.get_NAME))) }), new ParameterExpression[] { expression2 }); </code></pre> <p>I have looked several places to try and understand this but I haven't quite gotten it yet. Can anyone help?</p> <p>These are some places that I have looked:</p> <ul> <li><a href="http://blogs.msdn.com/b/meek/archive/2008/04/25/using-linq-expressions-to-generate-dynamic-methods.aspx" rel="nofollow">msdn blog</a> -- This is exactly what I want to do but my decopiled code soes not have Expression.Call.</li> <li><a href="http://msdn.microsoft.com/en-us/library/bb301790.aspx" rel="nofollow">msdn MemberInit</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/bb348662.aspx" rel="nofollow">msdn Expression Property</a></li> <li><a href="http://stackoverflow.com/questions/1531934/entity-framework-only-get-specific-columns">stackoverflow EF only get specific columns</a> -- This is close but this seems like it is doing the same thing as if i just use a select off of a query.</li> <li><a href="http://stackoverflow.com/questions/2719762/lambda-expression-to-be-used-in-select-query">stackoverflow lambda expressions to be used in select query</a> -- The answer here is exactly what I want to do, I just don't understand how to translate the decompiled code to C#.</li> </ul>
10,707,169
0
<p>I had this exact problem today, while making a sample project for another SO answer! It looks like your xib is trying to connect an outlet to your view controller instead of your cell. In your screenshot, the outlets look correctly defined, but occasionally an old outlet definition can get left in the underlying XML and cause this type of crash. </p> <p>If you've changed the files owner class after connecting some outlets, for example, this could confuse it. </p> <p>You may be able to find it by opening the xib as "source code", look for the element and check there are only the entries you expect. Perhaps search the XML file for <code>albumLabel</code> as well. </p> <p>If that doesn't work, you may have to scrap the xib and start again. </p>
2,610,081
0
<p>None that I'm aware of. However, you can call Java from C++. That will let you use BCEL from C++. If you're on one of gcj's supported platforms, you could try using it to compile BCEL to native code.</p>
9,351,921
0
Change Combobox via Textbox Input VB.NET <p>Hi I need some help over here... how do i change the display member of a ComboBox after i have entered a code in a textbox that it represent the combobox value??</p> <p>example</p> <p>Code: 02-001 Combobox: Provider X</p> <p>if i change the code the provider combobox must change and if i change the provider combobox the code should change!.. i haven't found any help.. heres little code I remember</p> <pre><code>if e.keychar = chr(13) Then combobox.valuemember = textbox.text combobox.displaymember = me.stockdataset.selectprovider(@textbox.text) end if </code></pre> <p>this code change the combo box display member but if I change the comobox by clicking it the code on the textbox doesnt change, to its corresponding code...?? please help</p> <p>....the combo box is bound to the provider tables....</p>
3,566,034
0
<p>The default behavior of ViewSwitcher, as inherited by ViewAnimator, is to consider all child views on layout, which will result in the ViewSwitcher occupying the space of the largest child.</p> <p>To change this, all you need to do is to set the MeasureAllChildren flag to false. This will make the layout pass ignore the child view that is currently hidden. Set this flag e.g. in the onCreate method of the activity, e.g.:</p> <pre><code> ViewSwitcher switcher = (ViewSwitcher)findViewById(R.id.ViewSwitcher); switcher.setMeasureAllChildren(false); </code></pre> <p>XML example:</p> <pre><code>&lt;ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/viewSwitcher" android:measureAllChildren="false"&gt; &lt;/ViewSwitcher&gt; </code></pre>
24,219,023
0
<p>Use %0a , it might be helpful.</p> <p>Reference :<a href="http://www.twilio.com/help/faq/sms/how-do-i-add-a-line-break-in-my-sms-message" rel="nofollow">http://www.twilio.com/help/faq/sms/how-do-i-add-a-line-break-in-my-sms-message</a></p>
23,704,155
0
<p>You're referencing the root of the XML document, that's why only the data from the first element is being read. Get rid of the <code>//</code> in your call to <code>SelectSingleNode</code>:</p> <pre><code> currentBox.Compliment = currentBoxNode.SelectSingleNode("compliment").InnerText; currentBox.Description = currentBoxNode.SelectSingleNode("description").InnerText; currentBox.BoxType = currentBoxNode.SelectSingleNode("boxtype").InnerText; currentBox.InsideLength = decimal.Parse(currentBoxNode.SelectSingleNode("il").InnerText); currentBox.InsideBreadth = decimal.Parse(currentBoxNode.SelectSingleNode("ib").InnerText); currentBox.InsideHeight = decimal.Parse(currentBoxNode.SelectSingleNode("ih").InnerText); currentBox.OutsideLength = decimal.Parse(currentBoxNode.SelectSingleNode("ol").InnerText); currentBox.OutsideBreadth = decimal.Parse(currentBoxNode.SelectSingleNode("ob").InnerText); currentBox.OutsideHeight = decimal.Parse(currentBoxNode.SelectSingleNode("oh").InnerText); currentBox.BoxWeight = decimal.Parse(currentBoxNode.SelectSingleNode("bw").InnerText); currentBox.BoxGrossWeight = decimal.Parse(currentBoxNode.SelectSingleNode("bgw").InnerText); currentBox.BoxStrength = int.Parse(currentBoxNode.SelectSingleNode("boxstrength").InnerText); </code></pre> <p>You can also use ./ to indicate current context:</p> <pre><code>currentBox.Compliment = currentBoxNode.SelectSingleNode("./compliment").InnerText; ... </code></pre>
3,667,773
0
<p>One possibility: Use an xhtml parser that fixes malformed xhtml. One such library is libxml2. Then use the library to locate and remove empty p tags.</p>
29,066,247
0
Converting local numbers into international format (for use with Rails and services such as Nexmo/Twilo) <p>I want to verify my users phone numbers using a service such as Nexmo or Twilo.</p> <p>To send a message via these services I need to supply the international number, however, I do not want to have to ask my users to provide the full international number - just their normal number that they would give to anyone in their own country (I don't expect them to know their international dialling codes, etc).</p> <p>So what is the best way to convert a local national number into an international one? As well as their number, each user will be asked to provide their country. (My user base will be international.)</p> <ul> <li><p>Should I add an extra field to the Country table that holds the international dialling code - and then just construct the full international number? This seems ok until you consider that some countries require omitting the 0 at the start of the number, and others don't.</p></li> <li><p>Is there an easier way? Or gem out there that does this? </p></li> </ul>
37,337,715
0
<p><a href="https://3v4l.org/ZRenf" rel="nofollow">Online Check</a>, This is just a demo example.</p> <p>See below the real example:</p> <p>At first you need to use <code>array_search</code> for get the position of the same data, if exist then just remove it using <code>$arr[$pos] = '';</code>, and each and every time you need to import data into the new array called <code>$arr</code> and after completing fetching data you need to use a foreach loop to print them.</p> <pre><code>$arr = array(); foreach($query-&gt;result() as $row){ $pos = array_search($row-&gt;name, $arr); if($pos !== false) $arr[$pos] = ''; $arr[] = $row-&gt;name; } foreach($arr as $val){ echo $val.'&lt;br/&gt;'; } </code></pre> <p>Check this and let me know.</p>
3,748,538
0
Getting warning from C math library's pow function <p>I have the following function in my code:</p> <pre><code>int numberOverflow(int bit_count, int num, int twos) { int min, max; if (twos) { min = (int) -pow(2, bit_count - 1); \\ line 145 max = (int) pow(2, bit_count - 1) - 1; } else { min = 0; max = (int) pow(2, bit_count) - 1; \\ line 149 } if (num &gt; max &amp;&amp; num &lt; min) { printf("The number %d is too large for it's destination (%d-bit)\n", num, bit_count); return 1; } else { return 0; } } </code></pre> <p>At compile time I get the following warning:</p> <pre><code>assemble.c: In function ‘numberOverflow’: assemble.c:145: warning: incompatible implicit declaration of built-in function ‘pow’ assemble.c:149: warning: incompatible implicit declaration of built-in function ‘pow’ </code></pre> <p>I'm at a loss for what is causing this... any ideas?</p>
3,988,672
0
<p>The freezing is due to the fact you are trying to change your progress bar contained on the UI thread from your worker thread. I would recommend raising an event from within your worker Progress function to a handler on the UI thread. You will need to marshall the call to the handler on the thread as below. </p> <pre><code>private object _lock = new object(); //should have class scope private void ShowProgressControl(EventArgs e) { if (this.InvokeRequired) { lock (_lock) { EventHandler d = new EventHandler(ShowProgressControl); this.Invoke(d, new object[] { e }); return; } } else { //Show your progress bar. } } </code></pre> <p>Enjoy!</p>
18,776,688
0
<p>When catch exceptions I usually find that more specific is better, that being said typing out all of those different blocks that do the same thing can get really annoying. Thankfully in the Java 7 release a try-catch notation was added where you can specific <em>multiple</em> exceptions for a single block:</p> <pre><code>try{ //some statements } catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | FileNotFoundException | IOException | UnrecoverableKeyException | NoPropertyFoundException e) { LOGGER.error(e); } </code></pre> <p>This sounds like what you are looking for, but there is more detailed information in the Oracle docs: <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html</a></p>
3,376,479
1
Django object extension / one to one relationship issues <p>Howdy. I'm working on migrating an internal system to Django and have run into a few wrinkles.</p> <p><b>Intro</b><br> Our current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc.</p> <p><b>Base Objects</b><br> So I have two base objects/models:</p> <ul><li>JournalEntry <li>JournalEntryItems </ul> <p>defined as follows:</p> <pre> class JournalEntry(models.Model): gjID = models.AutoField(primary_key=True) date = models.DateTimeField('entry date'); memo = models.CharField(max_length=100); class JournalEntryItem(models.Model): journalEntryID = models.AutoField(primary_key=True) gjID = models.ForeignKey(JournalEntry, db_column='gjID') amount = models.DecimalField(max_digits=10,decimal_places=2) </pre> <p>So far, so good. It works quite smoothly on the admin side (inlines work, etc.)</p> <p><b>On to the next section.</b><br> We then have two more models</p> <ul><li>InvoiceEntry <li>InvoiceEntryItem </ul> <p>An InvoiceEntry is a superset of / it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site). That works quite smoothly too.</p> <pre> class InvoiceEntry(JournalEntry): invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='') journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID') client = models.ForeignKey(Client, db_column='clientID') datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid') </pre> <p>Where I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry. I'm getting the error:</p> <pre> &lt;class 'billing.models.InvoiceEntryItem'&gt; has more than 1 ForeignKey to &lt;class 'billing.models.InvoiceEntry'&gt; </pre> <p>The way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry. And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship.</p> <p>Here's the code I'm using at the moment.</p> <pre> class InvoiceEntryItem(JournalEntryItem): invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='') invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID') journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID') </pre> <ol> <li><p>I've tried removing the journalEntryItem OneToOneField. Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem).</p></li> <li><p>I've also tried removing the invoiceEntry ForeignKey relationship. Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline. All I see are blank fields (instead of the actual data that is currently stored in the DB).</p></li> </ol> <p>It seems like option 2 is closer to what I want to do. But my inexperience with Django seems to be limiting me. I might be able to filter the larger pool of journal entries to see just invoice entries. But it would be really handy to think of these solely as invoices (instead of a subset of journal entries).</p> <p>Any thoughts on how to do what I'm after?</p>
16,874,373
0
How do I declare a string as a user input, then check to see if it's "yes" or "no"? (JAVA) <p>I cannot get my program to take a user input as a string and then see if it equals "yes" or "no" and if it equals neither, then to display "incorrect entry." It always displays "incorrect entry" regardless if I type "yes" or "no." I have tried a few different types of if and do/while's but I just can't seem to get it: </p> <p>Class file: </p> <pre><code>import java.util.Scanner; public class PhysicsProblem { private double vI; // initial velocity private double vF; // final velocity private double t; // time private double deltaX; // change in the x value //Make sure to add acceleration public PhysicsProblem (double vI, double vF, double t, double deltaX) { this.vI = vI; this.vF = vF; this.t = t; this.deltaX = deltaX; } public void setVi(String strVi) { while (!(strVi.equals("no") || strVi.equals("yes"))); { System.out.println("incorrect entry"); } if (strVi.equals("yes")) { System.out.println("Enter the initial velocity: "); vI = new Scanner(System.in).nextDouble(); } if (strVi.equals("no")) { System.out.println("The program is assuming you want to solve" + "for intial velocity"); } } </code></pre> <p>Program: </p> <p>import java.util.Scanner;</p> <pre><code>public class PhysicsProblemSolver { public static void main (String[] args) { double vI = 0; double vF = 0; double t = 0; double deltaX = 0; Scanner scan = new Scanner(System.in); PhysicsProblem problem1 = new PhysicsProblem (vI, vF, t, deltaX); // Checks to see if initial velocity is given System.out.println("Do you know the initial velocity? (Type 'yes' or 'no')"); String strVi = scan.next(); problem1.setVi(strVi); </code></pre> <p>I know it looks like an incomplete program, and it is, but I just needed help with this one section, so I tried not to include the unnecessary parts. Sorry if it's confusing!</p>
7,575,471
0
Assigning issue with numpy structured arrays <p>I was trying this simple line of assigning codes to a structured array in numpy, I am not quiet sure, but something wrong happens when I assign a matrix to a sub_array in a structured array I created as follows:</p> <pre><code>new_type = np.dtype('a3,(2,2)u2') x = np.zeros(5,dtype=new_type) x[1]['f1'] = np.array([[1,1],[1,1]]) print x Out[143]: array([('', [[0, 0], [0, 0]]), ('', [[1, 0], [0, 0]]), ('', [[0, 0], [0, 0]]), ('', [[0, 0], [0, 0]]), ('', [[0, 0], [0, 0]])], dtype=[('f0', '|S3'), ('f1', '&lt;u2', (2, 2))]) </code></pre> <p>Shouldn't the second field of the subarray equals at this stage</p> <pre><code>[[1,1],[1,1]] </code></pre>
23,318,515
0
update a matplotlib figure from another class <p>How can I update a matplotlib figure that is a child of a frame in another class in tkinter? Here is where I am stuck.</p> <pre><code>class A(): def__init__(self, master): sframe = Frame(master) sframe.pack(side=RIGHT) f = Figure(figsize=(3,2), dpi=100) a = f.add_subplot(122); # initially plots a sine wave t = arange(0.0, 1, 0.01); s = sin(2*pi*t); a.plot(t,s); canvas = FigureCanvasTkAgg(f, master=sframe) canvas.show() canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1) # now i create the other object that will call show() data_obj = B(sframe) class B(): ... show(self, frame): _wlist = frame.winfo_children() for item in _wlist: item.clear() # or something like this # and then re-plot something or update the current plot </code></pre>
11,059,458
0
Cannot nullify the padding on a <select> in IE 8 <p>I've got a problem with IE8.</p> <p>I've got a select box to choose capacitance units pF, nF and mF.</p> <p>Now, the text is a little bit down, even though I set <code>padding:0</code>, and it cuts the text.</p> <p>And so the 'pF' option actually looks like 'nF' which is unacceptable.</p> <p><img src="https://i.stack.imgur.com/pd4zN.png" alt="enter image description here"></p> <p>I wonder if there is any fix at all. I can't think of nothing other than setting padding to 0 which doesn't work once again. Setting small <code>line-height</code> also doesn't do anything either.</p> <p>CSS:</p> <pre><code>select { width: 40px; height: 16px; padding: 0px; font: 8pt Helvetica; } </code></pre> <p>Any ideas?</p> <p>Edit: There you go for <strong>JSFIDDLE:</strong></p> <p><a href="http://jsfiddle.net/zuYsF/" rel="nofollow noreferrer">http://jsfiddle.net/zuYsF/</a></p> <p>See that 'pF' is selected by default, and it actually looks like 'nF'.</p>
4,915,668
0
Changing background color of RectangleShape in Visual Basic Power Pack 3 with C#? <p>I've installed Visual Basic Power Pack 3 in Visual Studio 2008 SP1. <br /> I wanna change the background color of RectangleShape in a C# WinForm !!! <br /> I changed <code>FillColor</code> property and <code>BackColor</code> property to <code>Black</code> but nothing happened and RectangleShape's background color didn't changed. <br /></p> <p>How can I change the background color of RectangleShape ?</p>
35,821,756
0
<p>Your checkout failed because pulling (and hence fetching) an explicit ref fetches <em>only</em> that ref, so after your initial pull your repo had only <code>refs/heads/master</code> and <code>refs/remotes/origin/master</code>, both pointing at the same commit. Checkout of 2.7 didn't work because your repo didn't have anything by that name.</p> <p>Pull does a merge, and the extra content <code>git pull origin 2.7</code> put in your worktree is there for conflict resolution, merge can't determine the correct results so you have to. You'll see that not everything outside the Tools directory is checked out, only the conflicted files. I'm not sure how merge with a shallow fetch and sparse checkout should behave overall, but asking for conflict resolution is surely the only thing to do here.</p> <p>Doing a shallow one-ref fetch is as lightweight as git gets, if one-off bandwidth use is really that dear you could clone to an ec2 instance and tag a particular tree.</p>
37,216,709
0
<p>Try with this code:</p> <pre><code>var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_beginRequest(BeginRequestHandler); function BeginRequestHandler(sender, args) { tinymce.execCommand('mceRemoveEditor', true, 'text_control_id'); } prm.add_pageLoaded(function (sender, e) { LoadTinyMCE(); }); </code></pre>
31,583,742
0
<p>The essential difference is that Special:SMWAdmin only ''queues'' the updates in the <a href="https://www.mediawiki.org/wiki/Manual:Job_queue" rel="nofollow">job queue</a>, while <code>rebuildData.php</code> actually <em>performs</em> the updates.</p> <p>If your job queue is correctly configured, the difference may be trivial; otherwise you'll run into <a href="https://www.mediawiki.org/wiki/Manual:Job_queue#Performance_issue" rel="nofollow">performance issues</a>. A common error is to <a href="https://phabricator.wikimedia.org/T60969" rel="nofollow">have insufficient memory</a> for the job runner. If all else fails, the last resort is <a href="https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/184#issuecomment-34790596" rel="nofollow">null-editing all the pages</a>.</p> <p>The difference was actually written in the help page, but in a weird English; <a href="https://semantic-mediawiki.org/w/index.php?title=Help%3ARebuildData.php&amp;diff=39897&amp;oldid=39582" rel="nofollow">fixed that too</a>.</p>
30,061,694
0
<p>Your code is restoring <code>productNames</code> <em>twice</em>, first in <code>onCreate()</code>, and again in <code>onRestoreInstanceState()</code>. After the first restoration, you append the new product String to the restored list. But then you restore it a second time, which replaces the updated list with the original list.</p> <p>Try deleting your <code>onRestoreInstanceState()</code>.</p>
32,577,045
0
<p>Remove <code>import U;</code>. You don't need it because both files are in the same location. That is what causing the problem.</p>
12,279,061
0
<p>It is not for <code>ConnectedThread</code> it for <code>mState</code> Synchronize should be used for both read and update.</p>
10,647,535
0
<p>You need to check for memory allocations with following in your app - </p> <ol> <li><p>Using <code>Instruments</code> check <code>Allocation</code> and <code>Leaks</code></p></li> <li><p>Using Static memory analyser check static memory leaks. To use this either use "cmd+shift+B" or go to "Xcode -> Product -> Analyze"</p></li> </ol> <p>Also you need to ensure proper release of your view controllers.</p>
3,995,018
0
<p>Why not get the square root of the number? If its negative - java will throw an error and we will handle it.</p> <pre><code> try { d = Math.sqrt(THE_NUMBER); } catch ( ArithmeticException e ) { console.putln("Number is negative."); } </code></pre>
6,596,742
0
How to get current location Latitude Longitude in android <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2227292/how-to-get-latitude-and-longitude-of-the-mobiledevice-in-android">How to get Latitude and Longitude of the mobiledevice in android?</a> </p> </blockquote> <p>I need a straight forward code which only find the Latitude and Longitude. I want to sent this over the webservice to get the near by hotels.</p> <p>I have used a lot of codes they work very well but some time they didn't work. If some one wants that code then i can also provide it is very good.</p> <p>Thanx all.</p>
38,128,265
0
<p>Fix for Chrome on Windows. </p> <p>First, you need to export the certificate.</p> <ul> <li>Locate the url in the browser. “https” segment of the url will be crossed out with the red line and there will be a lock symbol to the left. </li> <li>Right click on the crossed-out "https" segment. </li> <li>You will see an information window with various information</li> <li>Click “details”. </li> <li>Export the certificate, follow directions accept default settings.</li> </ul> <p>To import</p> <ul> <li>Go to Chrome Settings</li> <li>Click on "advanced settings"</li> <li>Under HTTPS/SSL click to "Manage Certificates"</li> <li>Go to "Trusted Root Certificate Authorities"</li> <li>Click to "Import"</li> <li>There will be a pop up window that will ask you if you want to install this certificate. Click "yes".</li> </ul>
18,790,656
0
Load xml malformed with simplexml <p>I've got a malformed xml file, basically it have ampersan(&amp;) inside the tags and they are not escaped...</p> <p>This is the code i'm using for loading the xml.</p> <pre><code>$archivo = "tarifa_mayorista.xml"; echo "Reading file&lt;br&gt;"; if (file_exists($archivo)) { $articulos = simplexml_load_file($archivo); if($articulos){ foreach ($articulos-&gt;Categoria as $rs) { $categoria = (string) $rs-&gt;TxCategoria; $subCat = (string) $rs-&gt;SubCategoria[0]-&gt;TxSubCategoria; $cod = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;PartNumber; $stock = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;Stock; $precio = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;Precio; $fabricante = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;Fabricante; $ean = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;EAN; $descripcion = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;Descripcion; $canon = (string) $rs-&gt;SubCategoria[0]-&gt;SubCategoria2[0]-&gt;Canon; $desc = mysql_real_escape_string($descripcion); $sql2="insert into `activadosmil` set cod='".trim($cod)."', stock='".trim($stock)."', precio='".trim($precio)."', categoria='".$categoria."', subcategoria='".$subCat."', descripcion='".$desc."', ean='".trim($ean)."', canon='".trim($precio)."', fabricante='".trim($fabricante)."'"; mysql_query($sql2) or die(mysql_error()."&lt;hr&gt;".$sql2); } } else echo "&lt;br&gt;Invalid XML sintaxis"; } else echo "&lt;br&gt;Error opening ".$archivo; </code></pre> <p>/* SAMPLE XML CODE */ </p> <pre><code>&lt;Categoria&gt; &lt;TxCategoria&gt;ALMACENAMIENTO&lt;/TxCategoria&gt; &lt;SubCategoria&gt; &lt;TxSubCategoria&gt;CARCASAS DISCO DURO&lt;/TxSubCategoria&gt; &lt;SubCategoria2&gt; &lt;TxSubCategoria2&gt;2,5"&lt;/TxSubCategoria2&gt; &lt;PartNumber&gt;5VECTRIXALU3,5&lt;/PartNumber&gt; &lt;Fabricante&gt;TACENS&lt;/Fabricante&gt; &lt;EAN&gt;4710700954461&lt;/EAN&gt; &lt;Descripcion&gt;MONITOR ASUS LED&amp;PIP 27 VE278Q&lt;/Descripcion&gt; &lt;Precio&gt; 12.37&lt;/Precio&gt; &lt;Stock&gt; 0&lt;/Stock&gt; &lt;Canon&gt; 0.00&lt;/Canon&gt; &lt;/SubCategoria2&gt; &lt;/SubCategoria&gt; &lt;/Categoria&gt; </code></pre> <p></p> <p>Is there any way to load the xml malformed file with simplexml? Or escape the characteres from tags?</p> <p>Thank you guys in advance</p>
16,770,704
0
<p>You can just use the .hidden property on the button </p> <p>To hide the button, if not already hidden</p> <pre><code>if(!yourButton.hidden) //Button is not hidden { //hide button yourButton.hidden = YES; //do other magic here if required } </code></pre> <p>To change the visibility of your button, you can use</p> <pre><code>yourButton.hidden = YES; //Set button hidden, (YES or NO, NO is by default) </code></pre>
4,691,764
0
<p>You should use the getter, because if your class moves to a more complex logic in the getter, then you will be insulated from the change. However, if your class provides a public getter, I'd question the logic of creating this method.</p>
5,824,890
0
Converting a ms-access front-end to a web-based technology <p>Can anyone recommend the best web-based technology/language for rewriting a ms-access front-end? I've already converted the tables to MySql and moved all the queries into stored-procedures. The language will need to be able to handle multiple result sets.</p> <p>Also, I need the GUI to be as similar as possible to the current ms-access front-end. So the new language will need to have features including full CRUD, tabbed forms, datasheet style sub-forms, combo-boxes and reports.</p> <p>I've dabbled a bit with html, css, php, javascript and java but are any of these capable or suitable? I've heard that Ajax or jQuery might be the way to go.</p>
34,932,955
0
Why are methods like setters used, instead of changing properties directly in Javascript? <p>With an object defined.</p> <pre><code>var bob = {age: 10}; </code></pre> <p>Defined setter as:</p> <pre><code>bob.setAge = function (newAge){ bob.age = newAge; }; </code></pre> <p>So we can change a property as:</p> <pre><code>bob.setAge(20) </code></pre> <p>Instead of simply:</p> <pre><code>bob.age = 20; </code></pre> <p>or</p> <pre><code>bob["age"] = 20; </code></pre> <p>Is best practices the reason?</p>
4,496,348
0
In the grid layout , what the difference between the followings <pre><code>Width="auto" Width ="*" Width ="100*" </code></pre>
13,683,745
0
Flash project does not show text correctly <p>Currently I am working on fixing a 3 year old flash project. I am using Flash professional CS5. The problem is that text is not shown correctly; characters seem to be omitted in textfields.</p> <ul> <li>"Hoi welkom bij deze groep" is shown as "oi elkom bij deze groep".</li> <li>"MEIJUH" is shown as "gi"</li> <li>"De connectie met de server is verbroken" is shown as "e connectie met de serer is erbroken"</li> </ul> <p>Note that these strings are in Dutch, but I don't think this is a problem for encoding. Above strings are "hardcoded" (or whatever you call it) in the project.</p> <p>I think that 3 years ago the project was initially created in an earlier version of Adobe CS.</p> <p>What might be a solution to fixing the correct showing of text in textfields?</p>
16,694,358
0
NewRelic reporting when using Rack::Timeout <p>We're running in an environment (Heroku) in which requests longer than 30 seconds will be interrupted. Therefore our web server (Unicorn) is set to abort after 15 seconds. We have noticed that when a request is interrupted no information seems to be logged to NewRelic. </p> <p>Any recommendations for how to get around this? My first thought was to use Rack::Timeout to have Rack cancel the request. Will this work with newrelic_rpm? Where in the middleware chain is newrelic injected?</p> <p>We're running Ruby 1.9.3 with Sinatra.</p> <p>Thank you in advance!</p>
40,940,970
0
<p>Adding <strong>-ExecutionPolicy ByPass</strong> is what made it work. So now what I am passing is:</p> <p><strong>-ExecutionPolicy ByPass -file "\SERVER\Share\Script.ps1"</strong></p> <p>This is where I got this tip - <a href="http://www.sqlservercentral.com/Forums/Topic1714552-147-1.aspx" rel="nofollow noreferrer">http://www.sqlservercentral.com/Forums/Topic1714552-147-1.aspx</a></p> <p>After I added this, <strong>Read-Host</strong> started working also and paused the execution of the script. </p>
4,801,725
0
<p>try datagrid.Items.Refresh() from here <a href="http://programmer.wrighton.org/2009/01/wpf-datagrid-items-refresh.html">http://programmer.wrighton.org/2009/01/wpf-datagrid-items-refresh.html</a></p>
35,835,247
0
<p>Thank you for reporting this. It's a bug. We'll deploy a fix in the next few days. Let me know if you have any questions.</p> <p>Update: This bug has been fixed.</p>
12,922,080
0
<p>I also believe it's region bias but did you tried comparing name and address of the result? It's happen to me sometimes I get the address and not the name lat lng pairs. I suggest you also to try this url from google <a href="http://maps.google.com/maps/geo?q=" rel="nofollow">http://maps.google.com/maps/geo?q=</a> see my answer: <a href="http://stackoverflow.com/questions/12788664/google-maps-api-geocode-returns-different-co-ordinates-then-google-maps/12790012#12790012">Google Maps API: Geocode returns different co-ordinates then Google maps</a>.</p>
15,724,424
0
<p>From the <a href="http://mongoosejs.com/docs/guide.html#id">documentation</a>:</p> <blockquote> <p>Mongoose assigns each of your schemas an id virtual getter by default which returns the documents _id field cast to a string, or in the case of ObjectIds, its hexString.</p> </blockquote> <p>So, basically, the <code>id</code> getter returns a string representation of the document's <code>_id</code> (which is added to all MongoDB documents by default and have a default type of <code>ObjectId</code>).</p> <p>Regarding what's better for referencing, that depends entirely on the context (i.e., do you want an <code>ObjectId</code> or a <code>string</code>). For example, if comparing <code>id</code>'s, the string is probably better, as <code>ObjectId</code>'s won't pass an equality test unless they are the same instance (regardless of what value they represent).</p>
1,066,862
0
How to set a property of a UIKit class or subclass for all future instantians? <p>What sort of Objective-C runtime magic do I need to use to make it so a property for an object is always set to a value than its normal default. For example, UIImageView's userInteractionEnabled is always false, but I want to my own UIImageview subclass to always have userInteractionEnabled set to true. Is the same thing achievable without subclassing UIImageView?</p>
11,372,554
0
<p>One important thing: you should write <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript" rel="nofollow">unobtrusive JavaScript</a>, as it is considered best practice. With it, you can maintain a separation of content from code. Thus, the first step is to remove that <code>onclick</code> handler on the <code>&lt;button&gt;</code> element.</p> <p>I'm assuming you want to click the button that says "click for hide" to hide the <code>&lt;div&gt;</code>. Okay, so let's get some skeleton code out into the <code>&lt;script&gt;</code>:</p> <pre><code>$(document).ready(function() { $(&lt;button&gt;).click(function() { $(&lt;div&gt;).hide(); }); }); </code></pre> <p>But we need to somehow link that <code>click</code> handler to that button, and link that <code>hide</code> function to the actual <code>div</code>. Here's the easiest way to do this: give your <code>&lt;button&gt;</code> and <code>&lt;div&gt;</code> some ids. Let's say...</p> <pre><code>&lt;button id="hide-button"&gt;...&lt;/button&gt; &lt;div id="hide-div"&gt;...&lt;/div&gt; </code></pre> <p>Now, we simply need to make a few modifications to our skeleton code:</p> <pre><code>$("#hide-button").click(function() { $("#hide-div").hide(); }); </code></pre> <p>Here's what this simple code does. When your DOM loads, a nameless function (you can't name functions that you define on the fly*) is invoked from the document's ready event. This nameless function attaches the <code>click</code> handler to your <code>#hide-button</code> button, so that when you click the button, another anonymous function is invoked. That function calls <code>hide</code>, which does some jQuery magic that works in all browsers, on that <code>#hide-div</code> div to hide it.</p> <p>*Well, you can, but only if you define them first and then pass them. Like this:</p> <pre><code>var fn = function() {...}; $(document).ready(fn); </code></pre> <p><strong>Edit</strong></p> <p>Since the asker does not want to use IDs or classes, here's an alternative solution:</p> <pre><code>&lt;script&gt; function hide() { $('div').hide(); } &lt;/script&gt; ... &lt;button onclick="hide()"&gt;click for hide&lt;/button&gt; &lt;div&gt;&lt;/div&gt; </code></pre> <p>Be careful not to place <code>function hide()</code> within jQuery's document-ready idiom. Doing so will deny you access to <code>hide()</code> because of scoping.</p>
2,020,999
0
WPF Master -Detail Binding XElement <p>I have a XElement that has the following structure</p> <pre><code>&lt;document num="1"&gt; &lt;pages&gt; &lt;page /&gt; &lt;page /&gt; &lt;/pages&gt; &lt;/document/&gt; </code></pre> <p>I have one Listbox named "documents" that is bound to an XElement in the following manner:</p> <pre><code>ItemsSource="{Binding Path=TheXElement.Elements[document]}" </code></pre> <p>I want to have a second ListBox named "pages" whose ItemsSource is the pages based on the selected document in the first list box.</p> <pre><code>ItemsSource="{Binding ElementName=documents,Path=SelectedItem.Element[pages].Elements[page]}" </code></pre> <p>Of source ,the above statement does not work. When I try the following <code>ItemsSource="{Binding ElementName=documents,Path=SelectedItem}</code>, the "pages" ListBox does get bound to the correct document, but it gets a binding error "ReferenceConverter cannot convert from System.Xml.Linq.XElement"</p> <p>I think I'm close, but having issues getting it to work. How can I correctly bind the "pages" ListBox to the SelectedItem of the "documents" ListBox?</p> <p>Thanks!</p>
14,368,605
0
<p>Unless there is some other requirement not specified, I would simply convert your color image to grayscale and work with that only (no need to work on the 3 channels, the contrast present is too high already). Also, unless there is some specific problem regarding resizing, I would work with a downscaled version of your images, since they are relatively large and the size adds nothing to the problem being solved. Then, finally, your problem is solved with a median filter, some basic morphological tools, and statistics (mostly for the Otsu thresholding, which is already done for you).</p> <p>Here is what I obtain with your sample image and some other image with a sheet of paper I found around:</p> <p><img src="https://i.stack.imgur.com/E5AZAm.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/vplgsm.png" alt="enter image description here"></p> <p>The median filter is used to remove minor details from the, now grayscale, image. It will possibly remove thin lines inside the whitish paper, which is good because then you will end with tiny connected components which are easy to discard. After the median, apply a morphological gradient (simply <code>dilation</code> - <code>erosion</code>) and binarize the result by Otsu. The morphological gradient is a good method to keep strong edges, it should be used more. Then, since this gradient will increase the contour width, apply a morphological thinning. Now you can discard small components.</p> <p>At this point, here is what we have with the right image above (before drawing the blue polygon), the left one is not shown because the only remaining component is the one describing the paper:</p> <p><img src="https://i.stack.imgur.com/isxDQ.png" alt="enter image description here"></p> <p>Given the examples, now the only issue left is distinguishing between components that look like rectangles and others that do not. This is a matter of determining a ratio between the area of the convex hull containing the shape and the area of its bounding box; the ratio 0.7 works fine for these examples. It might be the case that you also need to discard components that are inside the paper, but not in these examples by using this method (nevertheless, doing this step should be very easy especially because it can be done through OpenCV directly).</p> <p>For reference, here is a sample code in Mathematica:</p> <pre><code>f = Import["http://thwartedglamour.files.wordpress.com/2010/06/my-coffee-table-1-sa.jpg"] f = ImageResize[f, ImageDimensions[f][[1]]/4] g = MedianFilter[ColorConvert[f, "Grayscale"], 2] h = DeleteSmallComponents[Thinning[ Binarize[ImageSubtract[Dilation[g, 1], Erosion[g, 1]]]]] convexvert = ComponentMeasurements[SelectComponents[ h, {"ConvexArea", "BoundingBoxArea"}, #1 / #2 &gt; 0.7 &amp;], "ConvexVertices"][[All, 2]] (* To visualize the blue polygons above: *) Show[f, Graphics[{EdgeForm[{Blue, Thick}], RGBColor[0, 0, 1, 0.5], Polygon @@ convexvert}]] </code></pre> <p>If there are more varied situations where the paper's rectangle is not so well defined, or the approach confuses it with other shapes -- these situations could happen due to various reasons, but a common cause is bad image acquisition -- then try combining the pre-processing steps with the work described in the paper "Rectangle Detection based on a Windowed Hough Transform".</p>
3,028,971
0
<p>There is no standard predefined parameter type which allows you to get the current user name as a Where parameter in markup (I guess you are talking about <code>User.Identity.Name</code>). Something simple like...</p> <pre><code>&lt;asp:Parameter Name="userName" DefaultValue='&lt;%# User.Identity.Name %&gt;' /&gt; </code></pre> <p>...doesn't work unfortunately since you cannot use data binding syntax in the parameter controls.</p> <p>But you can create <a href="http://www.4guysfromrolla.com/articles/110106-1.aspx" rel="nofollow noreferrer">custom parameters</a>. (On the second half of that page is a concrete example of a "user name parameter".)</p> <p>To your problem with the exception: I'm using the "it-Syntax" with navigation properties a lot in EntityDataSource and it looks more or less exactly like your example. Without seeing more of your model it's hard to tell what might cause the error. But generally, navigating through properties in EntityDataSource is supported and works.</p>
38,477,014
0
<p>Ok, I investigated a bit more. My problem was not related to the value of DEFAULT_PORT.</p> <p>Concerning the negative value in the debugger, it looks to me like a bug in Xcode and not in Swift. I did a few tests and Swift does all operations with the correct value.</p> <p>To reproduce anyone can define <code>private let DEFAULT_PORT: UInt16 = UInt16(47300)</code> in the AppDelegate and put a Breakpoint in <code>didFinishLaunchingWithOptions</code>. You should then see -18326 as value in the debugger. </p>
22,866,252
0
Regex get text between parentheses and keywords <p>i have a text pattern like this;</p> <pre><code>(((a) or (b) or (c)) and ((d) or (e)) and ((!f) or (!g))) </code></pre> <p>and i want to get it like this;</p> <pre><code>((a) or (b) or (c)) ((d) or (e)) ((!f) or (!g)) </code></pre> <p>After that i want to seperate them like this;</p> <pre><code>a,b,c d,e !f,!g </code></pre> <p>any help would be awesome :)</p> <p><strong>edit 1:</strong> sorry about the missing parts; using language is C# and this is what i got;</p> <pre><code>(\([^\(\)]+\))|([^\(\)]+) </code></pre> <p>with i got;</p> <pre><code>(a) or (b) or (c) and (d) or (e) and (!f) or (!g) </code></pre> <p>thanks already!</p>
491,296
0
<p><strong>Here is the <em>answer</em> for those of you looking like I did all over the web trying to find out how to do this task. Uploading a photo to a server with the file name stored in a mysql database and other form data you want in your Database.</strong> Please let me know if it helped. </p> <p>Firstly the form you need: </p> <pre><code> &lt;form method="post" action="addMember.php" enctype="multipart/form-data"&gt; &lt;p&gt; Please Enter the Band Members Name. &lt;/p&gt; &lt;p&gt; Band Member or Affiliates Name: &lt;/p&gt; &lt;input type="text" name="nameMember"/&gt; &lt;p&gt; Please Enter the Band Members Position. Example:Drums. &lt;/p&gt; &lt;p&gt; Band Position: &lt;/p&gt; &lt;input type="text" name="bandMember"/&gt; &lt;p&gt; Please Upload a Photo of the Member in gif or jpeg format. The file name should be named after the Members name. If the same file name is uploaded twice it will be overwritten! Maxium size of File is 35kb. &lt;/p&gt; &lt;p&gt; Photo: &lt;/p&gt; &lt;input type="hidden" name="size" value="350000"&gt; &lt;input type="file" name="photo"&gt; &lt;p&gt; Please Enter any other information about the band member here. &lt;/p&gt; &lt;p&gt; Other Member Information: &lt;/p&gt; &lt;textarea rows="10" cols="35" name="aboutMember"&gt; &lt;/textarea&gt; &lt;p&gt; Please Enter any other Bands the Member has been in. &lt;/p&gt; &lt;p&gt; Other Bands: &lt;/p&gt; &lt;input type="text" name="otherBands" size=30 /&gt; &lt;br/&gt; &lt;br/&gt; &lt;input TYPE="submit" name="upload" title="Add data to the Database" value="Add Member"/&gt; &lt;/form&gt; </code></pre> <p>Then this code processes you data from the form: </p> <pre><code> &lt;?php // This is the directory where images will be saved $target = "your directory"; $target = $target . basename( $_FILES['photo']['name']); // This gets all the other information from the form $name=$_POST['nameMember']; $bandMember=$_POST['bandMember']; $pic=($_FILES['photo']['name']); $about=$_POST['aboutMember']; $bands=$_POST['otherBands']; // Connects to your Database mysqli_connect("yourhost", "username", "password") or die(mysqli_error()) ; mysqli_select_db("dbName") or die(mysqli_error()) ; // Writes the information to the database mysqli_query("INSERT INTO tableName (nameMember,bandMember,photo,aboutMember,otherBands) VALUES ('$name', '$bandMember', '$pic', '$about', '$bands')") ; // Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { // Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { // Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?&gt; </code></pre> <p>Code edited from <a href="http://www.about.com" rel="nofollow noreferrer">www.about.com</a></p>
21,456,670
0
<p>You could also use analytic functions to compute the number of NULL values for the name and filter by that:</p> <pre><code>with v_data as ( select name, value from table1 union select name, value from table2 ) select v2.* from ( select v1.*, count(value) over (partition by name) as value_cnt from v_data v1 ) v2 where value_cnt = 0 or value is not null </code></pre>
30,369,794
0
<p>The tuple part that you are looking for is actually a <a href="http://elixir-lang.org/getting-started/maps-and-dicts.html#maps" rel="nofollow">map</a>.</p> <p>The reason your original version didn't work is because your JSON, when decoded, returned a map as the first element of a <a href="http://elixir-lang.org/getting-started/basic-types.html#%28linked%29-lists" rel="nofollow">list</a>.</p> <p>There are multiple ways to get the first element of a list.</p> <p>You can either use the <code>hd</code> function:</p> <pre><code>iex(2)&gt; s = [%{"left_operand" =&gt; "2", "start_usage" =&gt; "0"}] [%{"left_operand" =&gt; "2", "start_usage" =&gt; "0"}] iex(3)&gt; hd s %{"left_operand" =&gt; "2", "start_usage" =&gt; "0"} </code></pre> <p>Or you can pattern match:</p> <pre><code>iex(4)&gt; [s | _] = [%{"left_operand" =&gt; "2", "start_usage" =&gt; "0"}] [%{"left_operand" =&gt; "2", "start_usage" =&gt; "0"}] iex(5)&gt; s %{"left_operand" =&gt; "2", "start_usage" =&gt; "0"} </code></pre> <p>Here <a href="http://elixir-lang.org/getting-started/pattern-matching.html#pattern-matching" rel="nofollow">destructuring</a> is used to split the list into its head and tail elements (the tail is ignored which is why <code>_</code> is used)</p> <p>This has nothing to do with the type of the elements inside the list. If you wanted the first 3 elements of a list, you could do:</p> <pre><code>iex(6)&gt; [a, b, c | tail] = ["a string", %{}, 1, 5, ?s, []] ["a string", %{}, 1, 5, 115, []] iex(7)&gt; a "a string" iex(8)&gt; b %{} iex(9)&gt; c 1 iex(10)&gt; tail [5, 115, []] </code></pre>
25,114,150
0
Is it limit for youtube json connections? <p>I'm getting youtube views like that:</p> <pre><code>$video_ID = 'your-video-ID'; $JSON = file_get_contents("https://gdata.youtube.com/feeds/api/videos/{$video_ID}?v=2&amp; alt=json"); $JSON_Data = json_decode($JSON); $views = $JSON_Data-&gt;{'entry'}-&gt;{'yt$statistics'}-&gt;{'viewCount'}; echo $views; </code></pre> <p>But sometimes i can see too many connections and yt back error ? So, how many queries into Youtube are possible for day, for ip or domain?</p> <p>Is there any chance to use API or something else to get a lot of data without problems ?</p>
5,701,468
0
<p>Own java agent should do the trick:</p> <p><a href="http://blogs.captechconsulting.com/blog/david-tiller/not-so-secret-java-agents-part-1" rel="nofollow">http://blogs.captechconsulting.com/blog/david-tiller/not-so-secret-java-agents-part-1</a></p> <p>I suppose that intercepting System.currentTimeMillis() calls should be enough.</p>
8,153,065
0
<p>The <a href="http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-4-2.html" rel="nofollow">Ada.Strings.Maps</a> packages would likely be very helpful here, particularly the "To_Set" (define the characters you want to strip out in a Character_Sequence) and "Is_In" functions.</p> <p>Since you're deleting, rather than replacing, characters, you'll have to iterate through the string, checking to see whether each one "is in" the set of those to be deleted. If so, don't append it to the output string buffer.</p>
27,188,356
0
<p>After @abhitalks comments/feedback. In your first example is nothing wrong, just is related to only inherited properties which will not work. color is inherited, but border is not:</p> <p>Take a look here <a href="http://www.w3.org/TR/CSS21/propidx.html" rel="nofollow"><strong>Full property table</strong></a></p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>:not(p) { color: #f00; border: 1px solid gray; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;This is a heading&lt;/h1&gt; &lt;p class="example"&gt;This is a paragraph.&lt;/p&gt; &lt;p&gt;This is another paragraph.&lt;/p&gt; &lt;div&gt;This is some text in a div element.&lt;/div&gt;</code></pre> </div> </div> </p> <p>In you second example:</p> <blockquote> <p>Selectors level 3 does not allow anything more than a single <a href="http://www.w3.org/TR/css3-selectors/#simple-selectors" rel="nofollow">simple selector</a> within a :not() pseudo-class.</p> </blockquote> <p>You can change it to:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>body :not(.example) { color: #ff0000; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h1&gt;This is a heading&lt;/h1&gt; &lt;p class="example"&gt;This is a paragraph.&lt;/p&gt; &lt;p&gt;This is another paragraph.&lt;/p&gt; &lt;div&gt;This is some text in a div element.&lt;/div&gt;</code></pre> </div> </div> </p>
36,778,764
0
Rails: Upload to Instagram programatically? <p>I want to upload photos to my own instagram account programatically from my Rails app. I've only been able to find posts from ~2013 that state this is against Instagram TOS. Is there any update or are photo uploads still disabled using the Instagram API?</p>
18,295,747
0
WordPress 301 Redirect Spaces to Hypens <p>I have the following in my .htaccess file:</p> <pre><code> # BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; Options +FollowSymlinks -MultiViews RewriteEngine On RewriteBase /entertainment/ RewriteCond %{THE_REQUEST} (\s|%20) RewriteRule ^([^\s%20]+)(?:\s|%20)+([^\s%20]+)((?:\s|%20)+.*)$ $1-$2$3 [N,DPI] RewriteRule ^([^\s%20]+)(?:\s|%20)+(.*)$ /$1-$2 [L,R=301,DPI] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /entertainment/index.php [L] &lt;/IfModule&gt; # END WordPress </code></pre> <p>The problem is that domain.com/entertainment/testing 1/ redirects to domain.com/testing-1 instead of domain.com/entertainment/testing-1/. How do I fix this?</p>
37,933,027
0
<p>If I understand you correctly, you want to <em>not</em> include any of the changes from <code>master</code>, but just "close" it and keep going with exactly what you have in <code>symfony</code>. If so, use the <code>ours</code> <a href="https://git-scm.com/docs/merge-strategies" rel="nofollow">merge strategy</a>, which will create a merge commit without incorporating any of the changes from the other branch and thus effectively "close" the other branch. The last two commands simply rearrange the branch names.</p> <pre><code>git checkout symfony git merge -s ours master git checkout -B master git branch -D symfony </code></pre>
24,327,386
0
<p>Try this... You can do it in single line...</p> <pre><code>formSubmit = isValidToggle($('#rta_cl_fn'), $('#div_cl_fn')) &amp;&amp; isValidToggle($('#rta_cl_ln'), $('#div_cl_ln')) &amp;&amp; isValidToggle($('#rta_cl_ph'), $('#div_cl_ph')) &amp;&amp; isValidToggle($('#rta_cl_mob'), $('#div_cl_mob')) </code></pre> <p>in this, it will check first one condition and if it is true then It will check further condition otherwise it will take you out.</p>
37,710,855
0
Angular Jasmine $location $httpBackend: "Error: unexpected request" <p>I'm trying to unit test $urlRouterProvider.otherwise to show the url as whatever the user entered. However, every time I use $location in my unit test, I get this error</p> <pre><code>path default rerouting should go to error upon bad rerouting url FAILED Error: Unexpected request: GET public/templates/404.html No more request expected at $httpBackend (/Users/project/lib/angular-mocks.js:1207:9) </code></pre> <p>This is what I have in my config file:</p> <pre><code>$urlRouterProvider .when('', '/main') .when('/', '/main') .otherwise(function($injector){ $injector.get('$state').go('404', {}, { location: false }); }); </code></pre> <p>And this is what I have as my spec.js file</p> <pre><code>describe('path', function(){ var $rootScope, $state, $location, $injector, $templateCache, state; beforeEach(angular.mock.module('app')); beforeEach(angular.mock.inject(function(_$rootScope_, _$state_, _$injector_, _$location_, _$templateCache_, _$httpBackend_){ $rootScope = _$rootScope_; $state = _$state_; $injector = _$injector_; $location = _$location_; $templateCache = _$templateCache_; $httpBackend = _$httpBackend_; $templateCache.put('public/templates/main.html', ''); $templateCache.put('public/template/audio.html', ''); $templateCache.put('public/template/404.html', ''); })); describe('default rerouting', function(){ it('should go to error upon bad url', function(){ var badUrl = '/badUrlToTest'; goTo(badUrl); expect($state.current.name).toEqual('404'); expect($location.url()).toBe(badUrl); }); }); function goTo(url){ $location.url(url); $rootScope.$digest(); } }) </code></pre> <p>Using $state works just fine, and in the <code>goTo()</code> function $location seems to work, so why does using <code>$location.url()</code> (or <code>$location.path</code>) throw an error asking about $httpBackend when I'm not using an <code>$http.get()</code> request?</p>
40,842,726
1
how to read html page using python? <p>I am new in learning python I have this html page with these info:</p> <p><a href="https://i.stack.imgur.com/yUI9L.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yUI9L.jpg" alt="enter image description here"></a></p> <p>I want to read the html page and print the info in this way:</p> <pre><code>['2011/2016', 'aaaa', 'x-t ', 'htu ', '***' , '55'] </code></pre>
407,207
0
<p>What database are you running?<br /> Does this occur with any other entries in the database or just this one?</p>
27,990,634
0
<p>Thanks for the answers.</p> <p>I solved it altogether differently: upon a selection change event I enable a short timer which, when ticked, checks whether or not there's a selected item in the ListView, and if not, it selects the first one. And it disables itself in any case. Seems that it works for me, so I am stopping there.</p>
30,838,405
0
<p>It is quite simple. Just go through and let me know in case you need some clarity. public class ThreeDto2D {</p> <pre><code>public static void main(String[] args) { double[][] data= {{97, 36, 79}, {94, 74, 60}, {68, 76, 58}, {64, 87, 56}, {68, 27, 73}, {74, 99, 42}, {7, 93, 87}, {51, 69, 40}, {38, 23, 33}, {57, 86, 31}}; double data1[] = new double[data.length]; double data2[] = new double[data.length]; double data3[] = new double[data.length]; for (int x= 0;x &lt; data.length;x++) { for (int y=0; y &lt; data[x].length ;y++) { if (y==0) data1 [x] = data [x][y]; else if (y==1) data2 [x] = data [x] [y]; else if (y==2) data3 [x] = data [x] [y]; } } for (int i=0;i&lt;data1.length;i++) { System.out.print(data1[i]+" "); System.out.print(data2[i]+" "); System.out.print(data3[i]+" "); System.out.println(); } } </code></pre> <p>}</p> <p>Output : 97.0 36.0 79.0 94.0 74.0 60.0 68.0 76.0 58.0 64.0 87.0 56.0 68.0 27.0 73.0 74.0 99.0 42.0 7.0 93.0 87.0 51.0 69.0 40.0 38.0 23.0 33.0 57.0 86.0 31.0</p>
5,508,484
0
splitting on whitespace help <pre><code>// alerts -&gt; a,b,c,d // which is correct window.alert("a b c d".split(/[\u000A-\u000D\u2028\u2029\u0009\u0020\u00A0\uFEFF]+/g)); </code></pre> <p>However, this isn't:</p> <pre><code>// alerts -&gt; ,a,b,c,d, // which is not what we need // as you can see, there is an extra space // in the front and end of the array // it is supposed to alert -&gt; a,b,c,d // just like our first example window.alert(" a b c d ".split(/[\u000A-\u000D\u2028\u2029\u0009\u0020\u00A0\uFEFF]+/g)); </code></pre> <p>Any ideas guys?</p>
7,861,459
0
<p>Responding to dvcolgan's clarifying comment:</p> <p>So, you want to have an HTML file on the server with inline CoffeeScript that gets served as HTML with inline JavaScript. The CoffeeScript compiler doesn't support this directly, but you could write a Node script to do it fairly easily, using the <code>coffee-script</code> library and <a href="https://github.com/tmpvar/jsdom">jsdom</a> to do the HTML parsing.</p> <p>Exactly how you want to implement this would depend on the web framework you're using. You probably don't want the CoffeeScript compiler to run on every request (it's pretty fast, but it's still going to reduce the number of requests/second your server can handle); instead, you'd want to compile your HTML once and then serve the compiled version from a cache. Again, I don't know of any existing tools that do this, but it shouldn't be too hard to write your own.</p>
14,301,867
0
<p>From the <a href="http://doc.qt.digia.com/qt/qsortfilterproxymodel.html#filterRegExp-prop"><code>filterRegExp</code></a> property docs:</p> <blockquote> <p>If no <code>QRegExp</code> or an empty string is set, everything in the source model will be accepted.</p> </blockquote> <p>So the "proper" way of clearing the filter is to pass an empty string rather than a match-all regex.</p>
3,152,361
0
<p>Example of a possible solution:</p> <pre><code>$('#modalContent').modal({ onShow: function (dialog) { var sm = this; // bind click event to get ajax content $('.link', dialog.container[0]).click(function (e) { e.preventDefault(); $.ajax({ ..., // your settings here success: function (data) { dialog.data.html(data); // put the data in the modal dialog.container.css({height:'auto', width:'auto'}); // reset the dimensions sm.setContainerDimensions(); // resize and center modal // if you want to focus on the content: sm.focus(); // if you want to rebind the events sm.unbindEvents(); sm.bindEvents(); } }); }); } }); </code></pre> <p>I'm going to look into putting a resize function in SimpleModal, which would take care of most of these steps. Until then, this should work for you.</p> <p>-Eric</p>
23,249,486
0
<p>Check for <a href="https://github.com/genemu/GenemuFormBundle" rel="nofollow">Genemu bundle</a> which add differents form type such as file upload and image upload</p> <p><a href="http://tympanus.net/crop1.1/" rel="nofollow">demo here</a></p> <p>I took inspiration to create my own</p>
1,176,215
0
<p>Did you check <code>/var/log/messages</code> on your server?<br> May be the username 'git' does not work properly: From the <a href="http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way" rel="nofollow noreferrer">comments of Gitosis</a>,</p> <p>if you look at the authorized_key file you will see that it did not import the name of the system that key was generated on but the name of the server box.</p> <p>Example: using a username of “git” resulted in this in the authorized key</p> <pre><code>root@git-repo:/home/git/.ssh# cat authorized_keys command=”gitosis-serve root@git-repo” </code></pre> <p>After changing to user name “gitosis” it looks like this </p> <pre><code>root@git-repo:/home/gitosis/.ssh# cat authorized_keys command=”gitosis-serve myuser@mylocalbox”, </code></pre> <p>To fix I created a user gitosis with home dir of /home/gitosis and ran the git-init script again.</p> <pre><code>sudo -H -u gitosis gitosis-init &lt; /tmp/id_rsa.pub sudo chmod 755 /home/gitosis/repositories/gitosis-admin.git/hooks/post-update </code></pre> <p>then, on local box.. </p> <pre><code>git clone gitosis@YOUR_SERVER_HOSTNAME:gitosis-admin.git </code></pre>
1,034,746
0
<p>In the case where you are ignoring the first character, you only want to compare <code>word.length() - 1</code> characters -- and the same length for both the string and the word.</p> <p>Note that you really don't need to test the case where the first letter exactly matches as that is a subset of the case where you are ignoring the first letter.</p>
4,614,897
0
<pre><code>SELECT * FROM table WHERE COLUMN IS NULL </code></pre>
8,321,201
0
<p>You're best off creating a new timer. If the class doesn't provide an interface for changing that attribute, then you should consider it private and read-only.</p> <p>It's not even possible in this case to do the usual end run around that, using KVC:</p> <pre><code>[timer setValue:newNumber forKey:@"userInfo"]; </code></pre> <p>since <code>NSTimer</code> is not KVC-compliant for that key.</p>
14,071,154
0
<p>Use <code>java.nio.ByteBuffer</code></p> <p>Something like:</p> <pre><code>private static ByteBuffer buffer = ByteBuffer.allocate(8); public static byte[] encodeDouble(double x) { buffer.clear(); buffer.putDouble(0, x); return buffer.array(); } public static double decodeDouble(byte[] bytes) { buffer.clear(); buffer.put(bytes); buffer.flip(); return buffer.getDouble(); } </code></pre>
9,420,810
0
<p>To run Python scripts on your Android phone all you have to do is install SL4A and this is how you do that:</p> <p>To install SL4A, you will need to enable the "Unknown sources" option in your device's "Application" settings, download the .apk and install it either by accessing <a href="http://code.google.com/p/android-scripting/" rel="nofollow">http://code.google.com/p/android-scripting/</a> from your computer and click the qr-code or directly from your phone and click the qr-code and then run the downloaded .apk file.</p> <p>After installing SL4A:</p> <ul> <li>press the Home button</li> <li>press Add button</li> <li>go to Interpreters</li> <li>press Home button again</li> <li>press Add again</li> <li>pick Python Interpreter and install it</li> </ul> <p>and after that a new screen will appear with an Install button on the top, press it and it will download Python 2.6.2, at the moment, for you. Optionally there is a button so that you can download a few more Python modules.</p> <p>After these steps you are ready to go. You will be able to create Python scripts using SL4A and run the directly on your phone without "compiling" them, if that's your worry. It also makes the .pyc files if those are the ones you're talking about.</p>
12,229,258
0
<p><strong>This answer is based upon what you mentioned in the question when no code snippet was provided and quetion was...</strong></p> <blockquote> <p>I have created a component instance, drawn it onto the screen, and added it to an ArrayList. I'm accessing it by referencing to the drawn one using it's children (getParent() method). However, when I then pass this reference to ArrayLists indexOf(); method, it returns -1. I suppose that means that the component does not exist in the ArrayList. Is this what should happen, or did I probably mess something up in my program? I'm NOT providing you with a SSCCE, I'm not asking you to do any coding, just to tell me if this is normal Java behavior...</p> </blockquote> <p><strong>Here goes the my response</strong></p> <p>The javadoc of <code>indexOf()</code> says... </p> <blockquote> <p>Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.</p> </blockquote> <p>As you can see this depends on the <code>equals()</code> implementation for you component. Check your implementation as that holds the key of retrieving the value from list.</p>
36,889,959
0
JAVA JSON Restfull WebService No 'Access-Control-Allow-Origin' header is present on the requested resource <p>I have a JAVA RESTful webservice which will return JSON string and it was written in Java. My problem is when I send request to that webservice with below URL</p> <pre><code>http://localhost:8080/WebServiceXYZ/Users/insert </code></pre> <p>it's giving me the below error message</p> <pre><code>XMLHttpRequest cannot load http://localhost:8080/WebServiceXYZ/Users/insert/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. The response had HTTP status code 500. </code></pre> <p>Here is my Code</p> <pre><code>package com.lb.jersey; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.json.JSONException; import org.json.JSONObject; @Path("/Users") public class RegistrationService { @POST @Produces(MediaType.APPLICATION_JSON) @Path("/insert") public String InsertCredentials (String json) throws JSONException { java.util.Date dt = new java.util.Date(); java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentTime = sdf.format(dt); String phone = null; JSONObject returnJson = new JSONObject(); try { JSONObject obj = new JSONObject(json); JSONObject result1 = obj.getJSONObject("Credentials"); phone = result1.getString("phone"); DBConnection conn = new DBConnection(); int checkUserID = conn.GetUserIDByPhone(phone); if(checkUserID &lt;= 0) { DBConnection.InsertorUpdateUsers(phone, currentTime); } int userID = conn.GetUserIDByPhone(phone); int otp = (int) Math.round(Math.random()*1000); DBConnection.InsertorUpdateCredentials(userID, otp, currentTime); JSONObject createObj = new JSONObject(); createObj.put("phone", phone); createObj.put("otp", otp); createObj.put("reqDateTime", currentTime); returnJson.put("Credentials", createObj); System.out.println(returnJson); } catch (Exception e) { } return returnJson.toString(); } } </code></pre> <p>My web.xml code</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;display-name&gt;WebServiceXYZ&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt; &lt;servlet-class&gt;com.sun.jersey.server.impl.container.servlet.ServletAdaptor&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt; &lt;param-value&gt;com.lb.jersey&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>I already read many articles but no progress, so please let me know, How can I handle this issue?</p>
18,219,695
0
<p>Maybe you forgot to match the scopes of <code>PlusClient</code> and <code>getToken</code>:</p> <pre><code>new PlusClient .Builder(this, this, this) .setScopes(Scopes.PLUS_LOGIN, "https://www.googleapis.com/auth/userinfo.email") .build(); </code></pre>
28,892,840
0
<p>You can do it like this:</p> <pre><code>function setCaret() { var element = document.getElementById("input"); var range = document.createRange(); var node; node = document.getElementById("first"); range.setStart(node.childNodes[0], 1); &lt;-- sets the location var sel = window.getSelection(); range.collapse(true); sel.removeAllRanges(); sel.addRange(range); element.focus(); } </code></pre> <p>node.childNodes[] pertains to which line you want to set the cursor on and the next number is the location on that line. In this example is moves to space 1 line 0 (line 1 really). So if you change those values to variables and put them as parameters in your function you could specify where.</p>
9,128,671
0
<p>First of all <code>equals()</code> should determine whether two objects are <em>logically equal</em>. If these objects are logically equal when their <code>str1</code> fields are equal then you may go with equals and use methods defined for the collections. In this case <code>equals()</code> contract (defined in the java.lang.Object) is worth reading.</p> <p>If I were working with your code I would prefer if you solve your problem with iteration instead of defining incorrect <code>equals()</code> method (Warning: not tested code):</p> <pre><code>Set&lt;String&gt; strings = new HashSet&lt;String&gt;(listOne.size()); for(Test t : listOne){ strings.add(t.getStr1()); } Iterator&lt;Test&gt; it = listTwo.iterator(); while(it.hasNext()){ Test t = it.next(); if(strings.contains(t.getStr1()) it.remove(); } </code></pre>
31,502,377
0
<p>Just remove the <code>return jsonify(ret_data)</code> line form your <code>send_recommend()</code> route. </p> <pre><code>@app.route('/send_recommend', methods=['GET', 'POST']) def send_recommend(): if request.method == 'GET': ret_data = {"data": request.args.get('data')} #do something here </code></pre> <p>Because you are returning the JSON data back to your template.</p>