pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
3,166,759
0
<pre><code>// Here UL will be the id attribute, not the &lt;ul&gt; element. var UL = document.createElement('ul').id = 'meta-ul'; // this doesn't makes sense... (id.appendChild) UL.appendChild(li1) ; // solution: var UL = document.createElement('ul'); UL.id = 'meta-ul'; </code></pre> <p>And the same goes for Dialog and Tabs. (your li1 and li2 are fine)</p> <p>Oh, and as long as you're not using anything starting with $, you cannot conflict with jQuery.</p>
30,197,374
0
<p>Instead of trying to run ij.bat, and feed it commands to run and parse the output, just have your program use the ij class, and its runScript method: <a href="http://db.apache.org/derby/docs/10.11/publishedapi/org/apache/derby/tools/ij.html#runScript-java.sql.Connection-java.io.InputStream-java.lang.String-java.io.OutputStream-java.lang.String-" rel="nofollow">http://db.apache.org/derby/docs/10.11/publishedapi/org/apache/derby/tools/ij.html#runScript-java.sql.Connection-java.io.InputStream-java.lang.String-java.io.OutputStream-java.lang.String-</a></p> <p>Then you don't have to spawn a separate process, but can just keep everything in pure Java in your program itself.</p>
10,103,473
0
<p>What about:</p> <pre><code>select std.name ,(select count(1) from STUD_Name) nrofstds from STUD_Name std where std.id='2' </code></pre>
32,130,351
0
Installing Caliburn.Micro NuGet Package always fails <p>I am attempting to compile the Caliburn.Micro projects from <a href="https://github.com/Caliburn-Micro/Caliburn.Micro" rel="nofollow">GitHub</a> so I can generate the DLL's to use in my own project - a Caliburn.Micro Xamarin Native Android project.</p> <p>I have loaded the Caliburn.Micro.sln (located in the <code>src</code> folder) into Visual Studio 2012 professional and attempted to build the <code>Caliburn.Micro</code> project. I get 40 errors relating to metadata. For example;</p> <pre><code>Error 5 Metadata file '_Tests\Caliburn.Micro-xamarin\Caliburn.Micro-xamarin\bin\net45\Debug\Caliburn.Micro.Platform.dll' could not be found _Tests\Caliburn.Micro-xamarin\Caliburn.Micro-xamarin\src\Caliburn.Micro.Tests.NET45\CSC Caliburn.Micro.Tests.NET45 </code></pre> <p>So I have attempted to install the <code>Caliburn.Micro</code> NuGet package on this project and I get the following errors. I have also created my own new solution and attempted to install the <code>Caliburn.Micro</code> NuGet package and the same error occurs.</p> <p>Any ideas what is going wrong?</p> <pre><code>PM&gt; Install-Package Caliburn.Micro Attempting to resolve dependency 'Caliburn.Micro.Core (= 2.0.2)'. Installing 'Caliburn.Micro.Core 2.0.2'. Successfully installed 'Caliburn.Micro.Core 2.0.2'. Installing 'Caliburn.Micro 2.0.2'. Successfully installed 'Caliburn.Micro 2.0.2'. Adding 'Caliburn.Micro.Core 2.0.2' to Caliburn.Micro. Uninstalling 'Caliburn.Micro.Core 2.0.2'. Successfully uninstalled 'Caliburn.Micro.Core 2.0.2'. Install failed. Rolling back... Install-Package : Specified argument was out of the range of valid values. Parameter name: supportedFrameworks At line:1 char:1 + Install-Package Caliburn.Micro + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], ArgumentOutOfRangeException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand </code></pre>
7,064,737
0
How to select Dev Express's WPF GridControl row? <p>I want to select GridControl's row, after data binding:</p> <blockquote> <ol> <li>Get selected row</li> <li>Bind GridControl with new Data</li> <li>Select GridControl's row</li> </ol> </blockquote> <p>I'm trying so, but with no success:</p> <pre><code>int selectedRowhandle = gridControl1.View.GetSelectedRowHandles()[0]; gridControl1.DataSource = "DataSource..."; gridControl1.View.SelectRow(selectedRowhandle); </code></pre> <p>How can I do this in DevExpress.Xpf.Grid.GridControl?</p> <p>Thanks.</p>
37,007,006
0
In fabrics JS after stage.loadFromJSON is loaded <p>I have fabrics JS canvas which is loaded from json, like:</p> <pre><code> stage.loadFromJSON( _templateData, stage.renderAll.bind(stage), function( _object, _klass ) { if( _object.type == 'image' ){ _klass.set({ id: 'bgImage'+_get_dynamicOriginalLayerCount(stage), centeredRotation: true, }); _klass.on( 'mousedown', function(){ _destroyOptions(); } ); } else { _klass.id = 'layer'+_get_dynamicOriginalLayerCount(stage); _textStyleMenu( _klass ); _textListener( _klass ); _klass.set({ borderColor: 'rgba(52, 152, 219, .5)', cornerColor: 'rgba(42, 142, 209, .5)', cornerSize: 55, transparentCorners: false }); } } ); html2canvas(original_target, { onrendered: function(original_canvas) { var data = original_canvas.toDataURL(); </code></pre> <p>and I need to read image using html2canvas function. In case if loaded image is big, 5-10 mb, it takes some time(seconds) and toDataURL return very few of data. If there is a way to get event after image is reaaly loaded?</p> <p>I read here <a href="http://fabricjs.com/docs/fabric.Canvas.html" rel="nofollow">http://fabricjs.com/docs/fabric.Canvas.html</a> but did not find how to salve it? fabric 1.5.0.</p>
9,701,383
0
<p>Because <code>get()</code> is <strong>method</strong> and must be invoked on instance.</p> <pre><code>new B().get(5); new A().get(1); </code></pre> <p>You call it in <code>static main()</code>, which is class <strong>function</strong>.</p> <pre><code>B.exampleFunction(); </code></pre>
18,301,024
0
<p>Have you tried adding the <code>!important</code> tag on each CSS line in order to tell the element to override bootstrap?</p> <p>Something like this:</p> <pre><code>.navbar-override { background-color: #006633 !important; background-image: -moz-linear-gradient(top, #006633, #006633) !important; background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#006633), to(#006633)) !important; background-image: -webkit-linear-gradient(top, #006633, #006633) !important; background-image: -o-linear-gradient(top, #006633, #006633) !important; background-image: linear-gradient(to bottom, #006633, #006633) !important; border-color: #006633 !important; filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ff006633', endColorstr='#ff006633', GradientType=0) !important; } </code></pre> <p>Typically not the best way to do this, but I think it should work.</p>
14,206,730
0
<pre><code>$("[ref=B]").append($(data).find("[ref=A]")); </code></pre> <p>The way you do it in your question, the last part <code>find( '[ref=A]' )</code> is useless.</p> <p>[Edit] Also, the other question is more than 2 years old. For recent versions of jQuery you might need additional quotes:</p> <pre><code>$("[ref='B']").append($(data).find("[ref='A']")); </code></pre>
3,664,738
0
<p>This is an interesting question. For sure I would say start with UIScrollView, and set the content size bigger than the screen size, exactly how big is up to you.</p> <p>Next you'll want to make some kind of implementation that efficiently figures out what cells are on screen. If I were you I would do something similar to how UITableView is done, i.e. make a custom object that keeps track of what indexes should be on screen based on the offset of the scroll view.</p> <p>Next you'll need this custom object to either directly or indirectly get the visible cells to display themselves on screen when they are visible, and remove them from the superview when they aren't. I'd also recommend reusing the views that are offscreen.</p> <p>This is a moderately challenging thing you are trying to make, so be sure you are very organized and don't be scared to make a few new custom object to perform specific tasks. </p> <p>Sample interface file:</p> <pre><code> @protocol doubleTableViewDelegate -(NSInteger)heightForRow:(NSInteger)row; -(NSInteger)widthForCol:(NSInteger)col; -(NSInteger)numberOfRows:(NSInteger)rows; -(NSInteger)numberOfCols:(NSInteger)cols; -(UIView *)cellForRow:(NSInteger)row col:(NSInteger)col; //get the custom table view to store and dequeue these, i.e. store them in an NSSet when they go offscreen, and give them back when a certain function is called. //There's probably a few functions missing here still. @end @interface doubleTableView: UIScrollView { id&lt;doubleTableViewDelegate&gt; infoDelegate; } //your functions to show and remove cells as needed @end </code></pre> <p>You'll need to work out the rest, but keep updating this page and I'll try to help out. Good luck with this, let me know how it goes.</p>
12,755,256
0
<p>Not sure if this is what you thought, but maybe you could style that portion of the page and use something like this?</p> <pre><code>@gridColumnWidth: 60px; // example width declared in bootstrap @media only screen and (min-width: 768px) and (max-width: 979px) { .yourClass { max-width: @gridColumnWidth * 2 } } </code></pre>
16,410,844
0
Multiple matches for syntax highlighting in VIM <p>I'm writing a syntax file to match a log format (basically column based; think syslog for a similar example), and I'm trying to set up a type of inheritance for columns.</p> <p>I have two main goals with this.</p> <p>First, I want to say that column 3 is the "component" field (let's say it's marked by a header; it could also be at a fixed position) and set the background to, say, Grey. I then want to say that component "foo" gets a foreground color of Red, and component "bar" gets a foreground color of Green, but they should inherit the background color of the "component" column. In this case, the field should really have two syntax matches; this also makes it easy to conceal the entire column (a la <a href="http://stackoverflow.com/questions/3853631/toggling-the-concealed-attribute-for-a-syntax-highlight-in-vim">Toggling the concealed attribute for a syntax highlight in VIM</a>)</p> <p>Second, there's a field for levels; I want to set the background of the entire line for a critical level message to Red, but the foreground should be continue to be set via the normal highlighting (component, source, etc; I left off most of the other requirements).</p> <p>From what I can see in the vim documentation, this doesn't seem possible. Am I missing something? Alternatively, can anyone suggest a good workaround?</p> <p>Thanks</p>
32,486,438
0
<p>Try <code>git clone origin-url .</code> (with dot)</p> <p>Example:</p> <pre><code>hg clone https://[email protected]/mitsuhiko/flask . </code></pre>
1,989,931
0
Android: Delete app associated files from external storage on Uninstall? <p>It'd be convenient if an application I'm writing stored some files to external storage permanently (so they persist after the application has been exited[destroyed]), but on an uninstall I'd like to do the decent thing and have these files removed to free up the storage.</p> <p>Is there any way I can have these files removed on an uninstall?</p> <p>If there isn't (and I'm skeptical), then I'll have to create these files each time. I'm trying to save start-up time and also occupy required space by having them exist permanently.</p> <p>Note: I need to use external storage, so both internal storage or a DB would be inappropriate.</p>
1,712,496
0
<p>In the DrScheme IDE this can be found under the "Scheme -> Create Executable..." menu item. This can also be done from the command line with:</p> <pre><code>mzc --exe foo foo.ss </code></pre>
6,804,386
0
RMagick: Setting opacity on a png that already has transparent elements <p>I need to compose images in rmagick. If I put a png that has transparent regions on another image and set the opacity of that png to 50% the parts that where transparent become white (with 50% opacity). But I want these regions to stay transparent.</p> <p>Here's my code:</p> <pre><code>canvas = Magick::Image.new(1024,768) canvas.opacity = Magick::MaxRGB image = Magick::ImageList.new('/tmp/trans.png').first image.background_color = "none" image.opacity = Magick::MaxRGB/2 canvas.composite!(image, 50, 50, Magick::OverCompositeOp) canvas.write('/tmp/composite.png') </code></pre> <p>Any suggestions?</p>
8,559,650
0
<p>You could do a very nasty <code>for</code> loop where you search for the <code>,</code> values and then compare from the start of 1 <code>,</code> to the next. You could use <code>SubString()</code> and <code>IndexOf()</code> to achieve this, but this isn't very performant nor elegant.</p>
40,069,199
1
Convert str bytes to bytes <p>I have a bluetooth controller which returns the data of a event in <code>received_data</code> where the 3 &amp; 4 byte together are a 16 bit signed little-endian int value. </p> <p>With python2 where a str is also a byte I just exctract it with <code>struct.unpact</code></p> <pre><code>rotation_value = struct.unpack("&lt;h", received_data[3] + received_data[4])[0] </code></pre> <p>This doesn't work with python3 because str and byte are not the same thing</p> <pre><code>rotation_value = struct.unpack("&lt;h", received_data[3] + received_data[4])[0] TypeError: 'str' does not support the buffer interface </code></pre> <p>So my approach was to just convert the str to bytes.</p> <p>here are things I tried</p> <pre><code>print((received_data[3]+received_data[3]).encode('utf_16_le')) print(received_data[3].encode('ISO-8859-1') + received_data[4].encode('ISO-8859-1')) print(int.from_bytes(bytes([ord(c) for c in (received_data[3]+received_data[3])]), byteorder='little', signed=True)) print(struct.unpack("&lt;h", bytearray(received_data[3] + received_data[4], 'cp1252'))[0]) </code></pre> <p>But no matter how I do it I have allays error messages like these:</p> <pre><code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 3: invalid continuation byte </code></pre> <p>As <a href="http://stackoverflow.com/users/4014959/pm-2ring">@PM 2Ring</a> proposed to use latin1</p> <pre><code>print(received_data[3].encode('latin1')) </code></pre> <p>Which didn't work </p> <pre><code>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xca in position 3: invalid continuation byte UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 3: invalid start byte </code></pre> <p>So what exactly is the correct way to convert these fake str in bytes, preferably a solution which works on python2 &amp; 3. </p>
9,847,208
0
Class Design C# Casting <p>Let's say I have a program to write text into a file (not really but that's easier to explain). I want a seperate class for each filetype like PdfType and WordType that inherit from a FileTypeMaster.</p> <pre><code>FileTypeMaster (base) -PdfType : FileTypeMaster -WordType : FileTypeMaster (same methods as pdftype but works different) </code></pre> <p>Now to the real problem... I want the user to decide on programstart what type to use. If he wants Pdf OR Word the methodcall should look the same (because word is new and the program was just for pdf before).</p> <p>How it should work for example with pdf:</p> <pre><code>static FileTypeMaster MyFavoriteType; //declare a general var MyFavoriteType = new PdfType(); //cast general var to the wanted type MyFavoriteType.CompileThis(); </code></pre> <p>How it should work with word: the same but MyFavoriteType = new WordType();`</p>
30,083,314
0
<p>I do not know how many records you have in each table. If they it is a relatively small number you may be better finding a way of holding them in memory rather than querying each time.</p>
25,091,139
0
Concave Curve With only CSS,A Compound Shapes in CSS <p>I have a CSS student and she is taking a CSS class, and her teacher asked her to create a shape using only CSS codes,without any implementation of an Image.</p> <p>the shape is a Concave Curve, is this possible?</p> <p>the shape looks like this:</p> <p><img src="https://i.stack.imgur.com/WhXKT.png" alt="enter image description here"></p> <p>Actually I wonder about the Power of CSS3 at this point,because I have read somewhere that is not possible to create a concave curve or other complex rounded shapes in CSS,and I appreciate <a href="http://stackoverflow.com/users/361755/imsky">imsky</a> answer,but it's based on absolute positioning but,I need to know that is it possible to create such a shape without using positioning?</p> <p><a href="http://css-tricks.com/well-rounded-compound-shapes-css/" rel="nofollow noreferrer">This article</a> is about to show the creation of this kind of rounded shape using CSS,but it's not exactly the same shape,but it's useful for peoples whom interested. </p>
25,315,581
0
<p>Are you sure you aren't calling from twice? Also a day path needs to be the argument to groupBy, not the full alias expression.</p>
40,193,273
0
<p>Can you try with something like this:</p> <pre><code>addListeners(player) { player.socket.on('disconnect', this.playerLeave.bind(this)); } playerLeave (socket) {...} </code></pre>
7,718,532
0
Adaptively render views in Ruby on Rails <p>In a RoR app, I have all partial views and a single layout page. If the request is ajax, I want to return only the partially rendered html, otherwise I want to return the fully rendered html page. </p> <p>What is the most efficient way to do this in RoR? I would prefer to do this at the application level rather than in every single controller action.</p>
22,666,494
0
<p>You probably missed the quotes:</p> <pre><code>$result = $DATABASE-&gt;rawQuery("SHOW TABLES LIKE '" . $TABLE . "'"); </code></pre>
18,385,021
0
Django ModelForm with prefix <p>I have a template with 2 forms. I would like to use "prefix" parameter to have different id in my rendered template like that :</p> <p>My first form :</p> <pre><code>&lt;input id="id_folder-name" maxlength="75" name="folder-name" type="text" /&gt; </code></pre> <p>My second form :</p> <pre><code>&lt;input id="id_file-name" maxlength="75" name="file-name" type="text" /&gt; </code></pre> <p>I my view, I instantiate forms :</p> <pre><code>self.form_class(prefix="folder") self.form_class_upload(prefix="file") </code></pre> <p>but it doesn't work, see console log :</p> <pre><code>[23/Aug/2013 11:15:57] "GET /sample/ HTTP/1.1" 200 1037 invalid &lt;tr&gt;&lt;th&gt;&lt;label for="id_name"&gt;Name:&lt;/label&gt;&lt;/th&gt;&lt;td&gt;&lt;ul class="errorlist"&gt;&lt;li&gt;This field is required.&lt;/li&gt;&lt;/ul&gt;&lt;input id="id_name" maxlength="75" name="name" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt; [23/Aug/2013 11:16:50] "POST /sample/new-folder/ HTTP/1.1" 200 634 </code></pre> <p>So it doesn't call my form_valid method...</p> <p>I don't understand why Django doesn't consider 'prefix' parameter for validation form.</p> <p>models.py:</p> <pre><code>from django.db import models class Inode(models.Model): name = models.CharField(max_length=75) file = models.FileField(upload_to="files", null=True) def __unicode__(self): return self.name </code></pre> <p>forms.py :</p> <pre><code>from django import forms from .models import Inode class FileUploadForm(forms.ModelForm): class Meta: model = Inode fields = ['name', 'file'] class NewFolderForm(forms.ModelForm): class Meta: model = Inode fields = ['name'] </code></pre> <p>views.py :</p> <pre><code>from django.views.generic import TemplateView from django.views.generic.edit import FormView from .forms import FileUploadForm, NewFolderForm from .models import Inode class MainView(TemplateView): template_name = "sample/browser.html" form_class = NewFolderForm form_class_upload = FileUploadForm def get_context_data(self, **kwargs): context = super(MainView, self).get_context_data(**kwargs) context['form_new_folder'] = self.form_class(prefix="folder") context['form_upload'] = self.form_class_upload(prefix="file") context["inodes"] = [i for i in Inode.objects.all()] return context class NewFolderView(FormView): template_name = "sample/browser.html" form_class = NewFolderForm success_url = "/sample" def form_invalid(self, form): invalid = super(NewFolderView, self).form_invalid(form) print "invalid" print form return invalid def form_valid(self, form): isvalid = super(NewFolderView, self).form_valid(form) print "valid" return isvalid </code></pre> <p>template :</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang='fr' xml:lang='fr'&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;sample&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action="{% url 'sample-new-folder' %}"&gt; {% csrf_token %} {{form_new_folder}} &lt;input type="submit" value="Valider"/&gt; &lt;/form&gt; &lt;form method="post" action="{% url 'sample-upload' %}"&gt; {% csrf_token %} {{form_upload}} &lt;input type="submit" value="Valider"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>rendered template :</p> <pre><code>&lt;html lang='fr' xml:lang='fr'&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;sample&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action="/sample/new-folder/"&gt; &lt;input type='hidden' name='csrfmiddlewaretoken' value='btopdI8WyHgqG2ZSTG81yhmaDa9Rk7Is' /&gt; &lt;tr&gt;&lt;th&gt;&lt;label for="id_folder-name"&gt;Name:&lt;/label&gt;&lt;/th&gt;&lt;td&gt;&lt;input id="id_folder-name" maxlength="75" name="folder-name" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;input type="submit" value="Valider"/&gt; &lt;/form&gt; &lt;form method="post" action="/sample/upload/"&gt; &lt;input type='hidden' name='csrfmiddlewaretoken' value='btopdI8WyHgqG2ZSTG81yhmaDa9Rk7Is' /&gt; &lt;tr&gt;&lt;th&gt;&lt;label for="id_file-name"&gt;Name:&lt;/label&gt;&lt;/th&gt;&lt;td&gt;&lt;input id="id_file-name" maxlength="75" name="file-name" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;th&gt;&lt;label for="id_file-file"&gt;File:&lt;/label&gt;&lt;/th&gt;&lt;td&gt;&lt;input id="id_file-file" name="file-file" type="file" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;input type="submit" value="Valider"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
33,503,436
0
jQuery Frame Breaker by Array of Domains <p>Using jQuery and an array of domains, I would like to create a frame breaker. I'd like to evaluate the top frame domain and if it's one of the domains in the array, then break it.</p> <pre><code>var domains = ["zoot.li", "domain.com"]; if ( jQuery.inArray( top.location.host, domains ) &gt; -1 ) { top.location.href = document.location.href ; } </code></pre> <p>It doesn't appear to be working, though. Any ideas?</p>
39,181,653
0
AutoCompleteDecorator.decorate(combobox); is not working perfectly in JTable <p>I'm using A <code>JCombobox</code> with <code>editable = true</code> in a <code>JPanel</code> and using a <code>JTable</code> in the same panel with a column that is set to show combobox as its field type. I applied</p> <pre><code> AutoCompleteDecorator.decorate(cb); </code></pre> <p>to <code>JCombobox</code> that is outside the <code>JTable</code> and its working perfectly <strong>But</strong> when I applied the same line of code to combobox within jtable which selects the first occurrence of the data that match the key typed.</p> <p>How can I resolve this issue. Any Suggestion ?</p> <p>Look at the image below in which the exact item is selected that I typed.</p> <p><a href="https://i.stack.imgur.com/whrTQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/whrTQ.png" alt="enter image description here"></a></p> <p>And this is the image of combobox within <code>JTable</code>.</p> <p><a href="https://i.stack.imgur.com/NIUXn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NIUXn.png" alt="enter image description here"></a></p> <p>When I press <kbd> w </kbd> key it select the first occurrence <code>windy</code> and set it in the cell.</p>
37,531,795
0
<p>The format of the value you are passing into the constructor of the <code>MediaTypeHeaderValue</code> is invalid. You are also trying to add multiple content types to the header value. </p> <p>Content type header takes a single type/subtype, followed by optional parameters separated with semi-colons <code>;</code> </p> <p>eg:</p> <pre><code>Content-Type: text/html; charset=ISO-8859-4 </code></pre> <p>For your result you need to decide on which one you want to use. <code>application/zip</code> or <code>application/octet-stream</code></p> <pre><code>result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/zip"); </code></pre> <p>Also, to avoid exception you can use the <code>MediaTypeHeaderValue.TryParse</code> method</p> <pre><code>var contentTypeString = "application/zip"; MediaTypeHeaderValue contentType = null; if(MediaTypeHeaderValue.TryParse(contentTypeString, out contentType)) { result.Content.Headers.ContentType = contentType; } </code></pre>
37,581,970
0
<p>A solution is to replot the line on top of the scatter:</p> <pre><code>df = pd.DataFrame([[1,2],[10,20]]) ax = df.plot.scatter(x=0, y=1, style='b') df.plot.line(x=0, y=1, ax=ax, style='b') </code></pre> <p>In this case, forcing points and lines both to be blue.</p> <p>If you don't need the properties of the scatter plot such as value dependent colours and sizes, just use a line plot with circles for the points:</p> <pre><code>df.plot.line(x=0, y=1, style='-o') </code></pre>
31,625,171
0
<p>It isn't a server side issue, every smartphone can apply a different orientation to the camera images. When you receive the image you have to access to its metadata (exif data si the exact name) to verify its rotation and other properties. Then you should apply to the picture the transformations you need.</p> <p>This should be a good startpoint to read exif data with PHP: <a href="http://php.net/manual/en/function.exif-read-data.php" rel="nofollow">http://php.net/manual/en/function.exif-read-data.php</a></p>
1,359,586
0
<p>You are on the right track this is indeed accomplished using ajax. Since you used the term postback I assume you are using asp.net webforms. There is a accompanying library asp.net ajax which you can find more about at <a href="http://www.asp.net/ajax/" rel="nofollow noreferrer">http://www.asp.net/ajax/</a> you can start learning how to use it at <a href="http://www.asp.net/learn/ajax/tutorial-01-cs.aspx" rel="nofollow noreferrer">http://www.asp.net/learn/ajax/tutorial-01-cs.aspx</a></p> <p>just like webforms is a abstraction of http so is asp.net ajax to ajax. Although it certainly makes some things easier it can also make other things not envisioned by the authors harder then they need to be. For more advanced ussages you might want to check out jquery at <a href="http://jquery.com/" rel="nofollow noreferrer">http://jquery.com/</a> which goes together great with asp.net MVC. There are also allot more information, samples and libraries in the public domain for jquery then for asp.net ajax. But asp.net ajax should get you on your way fastest if you already have a webforms codebase.</p>
28,755,626
0
<p>If your intention is to automate the actions for testing of your web from an Android app, try <a href="https://github.com/calabash/calabash-android/" rel="nofollow">calabash-android</a>, it's like Selenium for Android.</p> <p>Calabash-android supports <code>WebView</code> manipulation, in your case entering text as well.</p> <blockquote> <p>You can use the enter_text method to enter text in a webview (in addition to any other android widget).</p> <p><code>enter_text("webView css:'input.login'", "run")</code></p> <p>This will enter the text "run" into the first input field of the class 'login'.</p> </blockquote> <p>Source: <a href="https://github.com/calabash/calabash-android/wiki/06-webview-support" rel="nofollow">https://github.com/calabash/calabash-android/wiki/06-webview-support</a></p>
39,229,331
0
Error in PDF Export Options in Angular DataTable <p>While Exporting PDF The Columns are overlapping from 4th Column.The Other Options(copy,excel,print) are Working Fine. I got Like this.</p> <p><a href="https://i.stack.imgur.com/nmPV1.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmPV1.jpg" alt="enter image description here"></a></p> <p>(I ve erased the original details in the Screen Shot)</p> <p>This is My Snippet</p> <pre><code> extend:'pdf', title: 'My Title', orientation: 'landscape', pageSize: 'A4', text: 'PDF', exportOptions: { columns: [0,1,2,3,4,5,6,7,....] } </code></pre>
8,031,814
0
<p>Correct...summing the element-wise products will be quicker:</p> <pre><code>n = 1000 A = randn(n); B = randn(n); tic sum(sum(A .* B)); toc tic sum(diag(A * B')); toc </code></pre> <pre class="lang-or-tag-here prettyprint-override"><code>Elapsed time is 0.010015 seconds. Elapsed time is 0.130514 seconds. </code></pre>
12,760,579
0
<p>There is a feature called 'collection merging' that does exactly this. See section 3.3.3.4.1. "Collection merging" in the <a href="http://static.springsource.org/spring/docs/3.0.x/reference/beans.html" rel="nofollow">Spring documentation</a> or the <a href="http://greybeardedgeek.net/2008/04/23/spring-collection-merging/" rel="nofollow">2008 blog post (with an example) that I wrote on the subject</a>.</p>
11,847,697
0
<p>What is the logic that you want?</p> <p>Let me guess that you want Mexicans with more than 3 children, Americans with 2, and Japanese with 1. In this case, you would something like:</p> <pre><code>having (case when count(nationality = 'Mexican' then children end) &gt; 3 then 'true' when count(nationality = 'American' then children end) = 2 then 'true' when count(nationality = 'Japanese' then children end) = 1 then 'true' end) = 'true' </code></pre> <p>However, even this seems strange. Why are you counting "children". What are you grouping on? If children is just a field in the data, then this should be a WHERE clause instead of a HAVING clause:</p> <pre><code>where (nationality = 'Mexican' and children end &gt; 3) or (nationality = 'American' and children = 2) or (nationality = 'Japanese' and children = 1) </code></pre>
17,024,054
0
<p>Use the <code>New Class</code> as normal but then specify your abstract class as the <code>Superclass</code>. Then check <code>Which methods stubs would you like to create</code> -> <code>inherited abstract methods</code></p>
36,267,287
0
<p>Implicit sharing in Qt follows the CoW (copy on write) paradigm - objects will implicitly share the same internal resource as long as it is not modified, if some of the copies attempts to modify the resource, it will be "detached" from the shared resource, copy it and apply the modifications to it. </p> <p>When object lifetime ends, it decrements the reference counter for the shared resource, and if it is zero that means no other object uses it, so it is deleted. If the reference count is more than zero, the resource remains alive until there are objects, referencing it.</p> <p>In case 1 the shared resource will be deleted, as there are no more objects referencing it.</p> <p>In case 2 it will be deleted as well, because <code>aImg</code> will be out of scope by the time <code>tImg</code> is deleted.</p>
16,958,349
1
What's the scope for Gmail's OAuth2 IMAP access? <p>I'm using <a href="http://code.google.com/p/google-api-python-client/" rel="nofollow">google-api-python-client</a> and <a href="https://bitbucket.org/mjs0/imapclient" rel="nofollow">imapclient</a> libraries to try get IMAP access to Gmail.</p> <p>When going through the authentication flow, I'm getting "invalid scope" errors. I've tried both <code>https://mail.google.com</code> and <code>https://mail.google.com/mail/feed/atom</code> as scopes.</p> <p>Here's what I'm trying to do:</p> <pre><code>from oauth2client.appengine import OAuth2Decorator SCOPE = "https://mail.google.com" # SCOPE = "https://mail.google.com/mail/feed/atom" oauth2decorator_gmail = OAuth2Decorator(client_id="CLIENT_ID", client_secret="CLIENT_SECRET", scope=SCOPE, callback_path='/mycallbackurl') class AuthenticateSyncServices(webapp2.RequestHandler): @oauth2decorator_gmail.oauth_required def get(self): self.response.write("Authenticated") </code></pre> <p>And here's the stacktrace:</p> <pre><code>INFO 2013-06-06 08:56:36,686 client.py:1304] Failed to retrieve access token: { "error" : "invalid_scope" } Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1536, in __call__ rv = self.handle_exception(request, response, e) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1530, in __call__ rv = self.router.dispatch(request, response) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1278, in default_dispatcher return route.handler_adapter(request, response) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 1102, in __call__ return handler.dispatch() File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 572, in dispatch return self.handle_exception(e, self.app.debug) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1/webapp2.py", line 570, in dispatch return method(*args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/util.py", line 68, in check_login handler_method(self, *args) File "/Users/John/Projects/my-app/backend/oauth2client/appengine.py", line 787, in get credentials = decorator.flow.step2_exchange(self.request.params) File "/Users/John/Projects/my-app/backend/oauth2client/util.py", line 128, in positional_wrapper return wrapped(*args, **kwargs) File "/Users/John/Projects/my-app/backend/oauth2client/client.py", line 1310, in step2_exchange raise FlowExchangeError(error_msg) FlowExchangeError: invalid_scope </code></pre>
20,792,798
0
Show dialog when the input data is validated <p:confirmDialog> <p>For my school project I have to realize a mini website where I use primefaces framework. In a form I want after pressing the Save button two things: 1 - Validate the data entered. that's why I put</p> <pre><code>&lt;p:message for="date" /&gt; and &lt;p:message for="zone" /&gt; </code></pre> <p>As the values ​​are not correct, the dialog box should not be displayed. 2 - When all data is correct, and I click Save, I want to display my dialog box.</p> <p>Now I can not. Can you help me? I use version 4 primefaces.</p> <pre><code>&lt;h:form&gt; &lt;p:panel id="panel" header="Create" style="margin-bottom:10px;border-color:blueviolet" &gt; &lt;p:messages id="messages" /&gt; &lt;h:panelGrid columns="3"&gt; &lt;h:outputLabel for="date" value="Date : *" /&gt; &lt;p:calendar locale="fr" id="date" value="#{newBusinessCtrl.exercice.debut}" required="true" label="date" showButtonPanel="true"/&gt; &lt;p:message for="date" /&gt; &lt;h:outputLabel for="zone" value="Zone Monétaire: *" /&gt; &lt;p:selectOneMenu id="zone" value="#{newBusinessCtrl.exercice.zoneChoice}" &gt; &lt;f:selectItem itemLabel="Choice " itemValue="" /&gt; &lt;f:selectItems value="#{newBusinessCtrl.exercice.zones}" var="azone" itemLabel="#{azone}" itemValue="#{azone}" &gt; &lt;/f:selectItems&gt; &lt;p:message for="zone" /&gt; &lt;/p:selectOneMenu&gt; &lt;p:message for="zone" /&gt; &lt;/h:panelGrid&gt; &lt;/p:panel&gt; &lt;p:commandButton update="panel" value="Save" icon="ui-icon-check" style="color:blueviolet" onclick="choice.show()"/&gt; &lt;p:confirmDialog message="Would you like to create accounts automatically ?" header="Account creation" severity="alert" widgetVar="choice" appendTo="@(body)"&gt; &lt;p:button outcome="personalizeAccount" value="Personalize" icon="ui-icon-star" /&gt; &lt;p:button outcome="autoAccount" value="Continue" icon="ui-icon-star" /&gt; &lt;/p:confirmDialog&gt; </code></pre> <p></p>
25,395,651
0
Storing PBKDF2 Settings Alongside Password <p>I'm experimenting with PBKDF2 for my passwords right now, and it dawned on me that if I were to ever upgrade to a faster machine in the future, I would want to increase the number of PBKDF2 iterations. However, this would invalidate all the current passwords that I have stored. One idea I've seen was to store the PBKDF2 settings along with the password (similar to how you store the salt) such as the iteration count and the PRF used (SHA-256, SHA-512) at the time of the hash creation. It sounds like a good idea in terms of backwards compatibility, but I wanted to know if there are any drawbacks to doing this. Any insight into this would be appreciated.</p>
33,466,149
0
<p>You are using <a href="http://stackoverflow.com/q/3602827/560648">integer division</a>, so your series converges really, really quickly.</p> <p>Make <code>s</code> and <code>a</code> be <code>double</code>s, and replace <code>4</code> with <code>4.0</code>.</p>
10,069,415
0
<p>The success function is a callback; it's designed to be called AFTER a response has been received. How could you determine success or error if it was called before the server thread execution had completed? The call to Sleep suspends the current server thread, so of course your response is going to take five seconds to come back.</p> <p>The asynchronous part would apply to Javascript code that directly follows your ajax post. For example:</p> <pre><code>&lt;script language="javascript"&gt; $(function() { var tempParam = { ttid: 100 }; var param = $.toJSON(tempParam); $.ajax({ type: "POST", url: "testservice.aspx/sampleService", data: param, contentType: "application/json; charset=utf-8", dataType: "json", async: true, error: function() { alert("Error"); }, success: function(msg) { alert("Success") alert(msg.d) } }); alert('This alert is asynchronous! We do not know yet if the ajax call will be successful because the server thread is still sleeping.'); });​ &lt;/script&gt; </code></pre>
20,341,420
0
Whats the meaning of this" vector(vector'HIGH)='1'"? <p>I know 'HIGH its a data attribute, that return the upper array index, but the vector out side the parentheses i dont get it. Its the same as vector'HIGH??</p> <p>Tell me if someone need more info or something</p>
30,203,867
0
Prevent intermediate compass file output when piping <p>I'm using <code>gulp-compass</code> to compile scss files. However, I'm concatenating output into a single file.</p> <p>This all works fine, but I'm noticing that compass itself is writing the individual files to the output directory.</p> <p>I'm left with the individual files, as well as the concatenated result.</p> <p>Is there any way to prevent that intermediate output?</p> <pre><code>gulp.task('compass:dev', function() { return gulp.src(appPath + '/**/*.scss') .pipe(plugins.compass({ css: distPath + '/css', sass: appPath })) .pipe(plugins.concat('app.css')) .pipe(gulp.dest(distPath + '/css')); }); </code></pre>
1,518,073
0
Embed pdb into assembly <p>I want my application to be distributable as a <em>single .exe file</em> but I want to be able to get nice error reports with source code line numbers (the application simply sends email with <code>exception.ToString()</code> and some additional information when unhandled exception occurs).</p> <p>Is there any way to embed .pdb into assembly?</p>
27,909,981
0
<p>In case you really want to use Streams,</p> <p>Inside your onClick method for your save button, you want to call this:</p> <pre><code>try { FileOutputStream fos = getApplicationContext().openFileOutput("file_name.txt", Context.MODE_PRIVATE); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(obj); os.close(); } catch(Exception e) { //handle exceptions } </code></pre> <p>which will save whatever you defined in obj to a file named "file_name.txt".</p> <p>To read obj back from this textfile, you can call:</p> <pre><code>try { FileInputStream fis = getApplicationContext().openFileInput("file_name.txt"); ObjectInputStream is = new ObjectInputStream(fis); my_obj = (MyObject) is.readObject(); is.close(); } catch(Exception e) { //handle exceptions } </code></pre>
27,615,170
0
Transfering data from textbox to 2D Array <p>I am a new in C sharp and a little stupid, I have a problem with my project, hope you can help me!</p> <p>Suppose I have a textbox1 as follow (n rows x n columns):</p> <pre><code>0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 </code></pre> <p>Now I want to transfer data from this text box into an existed 2d Matrix that will store data in Integer Type.</p> <p>I tried this but it seem to not works:</p> <pre><code>private void GETNUMERICDATA() { string txt = textbox1.text; txt = txt.Replace(" ", string.Empty); for (int k = 0; k &lt; 32; k++) { for (int l = 0; l &lt; 32; l++) { for (int i = 0; i &lt; txt.Length; i++) { char chr = txt[i]; if (chr == '0') { Matrix[k, l] = (int)char.GetNumericValue('0'); } else { if (chr == '1') Matrix[k, l] = (int)char.GetNumericValue('1'); } } } } } </code></pre> <p>Anybody can help me how to do it? All your support would be highly appreciated.</p>
18,675,015
0
org.springframework.beans.factory.NoSuchBeanDefinitionException exception in UNIX <p>I have my java spring standalone project which works fine in windows but when I create jar file and executes that jar file by using shell script, it gives me <code>org.springframework.beans.factory.NoSuchBeanDefinitionException</code>. It seems that in unix it is unable to load the beans and unable to do component scan.</p> <p>I have application contex file as below:</p> <pre><code>&lt;context:annotation-config /&gt; &lt;context:component-scan base-package="com.ubs.lazar" /&gt; &lt;context:property-placeholder location="oracle.properties" /&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="${batch.jdbc.driver}" /&gt; &lt;property name="url" value="${batch.jdbc.url}" /&gt; &lt;property name="username" value="${batch.jdbc.user}" /&gt; &lt;property name="password" value="${batch.jdbc.password}" /&gt; &lt;/bean&gt; &lt;bean id="daoFactory" class="com.ubs.mzq.xen.db.XenDaoFactory"&gt; &lt;property name="databaseName" value="oracle" /&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;/bean&gt; &lt;tx:annotation-driven/&gt; </code></pre> <p>And I am invoking and load the configuration from java as below:</p> <pre><code>ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:META-INF/application-context.xml"); AwardEventService awardEventService = (AwardEventService) context.getBean("awardEventServiceImpl"); </code></pre> <p>Can you please somebody helps to how to overcome this issue in UNIX.</p> <p>Thanks</p>
40,999,263
0
File Uploading with AJAX fails <p>I'm trying to test a file upload method with a simple HTML test page.</p> <p>The page is simply supposed to take a document's id, the document itself, package it up into form data and send it off to the server(with a token for authentication).</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;h4&gt;Id&lt;/h4&gt; &lt;input typ"text" id="Id" /&gt; &lt;h4&gt;token&lt;/h4&gt; &lt;input typ"text" id="token" /&gt; &lt;br /&gt; &lt;br /&gt; &lt;input type="file" id="upload" name="userFile" multiple/&gt; &lt;input type="submit" id="submit" /&gt; &lt;/div&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt; &lt;/script&gt; &lt;script&gt; let token,id,idName, fileSelect,data; function uploadFiles(data) { if (data) { $.ajax({ url: "http://uploaddomain.com/uploadMethod", type: "POST", data: data, processData: false, contentType: false, headers: { "Authorization" : 'Bearer%20' + token, "Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8" }, success: function (res) { console.log('success',res) }, error: function (err) { console.log('err',err) } }); } } } $( "#submit" ).click(function() { var fileSelect = document.getElementById('upload'); let file = fileSelect.files[0]; id = $("#Id").val(); token = $("#token").val(); idName = "Id"; var uploadButton = document.getElementById('upload-button'); data = new FormData(); data.append(idName, id ); data.append("fileUpload", file ); uploadFiles(data); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The error from the API is code 400, {"Message":"File not found in Request"}"</p> <p>Any suggestions on what I'm doing wrong?</p>
23,074,301
0
How to assign a big stream bit into one column vector <p>I have a large bit stream. (e.g. 10110001010101000.....001 size thousands or millions)</p> <p>I want to assign this bit stream into a one column vector x.</p> <pre><code> x = zeros(n,1); </code></pre> <p>I have tried to use some mod or rem operations, there will have some problems. </p> <p>I guess it caused by the integer size.</p> <p>I want to ask is there any good method to solve this problem? </p> <p>Thanks for reading.</p>
850,722
0
<p>Inside of your NSView's .m. Obviously you might want to hook this up to a UI or something.</p> <pre><code>- (void)awakeFromNib { // Have to wait for the window to be onscreen, graphics context ready, etc [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFired:) userInfo:NULL repeats:NO]; } - (void)timerFired:(NSTimer *)aTimer { [self lockFocus]; NSDate* then = [NSDate date]; int callIdx = 0; for( callIdx = 0; callIdx &lt; 1000; callIdx++ ) { [self drawRect:[self bounds]]; } NSDate* now = [NSDate date]; [self unlockFocus]; NSLog(@"Took %f seconds", [now timeIntervalSinceDate:then]); } - (void)drawRect:(NSRect)rect { [[NSColor redColor] set]; NSRectFill(rect); } </code></pre>
15,765,045
0
<p>This is not a good idea. First off Apple would not allow the two different applications and even if they did there is nothing stopping an iPhone 4 user from downloading your iPhone 5 Version or visa versa. The best way to go about handling the differences between sizes is either through the nib /storyboard or programmatically within a single application. </p>
31,483,321
0
<p>You could also set the image to <code>display: block</code> and add <code>padding</code>, if it does not mess with your layout.</p>
8,730,567
0
<p>Instead of pulling back a 1000 rows of data, why not make 2 sql calls? One to query for the first record:</p> <pre><code>SELECT id FROM (SELECT id FROM `table` LIMIT 0, 1000) tmp ORDER BY id LIMIT 1 </code></pre> <p>And one for the second:</p> <pre><code>SELECT id FROM (SELECT id FROM `table` LIMIT 0, 1000) tmp ORDER BY id DESC LIMIT 1 </code></pre>
35,752,123
0
Can two or more classes send data to the same IntentService? <p>I'm a beginner in Android programming, and I was reading about handling time consuming operations via IntentServices. However, I have this doubt - </p> <p>Can I have two classes (say A and B) issuing a call to the same class (C) extending the IntentService? Is this possible and/or safe?</p> <p>If so, how do I help the IntentService differentiate between the two calling classes?</p> <p>I was thinking of this way:</p> <pre><code>public class DoSomething extends IntentService{ @Override public void onHandleIntent(Intent intent){ Bundle data = intent.getExtras(); String type = data.getString("TagForClass"); if(type.equals("TagForClassA")){ //Do operations for Class A } else if(type.equals("TagForClassB")){ //Do operations for Class B } } } </code></pre> <p>Will this method work?</p>
1,619,982
0
<p>Fire up firebug and see if you're actually getting Javascript sent down the wire. Is there a 404 or 500 whooshing by? Or is code loading correctly? Is your event handler being called? Add a <code>console.log</code> or <code>alert</code> to your handler to test. Is your handler even being attached? Did you put the whole thing in a <code>$(document).ready()</code>? Did you put your script after the <code>jquery.js</code> file, so that jQuery is available when your script attaches event handlers? In general, you know, do that debugging thing we all love so much.</p>
15,976,195
0
<p>This is my OK code in QT 4.7:</p> <pre><code> //add combobox list QString val; ui-&gt;startPage-&gt;clear(); val = "http://www.work4blue.com"; ui-&gt;startPage-&gt;addItem(tr("Navigation page"),QVariant::fromValue(val)); val = "https://www.google.com"; ui-&gt;startPage-&gt;addItem("www.google.com",QVariant::fromValue(val)); val = "www.twitter.com"; ui-&gt;startPage-&gt;addItem("www.twitter.com",QVariant::fromValue(val)); val = "https://www.youtube.com"; ui-&gt;startPage-&gt;addItem("www.youtube.com",QVariant::fromValue(val)); // get current value qDebug() &lt;&lt; "current value"&lt;&lt; ui-&gt;startPage-&gt;itemData(ui-&gt;startPage-&gt;currentIndex()).toString(); </code></pre>
13,636,395
0
<p>Sometimes the element you are trying to find is loading, s0 will throw an exception using <pre> <code> <code>findElement(By.xpath(xpathLocator))</code> </code> </pre></p> <p>Therefore we would need do what Dejan Veternik has recommended, it will help wait until the ELEMENT has been loaded in the webpage, I am passing Selenium and extracting webdriver, this is helpful incase you are using WebDriverBackedSelenium just like me ...</p> <pre><code> private boolean isElementPresent(WebDriverBackedSelenium driver, String id) { try { driver.getWrappedDriver().findElement(By.id(id)); return true; } catch (Exception e) { return false; } } </code> </pre>
25,003,429
1
Python module installed 2.7 absent in 3.4, Mac Mavericks <p>I searched, but could not find this same issue answered elsewhere.</p> <p>I installed xlwt using easy_install. 'python' typed into the terminal defaults to opening 2.7. I'd like to change this, but it's not my question, since for now I can run python3.4 to get the newer version I installed.</p> <p>After using easy_install xlwt, xlwt will import into the python 2.7 interpreter/shell, but not the python 3.4 interpreter/shell.</p> <p>How do I add it to 3.4?</p> <p>Thank you.</p>
12,563,124
0
Sending apps to other devices <p>How can I share my app with friends? I created my app in eclipse and can run the app on my device but how can I share it without adding it to the play market?</p>
11,761,122
0
<pre><code>from o in dc.Orders group o by new { o.Product.ProdName, o.Size.Size } into g select new { g.Key.ProdName, g.Key.Size, Total = g.Sum(or =&gt; or.Qty))}; </code></pre>
38,943,954
0
<p>If you want to return two values, return a <code>std::vector</code> with them. Maybe a <code>std::pair</code>, or a class. As far as why, this is just how C++ works. Comma is just an operator, like + or -. It discards its left operand and returns the right one. <code>return</code> returns the value of its expression from the function. The rest you can figure out yourself.</p>
6,545,055
0
<p>You can use the <code>RowCommand</code> instead, like..</p> <pre><code> protected void cgvProjectPropertyList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { e.CommandArgument // will Return current Row primary key value, rather row Index } } </code></pre> <p>and you need to make sure to register the event in the GridView <code>OnRowCommand="cgvProjectPropertyList_RowCommand"</code></p>
9,295,533
0
<p>You need define your post contain some file inside with multipart HTML tag</p> <pre><code>&lt;%= semantic_form_for @imgD, :html =&gt; { :multipart =&gt; true } do |form| %&gt; &lt;%= form.input :img%&gt; &lt;%= form.actions %&gt; &lt;%end%&gt; </code></pre>
25,855,210
0
<p>As documentation said:</p> <pre><code>void QTextEdit::setAlignment(Qt::Alignment a) [slot] </code></pre> <p>Sets the alignment of the current paragraph to <code>a</code>. Valid alignments are <code>Qt::AlignLeft</code>, <code>Qt::AlignRight</code>, <code>Qt::AlignJustify</code> and <code>Qt::AlignCenter</code> (which centers horizontally).</p> <p>Link: <a href="http://qt-project.org/doc/qt-5/qtextedit.html#setAlignment" rel="nofollow noreferrer">http://qt-project.org/doc/qt-5/qtextedit.html#setAlignment</a></p> <p>So as you can see you should provide some alignment to each paragraph.</p> <p>Little example:</p> <pre><code>QTextCursor cursor = ui-&gt;textEdit-&gt;textCursor(); QTextBlockFormat textBlockFormat = cursor.blockFormat(); textBlockFormat.setAlignment(Qt::AlignRight);//or another alignment cursor.mergeBlockFormat(textBlockFormat); ui-&gt;textEdit-&gt;setTextCursor(cursor); </code></pre> <p>Which result I get on my computer?</p> <p><img src="https://i.stack.imgur.com/OSTXx.png" alt="enter image description here"></p> <p>Or something closer to your question:</p> <pre><code>ui-&gt;textEdit-&gt;clear(); ui-&gt;textEdit-&gt;append("example"); ui-&gt;textEdit-&gt;append("example"); QTextCursor cursor = ui-&gt;textEdit-&gt;textCursor(); QTextBlockFormat textBlockFormat = cursor.blockFormat(); textBlockFormat.setAlignment(Qt::AlignRight); cursor.mergeBlockFormat(textBlockFormat); ui-&gt;textEdit-&gt;setTextCursor(cursor); ui-&gt;textEdit-&gt;append("example"); cursor = ui-&gt;textEdit-&gt;textCursor(); textBlockFormat = cursor.blockFormat(); textBlockFormat.setAlignment(Qt::AlignCenter); cursor.mergeBlockFormat(textBlockFormat); ui-&gt;textEdit-&gt;setTextCursor(cursor); </code></pre> <p>Result:</p> <p><img src="https://i.stack.imgur.com/4SE5t.png" alt="enter image description here"></p>
36,039,610
0
<p><a href="https://developer.wordpress.org/reference/functions/has_post_thumbnail/" rel="nofollow"><code>has_post_thumbnail()</code></a> takes an optional parameter of <code>$post</code>, which can be a post ID or a WP_Post object.</p> <p>The default is the global <code>$post</code> object. You need to pass the post ID to tell WordPress to check the recent post in your loop instead of the global <code>$post</code> object. Like this:</p> <pre><code>if ( has_post_thumbnail( $recent['ID'] ) ) { $photo = get_the_post_thumbnail( $recent['ID'], 'large' ); echo '&lt;div class="section1-2singlephoto"&gt;' . $photo . '&lt;/div&gt;'; } else { echo 'no Thumbnail'; } </code></pre>
17,200,611
0
<p>I just typed this up and works perfect here</p> <p><strong>Animation</strong></p> <pre><code>public class ResizeWidthAnimation extends Animation { private int mWidth; private int mStartWidth; private View mView; public ResizeWidthAnimation(View view, int width) { mView = view; mWidth = width; mStartWidth = view.getWidth(); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { int newWidth = mStartWidth + (int) ((mWidth - mStartWidth) * interpolatedTime); mView.getLayoutParams().width = newWidth; mView.requestLayout(); } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); } @Override public boolean willChangeBounds() { return true; } } </code></pre> <p><strong>usage</strong></p> <pre><code>if(animate) { ResizeWidthAnimation anim = new ResizeWidthAnimation(leftFrame, leftFragmentWidthPx); anim.setDuration(500); leftFrame.startAnimation(anim); } else { this.leftFragmentWidthPx = leftFragmentWidthPx; LayoutParams lp = (LayoutParams) leftFrame.getLayoutParams(); lp.width = leftFragmentWidthPx; leftFrame.setLayoutParams(lp); } </code></pre>
27,146,581
0
<pre><code>if(is_array($variable) &amp;&amp; count($variable) &gt; 0) { foreach($variable as $key =&gt; $value) { //Your code } ) </code></pre>
2,091,157
0
<p>I don't think there's any Python-specific limits. UDP packets have a theoretical limit of circa 65kb and TCP no upper limit, but you'll have flow control problems if you use packets much more than a few kilobytes.</p>
30,258,295
0
Is my HTTP protocol design correctly implemented in the coding? <p>It's my very simple client-server application. Client sends some commands to the server and server gives back the output to the client. However, my special concern is about the <code>GET</code> command sent to the server. The client request <code>GET filename</code> to download a named file. That file ultimately gets downloaded into the client directory with the HTTP response headers, as I have designed my protocol.</p> <p>Now I am afraid if my coding follows the protocol accurately. Especially the HTTP response headers with the Line break (in both client and server side).</p> <p>PROTOCOL DESIGN:</p> <p>Client:</p> <pre><code>syntax: GET namedfile CRLF CRLF meaning: downloading the named file from the server representation: text file </code></pre> <p>server:</p> <pre><code>syntax: Status: ok CRLF Length: 20 bytes CRLF CRLF File contents meaning: The file exist in the server and ready to download representation: text file </code></pre> <p>CODE:</p> <p>ServerSide:</p> <pre><code> ................. ................. else if (request.startsWith("GET")) { System.out.println(""); String filename = request.substring(4); File file = new File(System.getProperty("user.dir")); File[] files = file.listFiles(); if (fileExists(files, filename)) { file = new File(filename); int fileSize = (int) file.length(); outputToClient.print("Status OK\r\n" + "Size " + fileSize + "KB" + "\r\n" + "\r\n" + "File " + filename + " Download was successfully\r\n"); outputToClient.flush(); // reading files fis = new FileInputStream(file); os = socket.getOutputStream(); byte[] buffer = new byte[2^7-1]; int bytesRead = 0; while ((bytesRead = fis.read(buffer))!= -1) { os.write(buffer, 0, bytesRead); } os.close(); fis.close(); } else { outputToClient.print("Status 400\r\n" + "File " + filename + " not found\r\n" + "\r\n"); outputToClient.flush(); } } outputToClient.flush(); } ................. ................. </code></pre> <p>ClientSide:</p> <pre><code> ............ ............ if (request.startsWith("GET")) { File file = new File(request.substring(4)); is = socket.getInputStream(); fos = new FileOutputStream(file); byte[] buffer = new byte[socket.getReceiveBufferSize()]; int bytesReceived = 0; while ((bytesReceived = is.read(buffer)) &gt;=0) { //while ((bytesReceived = is.read(buffer))&gt;=buffer) { fos.write(buffer, 0, bytesReceived); } request = ""; fos.close(); is.close(); } ................. ................. </code></pre>
19,470,436
0
<p>The PID is</p> <pre><code>PID := DWORD(List.Objects[Index]); </code></pre> <p>Where Index is the index of the item of interest.</p>
23,657,120
0
argument getting truncated while printing in unix after merging files <p>I am trying to combine two tab seperated text files but one of the fields is being truncated by awk when I use the command (pls suggest something other than awk if it is easier to do so)</p> <pre><code>pr -m -t test_v1 test.predict | awk -v OFS='\t' '{print $4,$5,$7}' &gt; out_test8 </code></pre> <p>The format of the test_v1 is</p> <pre><code>478 192 46 10203853138191712 </code></pre> <p>but I only print 10203853138 for $4 truncating the other digits. Should I use string format? Actually I found out after a suggestion given that pr -m -t itself does not give the correct output</p> <pre><code>478^I192^I46^I10203853138^I^I is the output of the command pr -m -t test_v1 test.predict | cat -vte </code></pre> <p>I used paste test_v1 test.predict instead of pr and got the right answer.</p>
40,288,900
0
2 flexbox columns side by side, both with fluid height, with one never exceeding the height of the other <p>I'm using flexbox to show two <code>&lt;div&gt;</code>s side by side. One has a video and the other has text. Neither <code>&lt;div&gt;</code> has a fixed height. I want the text div to never be taller than the video div. If the text div would naturally be taller than the video div then I want the text div to have a vertical scrollbar. How can I do this? I've tried adding <code>overflow-y: auto</code> to the text div, but that didn't work. Here is a demo of the problem:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } body { margin: 0; background-color: #ddd; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.42857143; } .wrapper { display: flex; flex-wrap: wrap; } .video, .text { padding: 10px; } .video { position: relative; width: 75%; background-color: #999; } .text { width: 25%; background-color: #bbb; } @media (max-width: 767px) { .video, .text { width: 100%; } } .red { position: absolute; top: 10px; right: 10px; bottom: 10px; left: 10px; background-color: red; } /* From embedresponsively.com */ .embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="wrapper"&gt; &lt;div class="video"&gt; &lt;div class="red"&gt;&lt;/div&gt; &lt;div class="embed-container"&gt;&lt;iframe src="http://www.youtube.com/embed/QILiHiTD3uc" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="text"&gt; &lt;p&gt; When you change the width of your browser window, the video's dimensions will change. &lt;/p&gt; &lt;p&gt; I want the height of this text div to never exceed the height of the video. It should have a vertical scrollbar instead. &lt;/p&gt; &lt;p&gt; For testing purposes, I have created the &lt;code&gt;div.red&lt;/code&gt; element. Currently, it is possible to expose this div by resizing your browser window (you will see red below the video). I want to make it so that exposing the &lt;code&gt;div.red&lt;/code&gt; element is not possible. I want this text div to have a vertical scrollbar instead. &lt;/p&gt; &lt;p&gt; Note that you need to have your browser window at least 768px wide in order for the video div and text div to be side by side. &lt;/p&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
38,632,018
0
<p>Regarding the blank-page issue: You're just processing, not outputting anything. You could simply post a redirect-header at the end - possibly according to errors occuring or not.</p> <pre><code>// 307 Temporary Redirect header("Location: /foo.php",TRUE,307); </code></pre> <p>..or just output stuff after processing. A good practice might be to keep processing and the form-display in one file - then you could pre-populate the form with the fields that did not produce errors and mark those that failed so the user can try again.</p> <p>Regarding the checkbox-group issue:</p> <pre><code>echo implode( ", ", $_POST['checkbox-group'] ); </code></pre> <p>to prove to yourself you actually got something passed along:</p> <pre><code>header("Content-type:text/plain;charset=utf-8"); echo print_r($_POST,TRUE); </code></pre>
39,606,139
0
<pre><code>canvas = this.transform.FindChild ("HealthCanvas").gameObject; hb = canvas.transform.FindChild ("HealthBar").gameObject; </code></pre>
2,394,923
0
rails retrieving button_to parameter in the controller <p>I iterate over an array of CartItem class I created and populate a view file. </p> <pre><code>&lt;td&gt;&lt;%= button_to "remove", :action =&gt; :remove_from_cart, :id =&gt; cart_item %&gt;&lt;/td&gt; </code></pre> <p>I would like to be able to get a CartItem instance from params[:id] in the remove_from_cart. <code>param[:id]</code> returns something like <code>"#&lt;CartItem:0xb77a3dcc&gt;":String</code> and i could not figure out how to treat it like a CartItem object. </p> <p>I know the code above works for objects descending from ActiveRecord::Base, and CartItem does not descend from it. I am guessing that might be the reason.</p> <p>any pointers would be much appreciated, thanks</p>
38,728,967
0
<p>Your code is actually SCSS, not SASS. </p> <p>To make it work as SASS, you need to get rid of curly braces, semi-colons and add some spaces. </p> <p>Here's the corrected code: </p> <pre><code>@each $flag in USA, EUR, JPN a.#{$flag} display:inline-block overflow:hidden width: 0 height: 11px padding-left: 16px background: url('http://res.cloudinary.com/mrengy/image/upload/v1470163121/#{$flag}.gif') no-repeat </code></pre> <p><a href="https://codepen.io/vic3685/pen/akaEyo?editors=1100" rel="nofollow">https://codepen.io/vic3685/pen/akaEyo?editors=1100</a></p>
3,148,215
0
<p>Try cleaning up your code a bit, there are a few missing semicolons (<a href="http://www.jslint.com/" rel="nofollow noreferrer">http://www.jslint.com/</a>).</p> <p>I worked with extjs some time ago, and had the same problem with a window rendering in Firefox and not in IE. Maybe IE's JS engine is more sensitive to syntactical errors.</p>
30,748,674
0
<p>Apparently, you need to download the Gear Fir Manager from apps.samsung.com/gearfit not from the samsung app store. The Samsung app store version does not work, you need to download the latest gear app from the website, gd luck</p>
15,185,051
0
<p>Perhaps use an explicit local redirect:</p> <pre><code>read answer &lt; /dev/tty </code></pre>
29,433,031
0
<p>If the possible duplicate doesn't fulfil your needs here's a way to do it - <a href="http://plnkr.co/edit/E7vYgBPwd1sBeObEl2vd?p=preview" rel="nofollow">Plunker</a>.</p> <p>JS</p> <pre><code>app = angular.module("app", []); app.directive("test", [ function() { return { restrict: "E", template: "&lt;div ng-repeat='item in ts.items track by $index' ng-init='ts.blah($index, $last)'&gt;{{$index}}&lt;/div&gt;", scope: {}, controllerAs: "ts", bindToController: true, controller:function() { var ts = this; ts.items = [0, 1, 2, 3, 4]; ts.blah = function(index, last) { console.log(index, last); if (last) { // Do your stuff } } } } }]); </code></pre> <p>Markup</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="style.css"&gt; &lt;script src="script.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body ng-app="app"&gt; &lt;test&gt;&lt;/test&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The output from the console is:</p> <blockquote> <p>0 false <br> 1 false <br> 2 false <br> 3 false <br> 4 true</p> </blockquote> <p>so you should (in theory) be able to rely on the last repeat element being created last.</p>
20,581,545
0
Best Elliptical Fit for irregular shapes in an image <p>I have an image with arbitrary regions shape (say objects), let's assume the background pixels are labeled as zeros whereas any object has a unique label (pixels of object 1 are labeled as 1, object 2 pixels are labeled as 2,...). Now for every object, I need to find the best elliptical fit of its pixels. This requires finding the center of the object, the major and minor axis, and the rotation angle. How can I find these?</p> <p>Thank you;</p>
33,571,948
0
<p>In your local copy of the repo, edit <code>progressbar/__init__.py</code> and change the following line:</p> <pre><code>__version__ = '2.3dev' </code></pre> <p>to</p> <pre><code>__version__ = '2.3.1' </code></pre> <p>Save the file, then reinstall with <code>pip</code>. Of course, without a pull request, this will only work locally for you.</p> <hr> <p>Another option is to use the much more up-to-date <a href="https://pypi.python.org/pypi/progressbar2" rel="nofollow"><code>progressbar2</code></a>, on Github <a href="https://github.com/WoLpH/python-progressbar" rel="nofollow">here</a>. It has been validated to work up to Python 3.5. Obviously, you'll have to test your code to ensure it works with the new version, but this is probably your best bet.</p>
33,828,036
1
select checkbox tag python <p>If have a XML document like this :</p> <pre><code>&lt;!-- Location --&gt; &lt;w:t&gt;Lokacioni:&lt;/w:t&gt; &lt;w:t&gt;Kucni:&lt;/w:t&gt; &lt;w:t&gt;Extension:&lt;/w:t&gt; &lt;w:t&gt;Hajvali –Prishtinë&lt;/w:t&gt; &lt;w:t&gt;Rr. “ Dëshmorët e Gollakut “&lt;/w:t&gt; &lt;w:t&gt;P. N. Prishtinë&lt;/w:t&gt; &lt;!-- Date --&gt; &lt;w:t&gt;Dat:&lt;/w:t&gt; &lt;w:t&gt;Datum:&lt;/w:t&gt; &lt;w:t&gt;Date:&lt;/w:t&gt; &lt;w:t xml:space="preserve"&gt; &lt;/w:t&gt; &lt;!-- Free text - contains time and description--&gt; &lt;w:t&gt;1.&lt;/w:t&gt;&lt;w:t&gt;08:05 Aksident trafiku me dëme materiale Audi dhe Kombi te Kisha Graqanic&lt;/w:t&gt; &lt;!-- Checkboxes - 1 means it is checked --&gt; &lt;w:t&gt;Informuar:PK&lt;/w:t&gt;&lt;w:checkBox&gt;&lt;w:sizeAuto/&gt;&lt;w:default w:val="1"/&gt;&lt;/w:checkBox&gt; &lt;w:t&gt;SHME&lt;/w:t&gt;&lt;w:checkBox&gt;&lt;w:sizeAuto/&gt;&lt;w:default w:val="0"/&gt;&lt;/w:checkBox&gt; &lt;w:t&gt;SHZSH&lt;/w:t&gt;&lt;w:checkBox&gt;&lt;w:sizeAuto/&gt;&lt;w:default w:val="0"/&gt;&lt;/w:checkBox&gt; &lt;w:t&gt;,Shërbimet tjera&lt;/w:t&gt;&lt;w:checkBox&gt;&lt;w:sizeAuto/&gt;&lt;w:default w:val="0"/&gt;&lt;/w:checkBox&gt; </code></pre> <p>In python I want to select values from that xml that is generated from a .docx document, that contain checkbox. I wrote code like this:</p> <pre><code>WordNameSpace = '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}' para_tag = WordNameSpace + 'p' text_tag = WordNameSpace + 't' checkBox_tag = WordNameSpace + 'checkBox' def get_docx_text(path): document = zipfile.ZipFile(path) xml_content = document.read('word/document.xml') document.close() tree = XML(xml_content) paragraphs = [] for paragraph in tree.getiterator(checkBox_tag): texts = [node.text for node in paragraph.getiterator(text_tag) if node.text] if texts: paragraphs.append(''.join(texts)) return paragraphs results = get_docx_text('test.docx') print results </code></pre> <p>when i print results variable, result is only <code>[]</code> ? Why is this happening?</p>
5,477,261
0
Specific CSS Font Style <p>quick question, I'm currently trying to style a font to resemble the letters pictured below. Before I proceed any further I just wanted to be sure there wasn't already a standard, web-safe, font that resembles these letters. I'm not familiar with font design terminology, so I'm not sure what the technical description of the letters below would be. Thanks much.</p> <p><img src="https://i.stack.imgur.com/e6CXL.png" alt="enter image description here"></p>
27,050,144
0
In the TCX format, how is a trackpoint marked as paused? <p>During an exercise, Garmin allows you to pause recording so that your split times and pace are not affected. How are these paused periods represented in the TCX format? I've looked through the TCX <a href="http://www8.garmin.com/xmlschemas/TrainingCenterDatabasev2.xsd" rel="nofollow">schema</a>, but did not find an obvious answer.</p>
40,176,279
0
<p>So in looking at this I guess I my approach was wrong. I assert that body contains an array of objects. Then access that object and verify that way. I also had the wrong understanding of <code>.property()</code>, the returned value was an object, not the values of the property.</p>
16,784,050
0
Jquery Load not loading <p>I'm trying to do a fairly simple load function with Jquery (at least I think it is), but it simply isn't loading anything. </p> <p>On this page here (<a href="http://new.visibilitysoftware.com/careers/" rel="nofollow">http://new.visibilitysoftware.com/careers/</a>), I am trying to load the div#center-stage from here: <a href="http://www.vspublic.com/VSCareers/Careers.aspx" rel="nofollow">http://www.vspublic.com/VSCareers/Careers.aspx</a>. I have tried it with and without the /careers.aspx. I have also tried it with #center-stage and #center-stage.content as jquery parameters for the function. </p> <p>I'm sure it's something obvious, but I simply can't find it. I appreciate any help. Thanks</p>
16,543,914
0
<p>Your question is not clear, create a JsFiddle. For better understanding of Vertical-align <a href="http://css-tricks.com/what-is-vertical-align/" rel="nofollow">http://css-tricks.com/what-is-vertical-align/</a></p>
37,672,434
0
Global Twig parameter transformation in Symfony 2.7 <p>I have added some config parameters in config.yml like:</p> <pre><code>twig: globals: brands: 'land-rover': 'Land Rover' </code></pre> <p>The problem that I have is that once I use this inside twig, land-rover becomes land_rover.</p> <pre><code>{% for slugKey, name in brands %} &lt;li&gt;&lt;a href="{{ path('getSearchResultsByBrand', {'slug': slugKey, 'edition': edition.edition}) }}"&gt;{{ name }}&lt;/a&gt;&lt;/li&gt; {% endfor %} </code></pre> <p>Why is this transformation happening automatically and how can I prevent it?</p>
11,875,367
0
<p>The <a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-button_tag" rel="nofollow">button_tag</a> helper includes an option, <code>:disable_with</code>. Using this option will disable the button (using unobtrusive JavaScript) when the form is submitted, preventing additional clicks.</p>
20,106,079
0
<p>The problem is not in Django settings, but in the <strong>date</strong> passed to the model. Here's how a timezone-aware object looks like:</p> <pre><code>&gt;&gt;&gt; from django.utils import timezone &gt;&gt;&gt; timezone.now() datetime.datetime(2013, 11, 20, 20, 8, 7, 127325, tzinfo=&lt;UTC&gt;) </code></pre> <p>And here's a native object:</p> <pre><code>&gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; datetime.now() datetime.datetime(2013, 11, 20, 20, 9, 26, 423063) </code></pre> <p>So if you are passing email date anywhere (and it eventually gets to some model), just use Django's <code>now()</code>. If not, then it's probably an issue with an existing package that fetches date without timezone and you can patch the package, ignore the warning or set USE_TZ to False.</p>
22,803,950
0
<p>Like this:</p> <pre><code>pattern.replace(/\{(\d+)\}/g, function($0, $1){ return args[$1]; }); </code></pre>
21,512,675
0
<p>if a field is final, then you have to initialize it when it's declared or with a constructor:</p> <pre><code> private final int N =10; private PrimeBuggy(int threadNum) { start = N/numThreads * threadNum; this.threadNum = threadNum; } </code></pre> <p>Nevertheless, you have in your code several initialization in a methid:</p> <pre><code> start = N/numThreads * threadNum; N = start + N/numThreads; </code></pre> <p>and this makes no sense at all:</p> <pre><code> //I created a lock private Lock lock(); this.start = start; this.N = N; </code></pre>
9,186,364
0
How do I display a list of items from a Bean onto a JSF webpage? <p>I'm new to JSF and in the process of learning im building an online book store application. </p> <p>I have 1 class and 1 bean: <code>Book.java</code> and <code>BookCatelogBean.java</code>. The Book class has 3 properties: <code>id</code>, <code>title</code>, and <code>author</code> with it's corresponding getters and setters. The <code>BookCatelogBean</code> contains an <code>ArrayList&lt;Book&gt;</code> where I populate it with <code>Books</code> (in future I will connect it to a database). </p> <p>I have two pages: <code>index.xhtml</code> and <code>book.xhtml</code>. I want to display the list of book titles on <code>index.xhtml</code> each formatted as a REST link and their ID to <code>book.xhtml</code>, like so: <code>&lt;h:link outcome="book?id=#{bookCatelogBean.id}" value="#{bookCatelogBean.title}" /&gt;</code></p> <p>I know how to use <code>BookCatelogBean</code> to display 1 <code>book</code> but I want to display all of them? I have an idea to call a method from <code>BookCatelogBean</code> called <code>getAllBooks()</code> that returns each of the books titles but how would I return each one of them to index.xhtml as a JavaserverFace link instead of a string?</p> <p>Thanks</p> <p>Here is my code:</p> <p><strong>Book.java</strong></p> <pre><code>package bookshop; import java.io.Serializable; public class Book implements Serializable { private int id; private String title; private String author; public Book(int id, String title, String author){ this.title = title; this.id = id; this.author = author; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } } </code></pre> <p><strong>BookCatelogBean.java</strong></p> <pre><code>package bookshop; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; @ManagedBean @SessionScoped public class BookCatelogBean implements Serializable { private int currentItem = 0; private ArrayList&lt;Book&gt; books = new ArrayList&lt;Book&gt;(Arrays.asList( new Book(1, "Theory of Money and Credit", "Ludwig von Mises"), new Book(2, "Man, Economy and State", "Murry Rothbard"), new Book(3, "Real Time Relationships", "Stefan Molyneux"))); public String getTitle(){ return books.get(currentItem).getTitle(); } public int getId(){ return books.get(currentItem).getId(); } public String getAuthor(){ return books.get(currentItem).getAuthor(); } } </code></pre> <p><strong>index.xhtml</strong></p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"&gt; &lt;h:head&gt; &lt;title&gt;BookShop&lt;/title&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:link outcome="book?id=#{bookCatelogBean.id}" value="#{bookCatelogBean.title}" /&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre>
945,575
0
<p>Well, it appears to work for me. I used this setting:</p> <pre><code>(setq gnus-parameters '(("regressions.*" (gnus-use-adaptive-scoring nil)) ("general-personal.*" (gnus-use-adaptive-scoring t)))) </code></pre> <p>Perhaps your regexps don't match your group names? The above regexps will match groups that look like <code>mail.</code> and <code>gmane.</code> (the <code>.</code> being a real period).</p> <p>The way I tested it was to enter each of the two groups and did an eval on the variable <code>M-: gnus-use-adaptive-scoring RET</code> - though you could also just do help on the variable <code>C-h v gnus-use-adaptive-scoring RET</code>.</p> <p>Perhaps what you want is not to turn <strong>adaptive</strong>-scoring off, but just to turn scoring off. AFAIK, adaptive-scoring is Gnus trying to <em>figure</em> <em>out</em> scoring for the articles, but not the actual <strong>use</strong> of scoring.</p> <p>So maybe this does what you want?</p> <pre><code>(setq gnus-parameters '(("mail\\..*" (gnus-use-scoring nil)) ("gmane\\..*" (gnus-use-scoring t)))) </code></pre>
18,701,091
0
<p>This is weird:</p> <pre><code>avg_rel_track_nan=avg_rel_track_nan(avg_rel_track) </code></pre> <p>You probably meant:</p> <pre><code>avg_rel_track_nan=averaged_rel_track_nan(avg_rel_track) </code></pre> <p>I can't tell for sure what is happening because a lot of your code depends on some other code but you are assigning the result of a (supposedly) function call to the name of this function. I'm guessing that's not what you meant to do.</p>
22,479,171
0
<ol> <li><code>conio.h</code> was used in MS-DOS. Are you using MS-DOS? Probably not. Don't include this header.</li> <li>Add a <code>{}</code> or <code>;</code> to the end of each <code>while</code> loop. This is proper syntax. Otherwise, you will get a parser error.</li> <li>While this code will print the four values entered once you fix those issues, it is a convoluted way to teach you about loops. <code>printf</code> will return the number of characters printed. <code>scanf</code> on success, the function returns the number of items of the argument list successfully filled. This count can match the expected number of items or be less (even zero) due to a matching failure, a reading error, or the reach of the end-of-file.</li> <li><code>&amp;a[0][0]+4</code> are memory addresses. Each time you run this program, you will get different memory addresses. </li> <li><code>p=&amp;a[0][0]</code> will start <code>p</code> at the beginning to prepare it to print out the values in the next while loop.</li> </ol> <p>You can read more on <a href="https://stackoverflow.com/questions/13554244/how-to-use-pointer-expressions-to-access-elements-of-a-two-dimensional-array-in">pointer arithmetic of multi-dimensional arrays here</a>.</p>