pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
28,889,118
0
<p>You can use the chart.ylabels.specific option. Eg:</p> <p>obj.set('chart.ylabels.specific', ['1.00','0.80','0.60','0.40','0.20']);</p>
39,284,597
0
<h2>Append Hyperlink to list using the Insert Hyperlink Dialog</h2> <p><a href="https://i.stack.imgur.com/go3UT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/go3UT.jpg" alt="enter image description here"></a></p> <pre><code>Private Sub btnInsertHyperlink_Click() Range("A" &amp; Rows.Count).End(xlUp).Offset(1).Select Application.Dialogs(xlDialogInsertHyperlink).Show End Sub </code></pre>
11,362,691
0
Weird JavaScript scoping behavior <p>Latey I've got some trouble with some weird javascript behavior. I want to do something like this:</p> <pre><code>var lang = null; function getLang() { if (browserLanguageIsGerman) { lang = 'de'; } else { lang = 'en'; } // alert(lang) shows "de" $('#someID').load(someValidUrl, null, function(response, status, xhr) { if(languageSettingsOnFacebookIsGerman) { lang = 'de'; } else { lang = 'en'; } // alert(lang) show "en" ); // alert(lang) shows "de" } </code></pre> <p>The first and the second alerts show the expacted value 1) "de" 2) "en". The third alert shows "de" but shouldn't it be "en"?! Also the second alert pops up after the third alert.</p> <p>Can someone please obvious bug in my mind? :)</p> <p>Thanks in advance!</p>
12,629,156
0
<p>There's a <a href="http://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html">GCC extension</a> that does exactly what you want.</p>
9,144,194
0
<p>It's a python code.</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; s = '&lt;span class="address"&gt;413 W. Street&lt;/span&gt;&lt;br&gt;&lt;span class="phone"&gt;218-999-1020&lt;/span&gt;, &lt;span class="region"&gt;WA&lt;/span&gt; &lt;span class="postal-code"&gt;87112&lt;/span&gt;&lt;br&gt;' &gt;&gt;&gt; re.findall(r'address"&gt;(.*?)&lt;.*phone"&gt;(.*?)&lt;.*region"&gt;(.*?)&lt;.*postal-code"&gt;(.*?)&lt;', s) [('413 W. Street', '218-999-1020', 'WA', '87112')] &gt;&gt;&gt; </code></pre> <h1><a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags">BTW, don't forget to see this</a></h1>
37,134,648
0
<p>For this tablelayout defined in xml, following will be the dynamic code in corresponding java file (Activity/Fragment).</p> <pre><code>&lt;TableLayout android:id="@+id/fenceTableLayout" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;/TableLayout&gt; </code></pre> <p>Activity logic for TableView</p> <pre><code>//Table Layout parameters TableRow.LayoutParams textViewParam = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,1.0f); TableLayout tableLayout = (TableLayout) view.findViewById(R.id.fenceTableLayout); TableRow trHead = new TableRow(context); LayoutParams tableRowParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); trHead.setLayoutParams(tableRowParams); TextView nameHead = new TextView(context); nameHead.setText("Content left"); nameHead.setLayoutParams(textViewParam); nameHead.setGravity(Gravity.CENTER); trHead.addView(nameHead); TextView detailHead = new TextView(context); detailHead.setText("Content right"); detailHead.setGravity(Gravity.CENTER); detailHead.setLayoutParams(textViewParam); trHead.addView(detailHead); tableLayout.addView(trHead); </code></pre> <p><strong>NOTE:</strong> Many values have been referred from resource files, You can either neglect/replicate those.</p>
32,027,651
0
<blockquote> <p>Is Task a specific case where we rely on the native javascript implementation of Task?</p> </blockquote> <p>Exactly. You'll notice that <code>Task</code> the type but not <code>Task</code> the tag (thing on the right) are exported from the module, so you can't actually access the latter. It's a placeholder to make the type system happy.</p> <p>Instead, the Native JavaScript implementation knows what tasks <em>really</em> are, which is <a href="https://github.com/elm-lang/core/blob/2.1.0/src/Native/Task.js#L18-L58" rel="nofollow">a JS object</a>. Any native module dealing with Tasks (either the <code>Task</code> module or any third-party library like <code>elm-http</code>) is in on the secret. However, the <code>Task</code> module exports a good number of helper functions that you can have a lot of control over tasks using only the already published libraries.</p> <p>Clarification Edit: Yes, you need to use a third-party library to get a task that actually does some effect in the outside world. To actually run that task, you need to send it out a port; until you do that a Task is just a <em>description</em> of the work to do.</p>
17,440,052
0
<p>I would like you to visit this post :- <a href="http://stackoverflow.com/questions/8574182/best-solution-for-a-drop-down-list-with-over-300-rows">Best solution for a drop down list with over 300 rows?</a> </p> <p>this guy has given the best solution that you need and its good. "autofill dropdown".</p>
12,582,455
0
<p>Have you considered <a href="https://notex.ch" rel="nofollow"><strong>NoTex</strong></a>: It is a UI to Sphinx and uses reStructuredText for content and LaTex for presentational issues (like HTML for structure and CSS for design). It's completely browser based, to you don't have to go through the head ache of installing LaTex/XeTex etc.</p> <p>In my opinion reStructuredText is the successor for the <em>content</em> part of LaTex; but since LaTex is so good in producing publication quality PDFs it should be used for the design part. Of course it would be nice to have an engine that's completely independent of LaTex and that translates rST directly into PDFs. Unfortunately <em>none</em> of those tools produce anything that can reach LaTex in terms of quality. </p>
4,013,228
0
JQuery optimization for searching classes <p>I have some filters on the left. Each filter has an id. The id of that filter is used to filter some results that have the id of the filter in their classes.</p> <p>Filters refer to characteristics of products.. example</p> <pre><code>&lt;a id="filter_colorRED"&gt;RED&lt;/a&gt; ... &lt;li id="item4" class="filter_colorBLUE"&gt;Blah Blah&lt;/li&gt; &lt;li id="item5" class="filter_colorRED "&gt;Blah Blah&lt;/li&gt; &lt;li id="item6" class="filter_colorRED filter_colorBLACK"&gt;Blah Blah&lt;/li&gt; </code></pre> <p>I am looking for the best method to find which filters should be disabled. Disabled filters should be these that dont exist in visible items' classes.</p> <p>For example if colorBlue is applied RED and BLACK should be disabled because the only <code>&lt;li&gt;</code> that has the BLUE class doesn't contain RED or BLACK.</p> <p>My only thought is for each filter to check against results <code>.hasclass(filter's id)</code> but I think that this is poor. Any other idea?</p>
36,485,869
0
<p>Your conversion atof in this code</p> <pre><code>for(k = 0; k &lt; 361; k++) { val = atof(result[k]); cal[k] = val; } </code></pre> <p>is going out of bounds of the array 'result'<br> You only allocate memory to elements in the result array when you have data to put in it </p> <p><code>result[i] = malloc(strlen(value) + 1);</code></p> <p>If less than 361 records were created you are reading from unallocated memory - hence the error.</p> <p>You need to keep a record of how many results you have read in and then use that value to ensure that you remain in range as you process the result array.</p> <p>There is no difference between files based on the file extension.</p>
36,187,713
0
<p>Postman 4.0.5 has a feature named <em>Manage Cookies</em> located below the <em>Send</em> button which manages the cookies separately from Chrome it seems.</p>
1,110,589
0
<p>You <em>could</em> use the static ForEach method:</p> <pre><code>Array.ForEach(x =&gt; fis.Add(new FileInfo(x))); </code></pre> <p>However, you can easily replace the entire function with this one line:</p> <pre><code>IList&lt;FileInfo&gt; fis = Directory.GetFiles(path). Select(f =&gt; new FileInfo(f)).ToList(); </code></pre>
15,253,274
0
<p>If you want to just know whenever a click on any part of <code>iFrame</code> happens, just put the <code>iFrame</code> in a <code>div</code> and bind the event to the <code>div</code>.</p>
22,905,067
0
<p>Use below.Give your ul a id </p> <pre><code>$('#yourulid li:last-child').val(); </code></pre>
28,241,767
0
CSS content of input value before the input in a td element <p>I have to print a pretty hefty page / form / table combination and when I print I have multiple text input elements that I can't seem to reduce the width to use only the width needed to display the text without excess width. That excess width effects the <em>ten required columns</em> I have to print.</p> <p>So I've attempted to use CSS Content to move the text from the text input elements in to the parent table data elements. Here is example HTML and CSS:</p> <pre><code>&lt;td&gt;&lt;input type="text" value="Deadly Ninja Robots" /&gt;&lt;/td&gt; </code></pre> <p>The CSS I have tried:</p> <pre><code>form fieldset input[type='text'] {display: none;} form fieldset input[type='text']:before {content: form fieldset input[type='text'](value) ": ";} </code></pre> <p>How do I take the value of text input elements and display them inside the table data element that is the direct parent of the text input element itself?</p>
4,058,739
0
<p>The error lies on the client side, so you want to use a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4" rel="nofollow">4xx</a> status code. I'd go with <a href="http://restpatterns.org/HTTP_Status_Codes/400_-_Bad_Request" rel="nofollow">400 - Bad Request</a>:</p> <blockquote> <p>The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.</p> </blockquote>
9,737,040
0
<p>That book seems to be assuming the compiler inlines at a source level, this of course totally depends on the compiler. Most will begin inlining at the AST level, where transforms and certain optimizations can and will occur. This all assumes the compiler <em>will</em> inline the code.</p> <p>If we look at your function, any <em>decent</em> compiler will turn them both into the same IR code, as it will compile the inline function before it is inlined, thus a temporary is required regardless (at IR level). when the IR is then actually inlined, the temporary will be folded away and instead replaced with the assignment destination of the call to <code>max</code>.</p> <p>When we compile down to machine code, things can change even more, not only can temporaries be removed, but the destination will most likely be a register (in this case), which will have probably been used for on of the source operands as well.</p> <p><strong>Bottom Line:</strong> This totally depends on your compiler, optimization levels and how it does variable livelyness analysis, value propagation and folding. </p>
1,930,760
0
<p>You can accomplish this in 2 different ways:</p> <p>1) You could use the return value of <code>parseLink()</code> and re-assign the variable in the array:</p> <pre><code>$myText = parseLink($myArray[0]['text']); $myArray[0]['text'] = $myText; </code></pre> <p>2) You can modify your <code>parseLink()</code> function to accept the argument by reference which would cause it to be modified in place:</p> <pre><code>function parseLink(&amp;$text) { $text = ereg_replace("[[:alpha:]]+://[^&lt;&gt;[:space:]]+[[:alnum:]/]","&lt;a href=\"\\0\"&gt;\\0&lt;/a&gt;", $text); return $text; } parseLink($myArray[0]['text']); </code></pre>
19,424,544
0
<p>Try this:</p> <pre><code>padding: #{$padding / 10}rem; </code></pre> <p>Concatenating in SASS/SCSS uses ruby syntax, and you were mixing a mathematical equation followed by a concatenation, which is a variable type mix, so it's not suprising to me that it didn't work.</p> <p>Expressions and variables included within #{here} are assesed as if seperate to the rest of the line, and thus don't typecast the rest of the line. Also comes in handy if your output is getting quoted when you didn't expect (as does the unquote() function)</p>
9,703,050
0
<p>Could be something like that:</p> <pre><code>str.replace(/["']/g,"\\$&amp;"); </code></pre>
104,844
0
Default Printer in Unmanaged C++ <p>I'm looking for a way to find the name of the Windows default printer using unmanaged C++ (found plenty of .NET examples, but no success unmanaged). Thanks.</p>
15,126,642
0
CSS character encoding <p>According to <a href="http://www.w3.org/International/questions/qa-css-charset.en.php" rel="nofollow">W3C</a>, CSS can set its character encoding by <code>@charset</code> in the first line, is it valid to to say that I should put <code>@charset "UTF-8"</code> in every CSS i made, even it only contains ASCII characters?</p> <p>Will there be any performance penalty after I declare it using UTF-8 ?</p> <p><em>p.s. I can't think of a way to test it out.</em></p>
29,174,740
0
<p>If everything in one employee table with field "manager" pointing to employee id, then what kind of relationship is that? Recursive? Many to one?</p>
27,921,989
0
<p>In almost all cases, font glyphs are composed of <strong>filled shapes</strong>. They don't use the stroke (line). So when your SVGs are being converted to a font, the font SVGs are getting a fill applied, even if they didn't have one before.</p> <p>The differences between browsers is probably explained by the fact that each browser may be loading a different generated font type. Eg. woff vs TTF etc.</p> <p>The fix is to design your SVGs so that they only use filled shapes and <strong>don't</strong> rely on strokes (ie. line colour, width etc). If you follow the following rules, your glyphs should always work when converted:</p> <ol> <li>Keep your line colour as "none" or "transparent",</li> <li>Never use any fill colour except black (ie. don't use "white" to make holes)</li> <li>Never let shapes cross over themselves or other shapes.</li> </ol> <p>So, for example, in the case of your star, it should be designed as a filled star shaped object with a star shaped hole in it.</p>
13,083,753
0
<p>I put a breakpoint in the getControl method and was able to determine why I was getting the error. <code>$("#SwitchUserDropdown")</code> was not finding anything so when the code below was running it threw the error:</p> <pre class="lang-cs prettyprint-override"><code>var id = Tridion.Utils.Dom.getUniqueID(element); if (id) { var control = instances[id]; if (!control) { control = instances[id] = new ctor(element, settings); if (Tridion.Type.isFunction(control.initialize)) { control.initialize(); } } } else { Tridion.Utils.Assert.raiseError("Unable to get unique id for element."); } return control; </code></pre> <p>It seems obvious now that I know why it was happening that the code was running at the wrong time. I believe it shouldn't run when the CME loads, but only when the popup is opened. This leads me to look at the configuration of the resources in my Editor config file. I had previously grouped my popup's JS with other resources associated with the ribbon toolbar button. By placing the popup specific resources in their own resource group I was able to stop the error and successfully get the control.</p>
33,755,356
0
<p>Put an @ before the jar file path as below:</p> <pre><code>curl --data-binary @/opt/hadoop/spark-jobserver/job-server-api/target/scala-2.10/job-server-api_2.10-0.6.1-SNAPSHOT.jar localhost:8090/jars/test </code></pre>
15,035,642
0
<blockquote> <p>And you could assume that I'm drawing into a BufferedImage, which I do sometimes, in fact.</p> </blockquote> <p>See <a href="http://tips4java.wordpress.com/2008/10/13/screen-image/" rel="nofollow">Screen Image</a>, which can also create a component image.</p>
8,384
0
<p>Based on NilObject's code:</p> <pre><code>#include &lt;sys/stat.h&gt; off_t fsize(const char *filename) { struct stat st; if (stat(filename, &amp;st) == 0) return st.st_size; return -1; } </code></pre> <p>Changes:</p> <ul> <li>Made the filename argument a <code>const char</code>.</li> <li>Corrected the <code>struct stat</code> definition, which was missing the variable name.</li> <li>Returns <code>-1</code> on error instead of <code>0</code>, which would be ambiguous for an empty file. <code>off_t</code> is a signed type so this is possible.</li> </ul> <p>If you want <code>fsize()</code> to print a message on error, you can use this:</p> <pre><code>#include &lt;sys/stat.h&gt; #include &lt;string.h&gt; #include &lt;stdio.h&gt; #include &lt;errno.h&gt; off_t fsize(const char *filename) { struct stat st; if (stat(filename, &amp;st) == 0) return st.st_size; fprintf(stderr, "Cannot determine size of %s: %s\n", filename, strerror(errno)); return -1; } </code></pre> <p>On 32-bit systems you should compile this with the option <code>-D_FILE_OFFSET_BITS=64</code>, otherwise <code>off_t</code> will only hold values up to 2 GB. See the "Using LFS" section of <a href="http://www.suse.de/~aj/linux_lfs.html" rel="nofollow noreferrer">Large File Support in Linux</a> for details.</p>
31,105,116
0
What are those new files after Activator 1.3.5 update? <p>Today while starting my Play app with <code>activator run</code> the new Activator version 1.3.5 got installed automatically. My app's running perfectly fine. But now I see a couple of new files in my app's folder and I don't know what they are or how to handle them. Maybe someone can advice me. Google didn't help me much so far. Those files are </p> <ul> <li>.sbtserver</li> <li>.sbtserver.lock</li> <li>play-fork-run.sbt</li> <li>sbt-ui.sbt</li> </ul> <p>Except for the .sbtserver.lock they all look like configuration files. But what are they configuring? And should I put them under version control?</p>
21,414,697
0
<p>Try this:</p> <pre><code>gci *.txt |% {write-host "`r$($_.name)" -NoNewline; Start-Sleep -Seconds 1} </code></pre>
28,714,815
0
Calculating CRC initial value instead of appending the CRC to payload <p>Most of the CRCs I've implemented were <strong>appending</strong> the calculated CRC value to the message (payload) and checking for a zero result at the receiver after all bytes incl. CRC value were fed through the CRC register. Obviously this is a quite standard approach.</p> <p>Now I would like to use a different approach:</p> <ol> <li>Calculate a value from the payload.</li> <li>Use that value as initial value for the CRC register <strong>before</strong> the message bytes (payload) are fed through the CRC register such that the result after the last byte of the payload was fed through will be zero.</li> </ol> <p>What is the best approach to do this? Does one have a good idea or some pointers where to dig deeper?</p> <p>ps: Why I want to do this? In some applications (ROM) I cannot append data as the data is stored at the end of address space of a ROM. So I'd like to either preload the CRC register or prepend the value to the message.</p>
32,402,444
0
Where is @AroundInvoke interceptor invoked? <p>I'm doing some test examples with java, and I come up with an example that uses @AroundInvoke. The question is that I don't know exactly where is the method invoked.</p> <p>This test makes an invocation where it calls post() method, but I don't really know how that works (<a href="https://docs.oracle.com/javaee/6/tutorial/doc/gkedm.html" rel="nofollow">Using Interceptors explanation</a>).</p> <pre><code>@Test public void crudtest() { JsonObjectBuilder todoBuilder = Json.createObjectBuilder(); JsonObject todoToCreate = todoBuilder. add("caption", "implement"). add("priority", 10). build(); //The next post execute, invoke the method Response postResponse = this.provider.target().request(). post(Entity.json(todoToCreate)); } </code></pre> <p>The order of invocation is BoundaryLogger and then MonitorSink</p> <p><strong>BoundaryLogger.java</strong></p> <pre><code>... public class BoundaryLogger { @Inject Event&lt;CallEvent&gt; monitoring; @AroundInvoke public Object logCall(InvocationContext ic) throws Exception { long start = System.currentTimeMillis(); try { return ic.proceed(); } finally { long duration = System.currentTimeMillis() - start; monitoring.fire(new CallEvent(ic.getMethod().getName(), duration)); } } } </code></pre> <p><strong>MonitorSink</strong></p> <pre><code>@Singleton @ConcurrencyManagement(ConcurrencyManagementType.BEAN) public class MonitorSink { @Inject LogSink LOG; public void onCallEvent(@Observes CallEvent event){ LOG.log(event.toString()); } } </code></pre>
30,348,888
0
<p>It's always better to use mathematical function to perform mathematical operations.<br> Not only does it make the code more readable, it's also likely to have better performance.<br> Therefor, as <a href="http://stackoverflow.com/users/3832970/stribizhev">stribizhev</a> wrote in the comments - <code>Use #1</code> :).</p> <p>Also, your regular expression does not take into consideration that different cultures might have different decimal separators.<br> Not everyone is writing one and a quarter as <code>1.25</code>, some cultures use <code>,</code> as the decimal separator and thus it's written as <code>1,25</code>.<br> Should you encounter a decimal like that, your regular expression will not work as you expect.</p>
6,447,438
0
<p>On merges SVN updates internal properties named <code>mergeinfo</code>. To inspect the actual properties that have changed with the merging on <code>a/b/aFolder</code> you can issue:</p> <pre><code>svn propget svn:mergeinfo a/b/aFolder </code></pre>
35,943,513
0
<p>You need to make a <a href="http://php.net/manual/en/language.operators.string.php" rel="nofollow">concatenation in php</a></p> <p>in your example use "." instead of "+"</p> <p>$string = $userNode->getFirstName() . $userNode->getLastName();</p>
1,792,670
0
<p>You can try the <a href="http://code.google.com/p/symja/wiki/MathExpressionParser" rel="nofollow noreferrer">math expression parser</a> from my <a href="http://code.google.com/p/symja/" rel="nofollow noreferrer">Symja</a> project.</p>
40,045,079
0
HTML created by PHP is created out of sequence <p>I have a PHP file which outputs some HTML.</p> <p>For ease of configuration I have a <code>second</code> PHP file that is included in the <code>first</code> PHP file. This included file simply contains an array definition as follows:</p> <pre><code>&lt;? $myArray = array("key1"=&gt;"value 1","key2"=&gt;"value 2","key3"=&gt;"value 3"); ?&gt; </code></pre> <p>In my first PHP file I have the following</p> <pre><code>&lt;? include("second.php"); ?&gt; &lt;label&gt;Select here: &lt;select id='mySelect'&gt; &lt;? foreach ($myArray as $keyString=&gt;$valueString) { ?&gt; &lt;option value='&lt;?= $keyString; ?&gt;'&gt;&lt;?= $valueString; ?&gt;&lt;/option&gt; &lt;? } ?&gt; &lt;/select&gt; &lt;/label&gt; </code></pre> <p>However the HTML output is generated as follows:</p> <pre><code>&lt;label&gt;Select here: &lt;select id='mySelect'&gt; &lt;/select&gt; &lt;option value='key1'&gt;value 1&lt;/option&gt; &lt;option value='key2'&gt;value 2&lt;/option&gt; &lt;option value='key3'&gt;value 3&lt;/option&gt; &lt;/label&gt; </code></pre> <p>which renders as an empty select dropdown with the text of the options shown below it!</p> <p>I'm sure this is something stupid and simple as I'm sure I have done this many times before without problems...</p> <hr> <p>[Update]</p> <p>After investigation it turns out that this is only happening when I display the <code>first</code> PHP page within FancyBox - when I load it directly the options are included in the <code>&lt;select&gt;</code> as you would expect.</p> <p>The FancyBox is opened via JavaScript via the onClick event of an image as follows (the image is on the background page that the FancyBox opens on, it is not part of first.php or second.php):</p> <pre><code>&lt;img src="myImage.png" alt="my image" onClick="openFirstPHP();"&gt; </code></pre> <p>in my JavaScript I have (in <code>first.js</code> which is included in <code>first.php</code> with the usual <code>&lt;SCRIPT&gt;</code> tags):</p> <pre><code>function openFirstPHP() { $.fancybox({ href: "/first.php", type: "ajax", afterShow: function() { // do some setting of some radio buttons' states - which works fine } }); } </code></pre> <p>For info, the reason I call <code>first.php</code> this way rather than in an iFrame or whatever is that it interacts with the calling page as well and so avoid me having to reference a different document object (I think).</p> <p>Basically everything else works without problems in <code>first.php</code> - the reading and settings of cookies, the interaction with the calling PHP page variables etc. The only thing that is not working is the insertion of these <code>&lt;options&gt;</code> tags out of sequence with the <code>&lt;select&gt;</code> tags.</p>
12,420,251
0
<p>The expression <code>[[]]</code> actually consists of two concatenated subexpressions: <code>[[]</code> and <code>]</code>.</p> <ul> <li><code>[[]</code> is character class that matches only <code>[</code> characters. Having <code>[</code> is only possible at the very beginning of a character class.</li> <li><code>]</code> is just a normal character if outside of a character class.</li> </ul> <p>Both are concatenated thus your expression matches any character of <code>[</code> followed by <code>]</code>, which results in matching <code>[]</code>.</p>
2,648,882
0
<p>As for where the error comes from, we have the following type constraints</p> <pre><code>// Cprod: seq&lt;`a&gt; -&gt; seq&lt;`a&gt; -&gt; `a list list let Cprod U V = ... // Cpower: seq&lt;`a&gt; -&gt; int -&gt; ??? let Cpower U n = // V: seq&lt;`a&gt; let mutable V = U // n: int for i=0 to n-1 do (* The next line implies two type constraints: V: seq&lt;`a&gt; V: `a list list *) V &lt;- Dprod U V V </code></pre> <p>That <code>V</code> must be an <code>seq&lt;&#x60;a&gt;</code> and an <code>&#x60;a list list</code>, and that U and V must have the same type means that <code>&#x60;a = &#x60;a list</code>, which is what results in the "infinite type" error message (the infinity type is <code>... list list list list</code>. Even though the value of <code>V</code> is mutable, it must have a single type.</p>
9,276,389
0
Template method of template class specialization <p>Here is my code:</p> <pre><code>template&lt;typename T1, typename T2&gt; class MyClass { public: template&lt;int num&gt; static int DoSomething(); }; template&lt;typename T1, typename T2&gt; template&lt;int num&gt; int MyClass&lt;T1, T2&gt;::DoSomething() { cout &lt;&lt; "This is the common method" &lt;&lt; endl; cout &lt;&lt; "sizeof(T1) = " &lt;&lt; sizeof(T1) &lt;&lt; endl; cout &lt;&lt; "sizeof(T2) = " &lt;&lt; sizeof(T2) &lt;&lt; endl; return num; } </code></pre> <p>It works well. But when I try to add this</p> <pre><code>template&lt;typename T1, typename T2&gt; template&lt;&gt; int MyClass&lt;T1, T2&gt;::DoSomething&lt;0&gt;() { cout &lt;&lt; "This is ZERO!!!" &lt;&lt; endl; cout &lt;&lt; "sizeof(T1) = " &lt;&lt; sizeof(T1) &lt;&lt; endl; cout &lt;&lt; "sizeof(T2) = " &lt;&lt; sizeof(T2) &lt;&lt; endl; return num; } </code></pre> <p>I get compiller errors: invalid explicit specialization before «>» token template-id «DoSomething&lt;0>» for «int MyClass::DoSomething()» does not match any template declaration</p> <p>I use g++ 4.6.1 What should I do?</p>
11,208,364
0
<p>You can use following code,</p> <pre><code>objectProduct.subProduct = new SubProduct{ ID = id,foo = value }; </code></pre>
5,735,730
0
<p>Try just:</p> <pre><code>bash &lt;(curl -s http://mywebsite.com/myscript.txt) </code></pre>
29,382,123
0
<p>You might have tried this already, but if you are using <code>django.contrib.auth.views</code>, then you could try calling <a href="https://docs.djangoproject.com/en/1.7/topics/auth/default/#how-to-log-a-user-out" rel="nofollow"><code>django.contrib.auth.logout(request)</code></a> to log out the user if they do not want to be remembered, then login as per your existing code:</p> <pre><code>from django.contrib.auth import logout def login(request, *args, **kwargs): if request.method == 'POST': if not request.POST.has_key('remember_me'): saved_user = getattr(request, 'user', None) logout(request) if saved_user is not None: request.user = saved_user return auth_views.login(request, *args, **kwargs) </code></pre> <p>This should work because <code>django.contrib.auth.login()</code> is called behind the scenes. The documentation says that the session is cleared out.</p>
14,342,691
0
System commands dont work when running over passenger <p>I have a sinatra app with a page that shows some information about the application. Some of which is generated by running commands on page load. Everything works fine on my MacBook when running in unicorn and everything works fine on the production server when running in unicorn but swap to Apache/Passenger and suddenly the commands start returning nil.</p> <p>For example to get a list of committers I use:</p> <pre><code>comitters = `cd /path/to/app &amp;&amp; git shortlog -s -n` </code></pre> <p>This works perfectly until run in the apache/passenger setup.</p> <p>Is there some option within passenger that disables system commands?</p>
40,550,694
0
RecyclerView inside CardView inside RecyclerView throwing null pointer on findViewById <p>I'm trying to have a RecyclerView, where each row is a CardLayout, which again contains a RecyclerView (with Header, Items and Footer). I have tried to instansiate the innerRecyclerView in the OnBind from the OuterRecyclerView but keep on getting a nullpointer. </p> <p>"Main" Activity Code:</p> <pre><code>import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; import com.squareup.timessquare.CalendarPickerView; import java.util.List; import ch.zhaw.it15a_zh.psit3_03.mealmanager.R; import ch.zhaw.it15a_zh.psit3_03.mealmanager.adapters.OuterWeekplanAdapter; import ch.zhaw.it15a_zh.psit3_03.mealmanager.db.repos.UserPlannedRecipesRepo; import ch.zhaw.it15a_zh.psit3_03.mealmanager.models.UserPlannedRecipe; public class WeekPlanActivity extends AppCompatActivity { private RecyclerView outerRecyclerView; private CalendarPickerView calendar; private UserPlannedRecipesRepo uprr = new UserPlannedRecipesRepo(); private List&lt;UserPlannedRecipe&gt; userPlannedRecipeList; private List&lt;String&gt; distinctUserPlannedDates; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Hide Top Toolbar form android device requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //Set LayoutFile setContentView(R.layout.activity_weekplan); /* BEGIN TOOLBAR */ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_weekplan_overview); setSupportActionBar(toolbar); getSupportActionBar().setTitle(R.string.toolbar_title_weekplan_activity); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); /* END TOOLBAR */ outerRecyclerView = (RecyclerView) findViewById(R.id.activity_weekplan_outer_recyclerview); distinctUserPlannedDates = uprr.getDistinctListOfPlannedDates(); OuterWeekplanAdapter outerWeekplanAdapter = new OuterWeekplanAdapter(getApplicationContext(), distinctUserPlannedDates); RecyclerView.LayoutManager manager = new LinearLayoutManager(getApplicationContext()); outerRecyclerView.setLayoutManager(manager); outerRecyclerView.setItemAnimator(new DefaultItemAnimator()); outerRecyclerView.setAdapter(outerWeekplanAdapter); } //Inflate Options Menu to show additional buttons in toolbar @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_weekplan_main_menu, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.ic_action_weekplan_add: Intent intent = new Intent(this, DateRangePicker.class); Context context = this; context.startActivity(intent); } return super.onOptionsItemSelected(item); } } </code></pre> <p>Inner RecyclerView Adapter</p> <pre><code>import android.content.Context; import android.net.Uri; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.squareup.picasso.Picasso; import java.util.List; import ch.zhaw.it15a_zh.psit3_03.mealmanager.R; import ch.zhaw.it15a_zh.psit3_03.mealmanager.db.repos.RecipeRepo; import ch.zhaw.it15a_zh.psit3_03.mealmanager.db.repos.UserPlannedRecipesRepo; import ch.zhaw.it15a_zh.psit3_03.mealmanager.models.Recipe; import ch.zhaw.it15a_zh.psit3_03.mealmanager.models.UserPlannedRecipe; public class InnerWeekplanAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; { private static final int TYPE_HEADER = 0; private static final int TYPE_ITEM = 1; private static final int TYPE_FOOTER = 2; private List&lt;UserPlannedRecipe&gt; userPlannedRecipeList; private UserPlannedRecipesRepo uprr = new UserPlannedRecipesRepo(); private RecipeRepo recipeRepo = new RecipeRepo(); private Context context; private int recipeID; public InnerWeekplanAdapter(List&lt;UserPlannedRecipe&gt; userPlannedRecipeList, Context context) { this.userPlannedRecipeList = userPlannedRecipeList; this.context = context; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (viewType == TYPE_HEADER) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_weeplan_day_header, parent, false); return new WeekplanHeaderViewHolder(v); } else if (viewType == TYPE_FOOTER) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_weekplan_day_footer, parent, false); return new WeekplanFooterViewHolder(v); } else if (viewType == TYPE_ITEM) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_weekplan_day_planned_recipe, parent, false); return new WeekplanItemViewHolder(v); } return null; } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof WeekplanHeaderViewHolder) { WeekplanHeaderViewHolder weekplanHeaderViewHolder = (WeekplanHeaderViewHolder) holder; //TODO Set header fields with get repo information recipeID = userPlannedRecipeList.get(position).getPlannedRecipeID(); weekplanHeaderViewHolder.textview_date_of_weekplan_row .setText(userPlannedRecipeList.get(position).getDatePlanned().toString()); } else if (holder instanceof WeekplanItemViewHolder) { WeekplanItemViewHolder weekplanItemViewHolder = (WeekplanItemViewHolder) holder; Recipe recipe = new RecipeRepo().getRecipe(userPlannedRecipeList.get(position - 1).getPlannedRecipeID()); //Sets Recipe Name weekplanItemViewHolder.textView_recipe_name.setText(recipe.getName()); //Sets Image Thumbnail String imageID = recipe.getImage(); imageID = imageID.substring(0, imageID.lastIndexOf(".")); Uri uri = Uri.parse("android.resource://" + context.getPackageName() + "/drawable/" + imageID); Picasso.with(context).load(uri).error(R.drawable.placeholder).placeholder(R.drawable.placeholder) .into(weekplanItemViewHolder.imageView_thumbnail_recipe_image); //Sets Short Recipe Description weekplanItemViewHolder.textView_short_recipe_description.setText(recipe.getDescription()); //Sets Cooking Time weekplanItemViewHolder.textView_cookingTime.setText(String.valueOf(recipe.getCookingTime())); //TODO implement RemoveRecipeFromPlanning-Button functionality } else { WeekplanFooterViewHolder weekplanFooterViewHolder = (WeekplanFooterViewHolder) holder; weekplanFooterViewHolder.button_plan_recipes_for_this_day.setText("Add Recipes to this day"); //TODO implement AddRecipesToThisDay-Button functionality } } @Override public int getItemCount() { return userPlannedRecipeList.size() + 2; } @Override public int getItemViewType(int position) { if (isPositionHeader(position)) { return TYPE_HEADER; } else if (isPositionFooter(position)) { return TYPE_FOOTER; } return TYPE_ITEM; } private boolean isPositionHeader(int position) { return position == 0; } private boolean isPositionFooter(int position) { return position == userPlannedRecipeList.size() + 1; } /*BEGIN VIEWHOLDERS*/ public class WeekplanHeaderViewHolder extends RecyclerView.ViewHolder { public TextView textview_date_of_weekplan_row; public WeekplanHeaderViewHolder(View view) { super(view); this.textview_date_of_weekplan_row = (TextView) itemView.findViewById(R.id.textview_date_of_weekplan_row); } } public class WeekplanItemViewHolder extends RecyclerView.ViewHolder { public ImageView imageView_thumbnail_recipe_image; public TextView textView_recipe_name; public TextView textView_short_recipe_description; public TextView textView_cookingTime; public ImageButton imageButton_remove_recipe_from_planning; public WeekplanItemViewHolder(View view) { super(view); this.imageView_thumbnail_recipe_image = (ImageView) view.findViewById(R.id.imageView_thumbnail_recipe_image); this.textView_recipe_name = (TextView) view.findViewById(R.id.textView_recipe_name); this.textView_short_recipe_description = (TextView) view.findViewById(R.id.textView_short_recipe_description); this.textView_cookingTime = (TextView) view.findViewById(R.id.cookingTime); //this.imageButton_remove_recipe_from_planning = // (ImageButton) view.findViewById(R.id.imageButton_remove_recipe_from_planning); //Set Button functionality for removing a recipe from a recyclerview ImageButton button = (ImageButton) view.findViewById(R.id.imageButton_remove_recipe_from_planning); button.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "Item Removed", Toast.LENGTH_SHORT).show(); } }); } } public class WeekplanFooterViewHolder extends RecyclerView.ViewHolder { public Button button_plan_recipes_for_this_day; public WeekplanFooterViewHolder(View view) { super(view); this.button_plan_recipes_for_this_day = (Button) view.findViewById(R.id.button_plan_recipes_for_this_day); } } /*END VIEWHOLDERS*/ } </code></pre> <p>Outer RecyclerView Adapter</p> <pre><code>import android.content.Context; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.util.List; import ch.zhaw.it15a_zh.psit3_03.mealmanager.R; import ch.zhaw.it15a_zh.psit3_03.mealmanager.db.repos.UserPlannedRecipesRepo; import ch.zhaw.it15a_zh.psit3_03.mealmanager.models.UserPlannedRecipe; public class OuterWeekplanAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; { private static Context context; private static OuterWeekplanAdapter outerWeekplanAdapter; private List&lt;String&gt; distinctListOfPlannedDates; private List&lt;UserPlannedRecipe&gt; userPlannedRecipeList; private UserPlannedRecipesRepo userPlannedRecipesRepo = new UserPlannedRecipesRepo(); private RecyclerView innerRecyclerView; public OuterWeekplanAdapter(Context applicationContext, List&lt;String&gt; distinctListOfPlannedDates) { context = applicationContext; this.distinctListOfPlannedDates = distinctListOfPlannedDates; } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_weekplan_cardview, parent, false); return new OuterWeekplanViewHolder(v); } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { </code></pre> <p>CRASH OCCURES HERE APPARENTLY:</p> <pre><code> innerRecyclerView = (RecyclerView) innerRecyclerView.findViewById(R.id.activity_weekplan_inner_recyclerview); userPlannedRecipeList = userPlannedRecipesRepo.getUserPlannedRecipeFromSpecificDate(distinctListOfPlannedDates.get(position)); InnerWeekplanAdapter innerWeekplanAdapter = new InnerWeekplanAdapter(userPlannedRecipeList, context); RecyclerView.LayoutManager manager = new LinearLayoutManager(context); innerRecyclerView.setLayoutManager(manager); innerRecyclerView.setItemAnimator(new DefaultItemAnimator()); innerRecyclerView.setAdapter(innerWeekplanAdapter); } @Override public int getItemCount() { return distinctListOfPlannedDates.size(); } public class OuterWeekplanViewHolder extends RecyclerView.ViewHolder { public OuterWeekplanViewHolder(View itemView) { super(itemView); } } } </code></pre> <p>"Main" Activity Layout</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".activities.WeekPlanActivity"&gt; &lt;include layout="@layout/toolbar_weekplan_overview" android:id="@+id/toolbar_weekplan_overview"/&gt; &lt;android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/activity_weekplan_outer_recyclerview" android:layout_below="@id/toolbar_weekplan_overview" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>CardView Layout: </p> <pre><code> &lt;android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/activity_weekplan_inner_recyclerview" /&gt; &lt;/android.support.v7.widget.CardView&gt; </code></pre> <p>Crash Message:</p> <pre><code> --------- beginning of crash 11-11 15:52:07.691 6350-6350/? E/AndroidRuntime: FATAL EXCEPTION: main Process: ch.zhaw.it15a_zh.psit3_03.mealmanager, PID: 6350 java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.v7.widget.RecyclerView.findViewById(int)' on a null object reference at ch.zhaw.it15a_zh.psit3_03.mealmanager.adapters.OuterWeekplanAdapter.onBindViewHolder(OuterWeekplanAdapter.java:41) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5825) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5858) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5094) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4970) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3315) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:2843) at android.view.View.measure(View.java:18850) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462) at android.view.View.measure(View.java:18850) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135) at android.view.View.measure(View.java:18850) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18850) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:18850) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18850) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5963) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2672) at android.view.View.measure(View.java:18850) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2102) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1218) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1454) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1109) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6046) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) at android.view.Choreographer.doCallbacks(Choreographer.java:670) at android.view.Choreographer.doFrame(Choreographer.java:606) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:152) at android.app.ActivityThread.main(ActivityThread.java:5507) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) </code></pre>
34,040,877
0
<p>As Alexander said, if you choose <a href="http://gruntjs.com" rel="nofollow">Grunt</a>, you can use a <a href="https://github.com/gruntjs/grunt-contrib-concat" rel="nofollow">concat plugin</a> to merge a list of selected files into a single destination:</p> <p>after you load the select plugin in your gruntfile.js</p> <pre><code>grunt.loadNpmTasks('grunt-contrib-concat'); </code></pre> <p>define a task in grunt configuration:</p> <pre><code>grunt.initConfig({ concat: { options: { separator: ';', }, dist: { // your source file list src: ['src/js/*.js'], //your destination file dest: 'dist/app.js', }, }, }); </code></pre> <p>then register this task to a list:</p> <pre><code>grunt.registerTask('compile', ['concat']); </code></pre> <p>this would be run by typing "grunt compile" on the command line</p> <p>so you only have to include the dist/app.js file in your index.</p> <p>There are many plugins available in grunt, i.e. you can inculde your app.js file dynamically using the <a href="https://www.npmjs.com/package/grunt-include-source" rel="nofollow">grunt-include-source</a> plugin, or minimize the js files using <a href="https://github.com/gruntjs/grunt-contrib-uglify" rel="nofollow">grunt-contrib-uglify</a>.</p> <p>More information on the gruntfile are available <a href="http://gruntjs.com/sample-gruntfile" rel="nofollow">here</a></p> <p>You can achieve the result as requested in the second point instead, i think you could use solutions like:</p> <ul> <li><a href="https://webpack.github.io/" rel="nofollow">WebPack</a></li> <li><a href="http://requirejs.org/" rel="nofollow">RequireJS</a></li> </ul> <p><strong>UPDATE</strong>:</p> <p>I couldn't find a concat end to end tutorial, I'm sorry.</p> <p>For a generic Grunt tutorial you can read <a href="http://adrianmejia.com/blog/2014/10/07/grunt-js-tutorial-from-beginner-to-ninja/" rel="nofollow">this</a></p> <p>Otherwise you can follow the <a href="http://gruntjs.com/getting-started" rel="nofollow">getting started</a> page from the official Grunt site for installation, configuration and have a general overview.</p> <p>When they talk about plugins please refer to the README of the <a href="https://github.com/gruntjs/grunt-contrib-concat" rel="nofollow">grunt-contrib-concat</a> plugin linked and explained above.</p> <p>Those pages could give you all the skills needed.</p> <p>Finally, customize the concat configuration in Gruntfile.js by putting in <code>dist.src</code> all files to be merged into the file set as <code>dist.dest</code> and only include the latter in your html.</p> <p>Once the set-up is complete, execute your task by typing <code>grunt compile</code> on the command line in your project folder, and the merged file will be produced.</p>
25,514,233
0
<p>I don't think the loop will be slower. You are accessing the memory of the M1 and M2 arrays in the same way in both instances i.e. . If you want to make the "manual" version faster then use scalar replacement and do the computation on registers e.g.</p> <pre><code> double M1_0 = M1[0]; double M2_0 = M2[0]; result[0] = M1_0*M2_0 + ... </code></pre> <p>but you can use scalar replacement within the loop as well. You can do it if you do blocking and loop unrolling (in fact your triple loop looks like a blocking version of the MMM).</p> <p>What you are trying to do is to speed up the program by improving locality i.e. better use of the memory hierarchy and better locality.</p>
19,227,018
0
<p>Your regular expression is self-contradictory.</p> <p>You are bounding your pattern on word boundaries, and then including a non-word character in the string you're looking for. Since the '.' character isn't a word character, there will never be any strings that are delimited by word boundaries that include the '.'. </p> <p>Put another way, since the '.' is itself a word boundary, you are looking for [word-boundary][word-boundary][word], which cannot occur.</p> <p>Just take out the word boundaries in your REGEXP:</p> <pre><code>WHERE INET_NTOA(ip) REGEXP '\.111' </code></pre>
10,759,817
0
<p>You can use <a href="http://p3rl.org/IPC%3a%3aOpen2" rel="nofollow"><code>IPC::Open2</code></a> to attache two file handles, one to the input and one to the output of a program. It may be closer to what you really want to use <a href="http://p3rl.org/IO%3a%3aSocket%3a%3aSSL" rel="nofollow"><code>IO::Socket::SSL</code></a>, which functions like <code>IO::Socket::INET</code> but encrypted.</p> <p><strong>Update:</strong> My best guess is that your doubling up <code>\r</code> characters. According to the man page for <code>s_client</code> <code>-crlf</code> converts line feeds into carriage return + line feed. An when you print to the <code>$sslwrite</code> handle you are sending <code>"\r\n"</code>. I think the result would be that the server would receive "\r\r\n" at the end of each command. You probably want to drop the <code>-crlf</code> from the <code>openssl</code> command in your program.</p>
37,378,816
0
<p>There is no easy way to do that. Maybe with very complex query, but it will be difficult to maintain and may be even less efficient than doing that with several simpler queries.</p> <p>The solution described by you costs 1 + (number of categories) queries, not two, of course. You could union them easily, and then you would have two queries and less trips do database, but similar load for db (comparing to your solution).</p> <p>Even if you would assume, that there is a way to fetch everything with single query, then db has to do almost the same work (fetch 3 newest posts from every category). So having 2 queries vs 1 hypothetical is not a big penalty in terms of performance. Moreover, I can imagine that DB engine could have some issues with finding most optimal execution plan, especially if you would add there functions etc.</p> <p>And the last solution. There is a way for fetching up to 3 posts from each category, but that require modifying schema and some application-side work. You can add a boolean column "most_recent" and have always 3 posts per cat. with <code>true</code> and false for the rest. You would have to keep updating it every time when you are adding/deleting posts. That is achievable as well with db triggers. Then your problem is trivial to resolve, but only because you have done some precomputation.</p>
11,696,380
0
<p>Here's a reasonably straightforward working example that produces the output you want:</p> <pre><code>import play.api.libs.json._ val json = Json.parse(""" {"1342558874663000":{"TEMPERATURE_C":"253","TEMPERATURE_F":"775"}, "1342558854606000" :{"TEMPERATURE_C":"254","TEMPERATURE_F":"776"}} """).as[JsObject] Json.toJson(json.fields.flatMap { case (epoch, obj) =&gt; obj.as[JsObject].fields.map(epoch -&gt; _) }.groupBy(_._2._1).mapValues( _.map { case (epoch, (_, v)) =&gt; Seq(epoch, v.as[String]) } )) </code></pre> <p>The trick here is to flatten the list and then rebuild the structure you need.</p>
4,601,965
0
<p>Yes, that is the write way.</p> <p>It's just that instead of writing webpart directly, you can write the usercontrol and then host it in a wrapper webpart.</p> <p>The advantage of this approach is that you can have designer for creating UI elements which is available while creating usercontrol. For sharepoint 2007, the wrapper webpart is already available called smart part. To smartpart, you can just give the location of your user control(.ascx) to load.</p> <p>In sharepoint 2010, the smartpart can be built out of the box using Visual Studio 2010.</p> <p><a href="http://smartpart.codeplex.com/" rel="nofollow">http://smartpart.codeplex.com/</a></p>
18,501,096
0
<p>This is the concept of <a href="http://docs.oracle.com/javase/tutorial/reflect/" rel="nofollow">Reflection</a>. You should be able to do something like the following (untested) code snippet:</p> <pre><code>/** * @return {@code true} if all of the values of the fields in {@code obj} are * contained in the set of {@code values}; {@code false} otherwise. */ public boolean containsAllValues(HashSet&lt;Object&gt; values, MyClass obj) { Field[] fields = MyClass.class.getFields(); for (Field field : fields) { Object fieldValue = field.get(obj); if (values.contains(fieldValue)) { return false; } } return true; } </code></pre>
4,985,298
0
<p>See scala.xml.transform._ and the corresponding Stack Overflow questions.</p> <p>It will probably look somewhat like this:</p> <p><a href="http://www.scalakata.com/5022b395e4b032f990af0493" rel="nofollow"></p> <pre><code>import scala.xml._ import transform._ case class Article( title: String, content: String ) val articleList = List( Article("title 1","content 1"), Article("title 2","content 2") ) class TransformArticle(title: String, content: String) extends RewriteRule { override def transform(n: Node): Seq[Node] = n match { case div @ &lt;div/&gt; =&gt; div match { case elem: Elem if elem \ "@class" contains Text("title") =&gt; elem copy (child = Text(title)) case elem: Elem if elem \ "@class" contains Text("content") =&gt; elem copy (child = Text(content)) case other =&gt; other } case other =&gt; other } } val article_template = &lt;div&gt; &lt;div class="title"&gt;&lt;/div&gt; &lt;div class="content"&gt;&lt;/div&gt; &lt;!-- some other markups don't know --&gt; &lt;/div&gt; Group( articleList.flatMap( article =&gt; { new RuleTransformer(new TransformArticle(article.title, article.content)) transform article_template }) ) </code></pre> <p></a></p>
8,115,394
0
Strange behaviour with Osmdroid overlay at high zoom levels <p>I'm using the osmdroid 3.0.5 jar in my app to display a map view. I'm superimposing an overlay, consisting of horizontal and vertical lines. I've noticed that in certain locations only, at high zoom levels some of the lines disappear, then reappear as the map is dragged.</p> <p>I've produced a minimal sample app which demonstrates the problem which exhibits itself both on a real device and an emulator (Gingerbread 2.3.3).</p> <p>The complete code is shown below - (the 'transform' methods are necessary in the real app although they don't appear to be in this minimal sample) :</p> <pre><code>public class DemoMap extends Activity implements MapViewConstants { private MapView mapView; private MapController mapController; private MapOverlay mmapOverlay = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.copymain); mapView = (MapView) findViewById(R.id.mapview); mapView.setTileSource(TileSourceFactory.MAPNIK); mapView.setBuiltInZoomControls(true); mapView.setMultiTouchControls(true); mapController = mapView.getController(); mapController.setZoom(17); // Only shows the bug at ceratin lat/lon positions, this is one GeoPoint point2 = new GeoPoint(39191699, -120102561); mapController.setCenter(point2); mmapOverlay = new MapOverlay(this); List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays(); listOfOverlays.add(mmapOverlay); mapView.invalidate(); } public class MapOverlay extends org.osmdroid.views.overlay.Overlay { public MapOverlay(Context ctx) {super(ctx); } private int mVpl;// viewport left, top, right, bottom private int mVpt; private int mVpr; private int mVpb; private MapView mMv = null; // Two routines to transform and scale between viewport and mapview private float transformX(float in, MapView mv) { float out; out = ((mVpr - mVpl) * in) / (mv.getRight() - mv.getLeft()) + mVpl; return out; } private float transformY(float in, MapView mv) { float out; out = ((mVpb - mVpt) * in) / (mv.getBottom() - mv.getTop()) + mVpt; return out; } @Override protected void draw(Canvas pC, MapView mapV, boolean shadow) { if (shadow) return; Paint paint; paint = new Paint(); paint.setColor(Color.RED); paint.setAntiAlias(true); paint.setStyle(Style.STROKE); paint.setStrokeWidth(1); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(12); final Rect viewportRect = new Rect(); final Projection projection = mapV.getProjection(); viewportRect.set(projection.getScreenRect()); mVpl = viewportRect.left; mVpt = viewportRect.top; mVpr = viewportRect.right; mVpb = viewportRect.bottom; // draw two lines to split screen into 2x2 quarters // drag the map left and right and the vertical line disappears, // then reappears! It's OK at one less zoom level pC.drawLine(transformX(mapV.getWidth()/2, mapV), transformY(0, mapV), transformX(mapV.getWidth()/2, mapV), transformY(mapV.getHeight(), mapV), paint); pC.drawLine(transformX(0, mapV), transformY(mapV.getHeight()/2, mapV), transformX(mapV.getWidth(), mapV), transformY(mapV.getHeight()/2, mapV), paint); } } } </code></pre> <p>Interestingly if, in my real app, if I do the drawing to an offscreen bitmap, then draw it all in one go at the end of the Overlay's draw, it's OK the lines don't disappear.</p> <p>Any help will be much appreciated.</p>
30,964,205
0
Setting GlassFish-Mysql Connection Pool on Openshift <p>I just created a new application with the DIY cartridge and add a MySQL cartridge to it as well. I also was able to deploy the application online. I cannot use the GlassFish administration console with OpenShift but I need to set up JDBC resources, connection pools. I'm trying to edit the domains.xml of my remote glassfish server using that of my local glassfish server. I'm still unable to connect to the database. This is what I've done so far: </p> <pre><code>&lt;jdbc-connection-pool is-isolation-level-guaranteed="false" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" name="SamplePool" res-type="javax.sql.DataSource"&gt; &lt;property name="User" value="adminvcsHiYw"&gt;&lt;/property&gt; &lt;property name="DatabaseName" value="timetable"&gt;&lt;/property&gt; &lt;property name="serverName" value="127.8.28.2"&gt;&lt;/property&gt; &lt;property name="PortNumber" value="3306"&gt;&lt;/property&gt; &lt;property name="URL" value="jdbc:mysql://127.8.28.2:3306/timetable"&gt;&lt;/property&gt; &lt;property name="Password" value="_R-LrpYIcdUf"&gt;&lt;/property&gt; &lt;/jdbc-connection-pool&gt; </code></pre> <p>This is the output of <code>rhc tail -a appname</code></p> <pre><code> ==&gt; app-root/logs/mysql.log &lt;== 150621 7:55:43 InnoDB: highest supported file format is Barracuda. 150621 7:55:43 InnoDB: Waiting for the background threads to start 150621 7:55:44 InnoDB: 5.5.41 started; log sequence number 1686690 150621 7:55:44 [Note] Server hostname (bind-address): '127.8.28.2'; port: 3306 150621 7:55:44 [Note] - '127.8.28.2' resolves to '127.8.28.2'; 150621 7:55:44 [Note] Server socket created on IP: '127.8.28.2'. 150621 7:55:44 [Warning] 'proxies_priv' entry '@ [email protected]' ignored in --skip-name-resolve mode. 150621 7:55:44 [Note] Event Scheduler: Loaded 0 events 150621 7:55:44 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: ready for connections. Version: '5.5.41' socket: '/var/lib/openshift/5585ff875004465b5500013a/mysql//socket/mysql.sock' port: 3306 MySQL Community Server (GPL) ` </code></pre> <p>What am I doing wrong? Can anyone help?</p>
3,968,005
0
<p><a href="http://stackoverflow.com/questions/576431/is-there-a-conditional-ternary-operator-in-vb-net">http://stackoverflow.com/questions/576431/is-there-a-conditional-ternary-operator-in-vb-net</a></p>
5,037,323
0
Writing "Code::Blocks" Without the Colons <p>This is a bit of a silly question, but please bear with me. ;)</p> <p>I just got the <a href="http://codeblocks.org" rel="nofollow">Code::Blocks</a> IDE and I'm enjoying it thoroughly. However, since the <code>:</code> character isn't allowed in Windows folder names, I'm unsure of what to call the folder I keep all my projects in. (I name each folder after its IDE.)</p> <p>Should it be written as "Code Blocks," "CodeBlocks," or something else...?</p>
14,299,542
0
<pre><code>char (*po)[10]; </code></pre> <p>is a pointer to an array of 10 <code>char</code> items.</p> <p>An array expression doesn't decay to a pointer to itself-as-array. It decays (when it does) to a pointer to first item. Hence, the need for applying address operator, and also the error message you got about being unable to convert the array expression to a pointer-to-array.</p>
37,346,795
0
How to indent the XML-Output of XSLT in Eclipse? <p>I don't habe any ideas how to indent my XML-Output in Eclipse. Currently I have everything in one row.</p> <p>What should I define beside indent="yes" in my XSLT?</p> <p></p> <p>Another problem is that I can not eliminate xmlns:dc="http://purl.org/dc/elements/1.1/ after every DC-tag in my Output-XML. It's really surprising that exclude-result-prefixes="dc dcterms "> only excludes dcterms, but not for dc.</p> <p>Maybe someone has an idea?</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" exclude-result-prefixes="dc dcterms "&gt; &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /&gt; Output XML: &lt;dc:titel xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;Fragebogen FB001&lt;/dc:titel&gt; but it should be : &lt;dc:titel&gt;Fragebogen&lt;/dc:titel&gt; </code></pre>
24,862,943
0
Show 'page not found' on Drupal 7 node page <p>Need show 404 page on node page when some condition is true. I know that Drupal have drupal_not_found(), but I don't know where to use it. If I use it in hook_init() some blocks is not displaying. Where to use it function of maybe there is another solution for me?</p>
24,488,558
0
<p>Apache tika can transform PDF files into structured data for you to feed into the solr server . </p> <p>My approach to your problem would be to index each pdf per page, with extra fields linking to the chapter, text title (or absolute path, or both) and page number.Using this data you can then open the relevant document at the relevant page. </p> <p>Read more about tika here : <a href="http://tika.apache.org/" rel="nofollow">http://tika.apache.org/</a></p>
24,171,668
0
<p>You can launch your softwares from the terminal binaries themselves to get a new terminal for each. It would depend on the terminal you use. With <code>konsole</code> you can have</p> <pre><code>konsole -e command [args] ... </code></pre> <p>With gnome-terminal you do:</p> <pre><code>gnome-terminal -e command [args] &amp; </code></pre> <p>With xterm:</p> <pre><code>xterm -e command [args] &amp; </code></pre> <p>Probably refer as well to a similar thread: <a href="http://stackoverflow.com/questions/18669866/run-multiple-sh-scripts-from-one-sh-script-centos">Run multiple .sh scripts from one .sh script? CentOS</a></p>
8,642,024
0
<p>You could wrap the Thread's <code>Runnable</code> inside another <code>Runnable</code> that would decrement the counter:</p> <pre><code>Thread createThread(final Runnable r) { return new Thread(new Runnable() { @Override public void run() { try { r.run(); } finally { Foo.decrementCounter(); } } }); } </code></pre> <p>The problem with this is if the <code>Runnable r</code> creates multiple instances of Foo. You'd have to somehow track how many instances the thread created. You could do so using a <code>ThreadLocal&lt;Integer&gt;</code>, and then call <code>decrementCounter()</code>, in the <code>finally</code> block, the appropriate number of times. See below for a complete, working example.</p> <p>If you can avoid it, you should not rely on the behavior of the GC as it is quite impredictable! If you insist into dealing with the Garbage Collector, then you should use reference queues -- and to use it properly, you should study the concept of <em>object reachability</em>: <a href="http://docs.oracle.com/javase/7/docs/api/index.html?java/lang/ref/package-summary.html" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/index.html?java/lang/ref/package-summary.html</a></p> <p>As a final note, if I were interviewing you, I'd try to make you realize that the code you propose does not perfectly satisfy the requirements: you'd have to make the class <code>final</code>, or the method <code>incrementCount()</code> <code>final</code> or <code>private</code>. Or, easier, you could increment the count in an instance initializer block: no need to think about methods being overriden in subclasses or newly added constructors not incrementing the count.</p> <hr> <p>A complete example:</p> <pre><code>public class Foo { private static final AtomicInteger liveInstances = new AtomicInteger(0); private static final ThreadLocal&lt;Integer&gt; threadLocalLiveInstances = new ThreadLocal&lt;Integer&gt;() { @Override protected Integer initialValue() { return 0; } } // instance initializer (so you won't have problems with multiple constructors or virtual methods called from them): { liveInstances.incrementAndGet(); threadLocalLiveInstances.set(threadLocalLiveInstances.get() + 1); } public static int getTotalLiveInstances() { return liveInstances.get(); } public static int getThreadLocalLiveInstances() { return threadLocalLiveInstances.get(); } public static void decrementInstanceCount() { threadLocalLiveInstances.set(threadLocalLiveInstances.get() - 1); liveInstaces.decrementAndGet(); } // ... rest of the code of the class ... } class FooCountingThreadFactory implements ThreadFactory { public Thread newThread(final Runnable r) { return new Thread(new Runnable() { @Override public void run() { try { r.run(); } finally { while (Foo.getThreadLocalLiveInstances() &gt; 0) { Foo.decrementInstanceCount(); } } } }); } } </code></pre> <p>This way, you can feed this ThreadFactory to a thread pool, for example, or you can use it yourself when you want to build a thread: <code>(new FooCountingThreadFactory()).newThread(job);</code></p> <p>Anyways, there's still a problem with this approach: if a thread creates instances of <code>Foo</code> and stores them on global scope (read: <code>static</code> fields), then these instances will still be alive after the thread has died, and the counter will all the same be decremented to 0.</p>
6,118,382
0
TextView not displaying data from xml file <p>I am trying to retrieve some data from my xml file. Below is the code which should be working but in this case it doesn't. I am not getting errors but data just doesn't gets displayed.Please review this code and tell me what's wrong here. (I am trying to look at an id, if it matches a certain digit than display text) Thanks.</p> <pre><code>String stringXmlContent; try { stringXmlContent = getEventsFromAnXML(this); tv.setText(stringXmlContent); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } button1.setOnClickListener(this); } private String getEventsFromAnXML(Activity activity)throws XmlPullParserException, IOException { StringBuffer stringBuffer = new StringBuffer(); String attVal = null; String desc; Resources res = activity.getResources(); XmlResourceParser xrp = res.getXml(R.xml.myxml); try { xrp.next(); int eventType = xrp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if(eventType == XmlPullParser.START_DOCUMENT) { stringBuffer.append(" "); } if(eventType == XmlPullParser.START_TAG) { if(xrp.getName().equals("Number")){ attVal = xrp.getAttributeValue(0); } } else if(eventType == XmlPullParser.TEXT) { if(xrp.getName().equals("Description") &amp;&amp; attVal.equals("2")){ stringBuffer.append(" " + xrp.getText()); } } } } catch (XmlPullParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return stringBuffer.toString(); </code></pre>
25,282,476
0
<p>Most simple, without caring about delegates</p> <pre><code>if(textBox1.InvokeRequired == true) textBox1.Invoke((MethodInvoker)delegate { textBox1.Text = "Invoke was needed";}); else textBox1.Text = "Invoke was NOT needed"; </code></pre>
36,702,631
0
<p>A few recommendations I would like to make (based on the app we've built which also uses Table Storage exclusively).</p> <ul> <li>Introduce a new entity called <code>Account</code> or <code>Subscription</code>. You can use a GUID to uniquely identify an account.</li> <li>Along with user information (user id, password etc.) in the user's table, store the account information as well. So at all times when you're authenticating a user, you're making point queries. Also store the user's role (Member or Owner) in the user's table. Doing this way, you would know if the user is an individual user or part of a team. If the user is part of a team, then what the role of that user in that team (Owner or Member).</li> <li>Store 2 copies of user data. First copy is what you're using now. Second copy essentially associate a user with an account where the PartitionKey of the second copy is the account id and row key is the PartitionKey of the first copy. This will help you find the users in a particular team.</li> </ul> <p><strong>Individual User Login Scenario</strong></p> <p>So an individual user logs in using their username/password. You retrieve the information about the user and there you find out that the user is an individual user based on the account type.</p> <p><strong>Team Owner Login Scenario</strong> So when a team owner logs in, based on the login you will find out that the user is a team owner. If the team owner needs to find the list of all the users in the team, you do another query (it will be the PartitionKey query only) which will give you information about all the users in the team.</p> <p><strong>Team User Login Scenario</strong></p> <p>So when a team user logs in, based on the login you will find out that the user is a team user. Since the user is a team user, he/she need not query the table to find out about other users in the team. Even if they do, you will do another query (same as team owner query) to get the list of users in a team.</p>
254,416
0
<p>An EXISTS operator might be faster than the subquery:</p> <pre><code>SELECT t1.Index, MIN(t1.[Date]), MAX(t1.[Date]) FROM myTable t1 WHERE EXISTS (SELECT * FROM myTable t2 WHERE t2.Index = t1.Index AND t2.[Date] &gt;= '1/1/2000' AND t2.[Date] &lt; '1/1/2001') GROUP BY t1.Index </code></pre> <p>It would depend on table size and indexing I suppose. I like G Mastros HAVING clause solution too.</p> <p>Another important note... if your date is actually a DATETIME and there is a time component in any of your dates (either now or in the future) you could potentially miss some results if an index had a date of 12/31/2000 with any sort of time besides midnight. Just something to keep in mind. You could alternatively use YEAR([Date]) = 2000 (assuming MS SQL Server here). I don't know if the DB would be smart enough to use an index on the date column if you did that though.</p> <p>EDIT: Added GROUP BY and changed date logic thanks to the comment</p>
9,848,319
0
Is there a more succinct Linq expression for inserting a constant between every item in a list? <p>Here's what I have at the moment:</p> <pre><code>public List&lt;double&gt; GetStrokeDashArray(List&lt;double&gt; dashLengths, double gap) { return dashLengths .SelectMany(dl =&gt; new[] { dl, gap }) .Take(dashLengths.Count * 2 - 1) .ToList(); } </code></pre> <p>Results for <code>GetStrokeDashArray(new List&lt;double&gt; { 2, 4, 7, 11, 16 }, 2);</code></p> <pre><code>2, 2, 4, 2, 7, 2, 11, 2, 16 </code></pre>
39,335,784
0
<p>You can use <a href="https://docs.angularjs.org/api/ng/type/form.FormController" rel="nofollow">$setPristine()</a> for resetting the field state.</p> <p>HTML:</p> <pre><code>&lt;form name="myForm"&gt; &lt;input type="text" ng-model="data.test" ng-disabled="data.check"&gt; &lt;input type="text" ng-model="data.test2" ng-disabled="data.check"&gt; &lt;input type="checkbox" ng-change="reset()" ng-model="data.check" value="one"&gt; &lt;/form&gt; </code></pre> <p>JS:</p> <pre><code>$scope.resetForm = function() { $scope.data = { "test": "", "test2": "" }; // 'myForm' is the name of the &lt;form&gt; tag. $scope.myForm.$setPristine(); } </code></pre>
29,270,220
0
<p>as mentioned above, just printing will invoke the toString method of the object. As this method has not be overriden, the toString method of Object gets invoked. The exact output is specified in the javadocs <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString()" rel="nofollow">http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString()</a></p> <p>which says </p> <pre><code> getClass().getName() + '@' + Integer.toHexString(hashCode()) </code></pre> <p>i.e. it is the class name + "@" + the HexString of the objects hashCode() method</p>
29,756,966
0
Nested ui-view animations <p>I'm struggling to create separate animations on two ui-view elements simultaneously (or any animations), using ui router.</p> <p>My basic site layout is: </p> <ul> <li>main.html (has one ui-view, which is faded in) <ul> <li>customerMain.html which sits in "main" </li> </ul></li> </ul> <p><strong>main.html</strong></p> <pre><code>&lt;div id="work-container"&gt; &lt;div class="menu"&gt; &lt;!-- some ul/li stuff --&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;div ui-view class="view-animate-main-container"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>customerMain.html</strong></p> <pre><code>&lt;div id="customer-work-container"&gt; &lt;div class='menu'&gt; &lt;div ui-view='menu' class='view-animate-main-container'&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;div ui-view='content' class="view-animate-sub-container"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>CustomerModule</strong></p> <pre><code>angular.module('btApp.crm.customers', ['ui.router']) .config(['$stateProvider', '$urlRouterProvider', function config($stateProvider, $urlRouterProvider) { $stateProvider .state('main.customerMain', { abstract: true, templateUrl: '/ng/crm/customers/templates/customerMain.html', }) .state('main.customerMain.overview', { url: '/customer/:id', views: { '[email protected]': { templateUrl: "/ng/crm/customers/templates/menu.html", controller: 'CRMCustomerMenuCtrl' }, '[email protected]': { templateUrl: "/ng/crm/customers/templates/overview.html", controller: 'CRMCustomerOverviewCtrl' }, } }) }]); </code></pre> <p>In a nutshell, i'm trying to perform different animations on the two content views, but everything i've tried doesn't seem to take effect, even if i remove all the parent animations there is still no animations being applied to the views. I'm not entirely sure if ng-enter is being added, it's too quick to see.</p> <p>What i originally thought was happening was the fade-in animation was being applied to the main ui-view, which in then turn also runs while loading the child ui-views thus you don't see the animations, however, removing parent animations and delaying child animations, still nothing.</p> <p>Would welcome any pointers. </p>
26,757,900
0
<p>This is because you are fixing the content that pushes "tasks-column" to the right. The simple way to do what you want is just to move "info" inside col-md-4, like this:</p> <pre><code>&lt;div class="row"&gt; &lt;div class="col-md-4"&gt; &lt;div class="info"&gt; &lt;!--some fixed Markup --&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-md-8 tasks-column"&gt; &lt;!--some Markup --&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Hope this helps!</p>
7,431,892
0
$.getJSON just not working for me <p>I've read in numerous places that adding <code>&amp;callback=?</code> to the URL in $.getJSON will allow cross-domain JSON fetching. (e.g. see: <a href="http://www.ibm.com/developerworks/library/wa-aj-jsonp1/" rel="nofollow">http://www.ibm.com/developerworks/library/wa-aj-jsonp1/</a>) But it's just not working for me.</p> <p>Here's my form:</p> <pre><code> &lt;form id="commentForm_pub4101" class="commentForm" action="/SubmitComment" method="POST"&gt; &lt;h3&gt;Your comment:&lt;/h3&gt; &lt;div class="commentFormTopData commentFormRow"&gt; &lt;label for="Commenter"&gt;your name&lt;/label&gt; &lt;input class="commentFormCommenter" id="Commenter" name="Commenter" type="text" value="" /&gt; &lt;label for="Email"&gt;e-mail&lt;/label&gt; &lt;input class="commentFormEmail" id="Email" name="Email" type="text" value="" /&gt; &lt;/div&gt; &lt;div class="commentFormBody commentFormRow"&gt; &lt;label for="Body"&gt;comment&lt;/label&gt; &lt;textarea class="commentFormBody" cols="20" id="Body" name="Body" rows="2"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Here's my jQuery: </p> <pre><code>$('form[action$="SubmitComment"]').submit(function (event) { event.preventDefault(); $.getJSON('http://localhost/Comments/index.asp?Title=TESTTitle&amp;Commenter=TESTCommenter&amp;Email=TESTemail&amp;Body=TESTBody&amp;PublicationId=TESTPublicationId&amp;callback=?', function (data2) { alert(data2.Title); } ); }); </code></pre> <p>The target URL is a classic-ASP script (don't ask why -- it's complicated), using the JSON_2.0.4.asp library to return a JSON result. I don't think that's related to the problem, because here's the returned result of a direct browser-call to the URL:</p> <pre><code>{"Commenter":"TESTCommenter","Email":"TESTemail","Body":"TESTBody","PublicationId":"TESTPublicationId","Title":"TESTTitle"} </code></pre> <p>But if you insist, here's the code (it's test at this point): </p> <pre><code>&lt;!--#include file="JSON_2.0.4.asp"--&gt; &lt;% Dim body: body = Request("") Dim jsa: Set jsa = jsObject() jsa("Commenter") = Request("Commenter") jsa("Email") = Request("Email") jsa("Body") = Request("Body") jsa("PublicationId") = Request("PublicationId") jsa("Title") = Request("Title") jsa.Flush %&gt; </code></pre> <p>...So when I put all this test code together .... no love. No alert window with 'TESTTitle' in it.</p> <p>What am I doing wrong??</p>
40,977,799
0
<p>The date format provided is insufficient to do parsing.</p> <p>Ruby can parse string dates so long as the format complies with certain rules.</p> <p>While using hyphens <code>-</code>, inclusion of a day is mandatory.</p> <p>This is because typically hyphenated date formats include the day.</p> <p>Fortunately, if you're willing or able to change the format you can do the following:</p> <pre><code>date = '2016/6' DateTime.parse(date) =&gt; Wed, 01 Jun 2016 00:00:00 +0000 </code></pre> <p>Otherwise I would just append the first to your dates.</p> <pre><code>date = '2016-6' + '-1' DateTime.parse(date) =&gt; Wed, 01 Jun 2016 00:00:00 +0000 </code></pre> <p>Now you can do typical comparison stuff:</p> <pre><code>date1 = ... date2 = ... case date1 &lt;=&gt; date2 when -1 # date1 is before date2 when 1 # date1 is after date2 when 0 # date1 is equal to date2 </code></pre>
16,483,525
0
<p>This is because you are outputting a numeric field. If you look at your HTML you will see that you have something like this:</p> <pre><code>&lt;input type="number" ... /&gt; </code></pre> <p>By defining the type as a numbber, the browser knows what to expect and it will give you a generic message. This is part of Html 5 spec. </p> <p>If you want to override the default behavior you could do this:</p> <pre><code>@Html.TextBoxFor(model =&gt; model.residentialExperience, new { @type = "text" }) </code></pre>
12,663,967
0
Accessing Facebook images over HTTPS <p>We're serving a Facebook feed in our site, which includes images such as profile pictures that are served off Facebook's cdn. Our site is served over HTTPS, and we generally use protocol-relative urls when linking to outside images. However, the facebook images were not showing up. After digging, i noticed that https links pointing to facebook cdn images throw an SSL error because the Facebook CDN url doesn't match the Akamai URL associated with their certificates. </p> <p>Compare:<br> <a href="http://profile.ak.fbcdn.net/hprofile-ak-prn1/50164_1132339922_583434524_n.jpg" rel="nofollow">http://profile.ak.fbcdn.net/hprofile-ak-prn1/50164_1132339922_583434524_n.jpg</a><br> <a href="https://profile.ak.fbcdn.net/hprofile-ak-prn1/50164_1132339922_583434524_n.jpg" rel="nofollow">https://profile.ak.fbcdn.net/hprofile-ak-prn1/50164_1132339922_583434524_n.jpg</a></p> <p>This makes using HTTPS or protocol-relative urls for facebook images impossible to access as image sources, and so makes embedding Facebook images into HTTPS sites impossible without triggering mixed content warnings.</p> <p>Has anyone run into this?</p>
36,084,938
0
ReSharper intermittently showing red errors for valid Razor code <p>When editing a CSHTML page, ReSharper is intermittedly showing some valid Razor syntax in red indicating an error. The syntax is red when I open the file, turns normal when I make an edit, then turns red again after a save:</p> <p><a href="https://i.stack.imgur.com/QciBg.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QciBg.gif" alt="ReSharper CSHTML error"></a></p> <p>Even when red, the code builds successfully and ReSharper even gives correct information about the syntax on hover:</p> <p><a href="https://i.stack.imgur.com/nG6OU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nG6OU.png" alt="enter image description here"></a> </p> <p>My environment is:</p> <ul> <li>ReSharper 10.0.2</li> <li>Visual Studio Enterprise 2015 Update 1</li> <li>ASP.NET 4.5</li> <li>MVC 5</li> </ul> <p>I have tried the solutions offered in other questions (e.g. <a href="http://stackoverflow.com/questions/15713167/resharper-can-not-resolve-symbol-even-when-project-builds">Resharper &quot;can not resolve symbol&quot; even when project builds</a>, <a href="http://stackoverflow.com/questions/29898607/resharper-is-suddenly-showing-red-for-razor-syntax">Resharper is suddenly showing red for Razor syntax</a>) like Suspending/Resuming ReSharper, clearing caches, etc. I even tried reinstalling ReSharper entirely but none of that helped.</p> <p>Potentially relevant (?) is that I recently installed MVC 3 and MVC 4 for other projects, but I have since uninstalled them again.</p> <p>Any suggestions for what might be causing this? Could it be a ReSharper bug somehow?</p> <p><strong>UPDATE:</strong></p> <p>This actually only happends when a ReSharper code cleanup is run and then a save is made. I had an extension which did this automatically on every save, but having disabled that the actual flow is:</p> <ul> <li>Make edits - <strong><em>OK</em></strong></li> <li>Save - <strong><em>OK</em></strong></li> <li>Clean up - <strong><em>OK</em></strong></li> <li>Save - <strong><em>RED</em></strong></li> </ul> <p>I am using the <em>Default: Full Cleanup</em> profile.</p>
16,627,512
0
<p>If you need information for more than the last 100 queries, you will simply need to collect existing data every 100 queries. I have implemented the latter feature in PHP PDO.</p> <p><a href="https://github.com/gajus/doll" rel="nofollow">https://github.com/gajus/doll</a></p> <p>This is an application layer solution.</p>
2,334,327
0
What is the linq equivalent to the SQL IN operator <p>With linq I have to check if a value of a row is present in an array.<br> The equivalent of the sql query:</p> <pre><code>WHERE ID IN (2,3,4,5) </code></pre> <p>How can I do?</p>
5,364,317
0
<p>Seems like a job for data structure called <code>multiset</code>.</p> <pre><code>Multiset&lt;Integer&gt; mp = HashMultiset.create(); mp.addAll(Arrays.asList(new Integer[] { 3, 3, 3, 1, 5, 8, 11, 4, 5 })); </code></pre> <p>Standard JDK 6 is primitive and do not contain <code>multiset</code>. If you do not want to rewrite it, you can use preexisting library like Google Guava-libraries or Apache Commons. </p> <p>For example with Guava-libraries you can</p> <pre><code> for (Integer i : mp.elementSet()) System.out.println(i + " is contained " + mp.count(i) + " times."); </code></pre> <p>And this would output:</p> <pre><code>1 is contained 1 times. 3 is contained 3 times. 4 is contained 1 times. 5 is contained 2 times. 8 is contained 1 times. 11 is contained 1 times. </code></pre>
26,230,390
0
<p>I suggest that you still use <code>select</code> but go with Angular-UI's <code>ui-select</code>:</p> <p><a href="https://github.com/angular-ui/ui-select" rel="nofollow">Angular-UI ui-select</a></p> <p>It's a wrapper for and AngularJS native implementation of <a href="http://ivaynberg.github.io/select2/" rel="nofollow">Select2</a></p>
20,503,552
0
<p>If waiting and upgrading the gsa software to v 7.2,.coming mid December is an option you will have wild card search built in.</p> <p>Otherwise you have to dig deeper. A possible option is a document filter. If you are interested in that option I might be able to help.</p> <p>I have developed such a document filter.</p>
16,027,009
0
OracleConnectionStringBuilder Exception <p>I am using Oracle.DataAccess.Client to access to the database. It works fine all the time, then all of a sudden, I will </p> <blockquote> <p>The type initializer for 'Oracle.DataAccess.Client.OracleConnectionStringBuilder' threw an exception. Inner exception: Configuration system failed to initialize</p> </blockquote> <p>from this line of command</p> <blockquote> <p>OracleConnectionStringBuilder strBuilder = new OracleConnectionStringBuilder();</p> </blockquote>
16,229,750
0
Javascript Causes DOM Elements to Be Deleted <p>This is probably just another instance of me staring at the code for too long and missing something important. Basically, I have a script that in WebKit when a .click (jQuery) event occurs, fills another with the content of clicked item. However, for some reason, clicking multiple times upon an item causes the DOM element to be deleted. Any ideas? JSFiddle with code samples linked below.</p> <p>Here's the function that I think is the culprit:</p> <pre><code>$(".vote-divs .vote-div").click(function () { $(".vote-none").hide() $(".step-2-column-left .vote-div").each(function () { $(this).hide(); }); $("#" + $(this).attr("id") + "-s").show(); $(".confirm-s").each(function () { $(this).hide(); }); if ($(this).attr("id") == "vote-grow") { $("#donation-vote-for").val("Grow"); $("#confirm-grow-s").show(); } else if ($(this).attr("id") == "vote-stache") { $("#donation-vote-for").val("Stache"); $("#confirm-stache-s").show(); } else if ($(this).attr("id") == "vote-shave") { $("#donation-vote-for").val("Shave"); $("#confirm-shave-s").show(); } else if ($(this).attr("id") == "vote-mutton") { $("#donation-vote-for").val("Mutton"); $("#confirm-mutton-s").show(); } else if ($(this).attr("id") == "vote-manchu") { $("#donation-vote-for").val("Manchu"); $("#confirm-manchu-s").show(); } console.log(event.target); $(".vote-none").html(event.target); goTo("3"); }); </code></pre> <p><a href="http://jsfiddle.net/wrVGQ/" rel="nofollow" title="JSFiddle">JSFiddle</a></p>
30,045,914
0
Can't get the text value of linkbutton in gridview <p>This is my markup:-</p> <pre><code> &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="245px" onrowcommand="GridView1_RowCommand" &gt; &lt;Columns&gt; &lt;asp:TemplateField&gt; &lt;ItemStyle BackColor="#CCCCCC" ForeColor="Black" Width="250px" HorizontalAlign="Center" BorderStyle="None" /&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="userList" runat="server" CommandName="Select" CommandArgument ='&lt;%# Container.DataItemIndex %&gt;' Text='&lt;%# Bind("users") %&gt;'&gt;&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p>And in the codebehind, I am trying to get the current row's text value, but can't seem to get it;</p> <p>it returns "".</p> <pre><code> protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int rowValue = Convert.ToInt32(e.CommandArgument.ToString()); GridView1.SelectedIndex = rowValue; string test = GridView1.SelectedRow.Cells[0].Text; } </code></pre>
24,791,964
0
<p>This code is not very elegant, but it does the job.</p> <pre><code>clear input obs v2 v3 v4 v5 v6 1 . 3 . . 1 2 2 . . 4 5 3 . 7 . . . 4 1 . 1 . 4 end gen strL nonmiss="" foreach var of varlist v2-v6 { replace nonmiss=nonmiss+" "+"`var'" if !missing(`var') } list nonmiss </code></pre>
39,065,294
0
Audio only room based WebRTC example with node.js <p>I'm looking for a simple audio only example which I can use to communicate on a isolated LAN. </p> <p>I'm looking for a room based example so I can measure the performance of the WebRTC app with multiple calls at the same time.</p>
26,628,878
1
Why is add and assign (+=) behaving strangely with numpy.ndarrays? <p>consider the following Python code:</p> <pre><code>import numpy a = numpy.random.rand(3,4) b = numpy.random.rand(3,4) c = a c += b c/2. - (a + b)/2. </code></pre> <p>The result of the last line is not an array with zeros. However, if I do:</p> <pre><code>d = a d = d + b d/2. - (a + b)/2. </code></pre> <p>Then the result is 0, as expected. This looks strange to me, can anybody please explain this behaviour? Is it wise to use <code>+=, /=, ...</code> for numpy arrays at all? Thank you!</p> <p>(This is only a minimal example, I have to add up several arrays.)</p>
22,727,318
0
How can I get a CAAnimation to call a block every animation tick? <p>Can I somehow have a block execute on every "tick" of a CAAnimation? It could possibly work like the code below. If there's a way to do this with a selector, that works too.</p> <pre><code>NSString* keyPath = @"position.x"; CGFloat endValue = 100; [CATransaction setDisableActions:YES]; [self.layer setValue:@(toVal) forKeyPath:keyPath]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath]; animation.duration = 1; animation.delegate = self; __weak SelfClass* wself = self; animation.eachTick = ^{ NSLog(@"Current x value: %f", [wself valueForKeyPath:keypath]); }; [self.layer addAnimation:animation forKey:nil]; </code></pre>
3,634,739
0
<p>Well, that's sorting them in descending order. You could sort them in <em>ascending</em> order like this:</p> <pre><code>customers.Sort((x, y) =&gt; x.DateOfBirth.CompareTo(y.DateOfBirth)); </code></pre> <p>If that's not what you were worried about, please specify what the problem is. Saying you don't get the expected result isn't very precise...</p>
32,982,553
0
Reading lines from text file and null point exception <pre><code>for(File d : documents) { if(d.isFile()) count++; { BufferedReader inputStream = null; try { inputStream = new BufferedReader(new FileReader(d)); String line; while ((line = inputStream.readLine()) !=null) { //condition to check the hyphen at end of line if(line.charAt(line.length() -1) == 45) { line = line.replace(line.charAt(line.length() -1),' '); String line2 = inputStream.readLine(); line = line.trim()+line2; } System.out.println(line); } finally { try { if(inputStream != null) inputStream.close(); } catch(IOException e) { } } } // System.out.println("\n" + tokens1); //System.out.println("\n" + count); } } catch(Exception e) { System.out.println("Null point exception"); } </code></pre> <p>When I remove the <strong>condition to check hyphen</strong>, it reads all the lines in the files and displays null pointer exception at the end. When I include this condition, it reads the file but whenever it finds first empty line, it stops and throws a null pointer exception.</p>
4,553,155
0
localising a text using gettext <p>I have a text in English which i want to convert it into French. </p> <p>The sequence that i followed are as under:</p> <ol> <li>generate all the text using xgettext command in terminal, creating .pot file</li> <li>creating .po file from .pot file</li> <li>creating .mo file from .po file</li> </ol> <p>I have copy the .mo file in "/usr/share/locale/fr/LC_MESSAGES"</p> <p>here is my code for main.c file:</p> <pre><code>int main() { setlocale(LC_ALL,""); bindtextdomain("main","/usr/share/locale"); textdomain("main"); printf( gettext("Hello world\n")); return (0); } </code></pre> <p>When i execute the program the French version of the text is not printed in terminal. What can be the reason for this issue?</p> <p>Here is my fr.po file</p> <pre><code># French translations for GNU main package. # Copyright (C) 2010 THE GNU main'S COPYRIGHT HOLDER # This file is distributed under the same license as the GNU main package. # msgid "" msgstr "" "Project-Id-Version: GNU main 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-12-29 10:14+0530\n" "PO-Revision-Date: 2010-12-29 12:21+0530\n" "Last-Translator: Lenin\n" "Language-Team: French\n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ASCII\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n &gt; 1);\n" #: main.c:29 #, c-format msgid "Hello world\n" msgstr "Bonjour tout le monde\n" </code></pre> <p>Here is my call to msgfmt from current directory:</p> <pre><code>msgfmt -c -v -o main.mo fr.po </code></pre>
10,927,004
0
<p>I found this to be a little more accurate:</p> <pre><code>SELECT owner, table_name, TRUNC(sum(bytes)/1024/1024/1024) GB FROM (SELECT segment_name table_name, owner, bytes FROM dba_segments WHERE segment_type in ('TABLE','TABLE PARTITION') UNION ALL SELECT i.table_name, i.owner, s.bytes FROM dba_indexes i, dba_segments s WHERE s.segment_name = i.index_name AND s.owner = i.owner AND s.segment_type in ('INDEX','INDEX PARTITION') UNION ALL SELECT l.table_name, l.owner, s.bytes FROM dba_lobs l, dba_segments s WHERE s.segment_name = l.segment_name AND s.owner = l.owner AND s.segment_type IN ('LOBSEGMENT','LOB PARTITION') UNION ALL SELECT l.table_name, l.owner, s.bytes FROM dba_lobs l, dba_segments s WHERE s.segment_name = l.index_name AND s.owner = l.owner AND s.segment_type = 'LOBINDEX') ---WHERE owner in UPPER('&amp;owner') GROUP BY table_name, owner HAVING SUM(bytes)/1024/1024 &gt; 10 /* Ignore really small tables */ ORDER BY SUM(bytes) desc </code></pre>
1,124,285
0
<p>I think, your problem is this line:</p> <pre><code> $forwardformat = str_replace(" ","",$forward); </code></pre> <p>This only matches the space-character. Tab, Newline etc. are not replaced (and do not really show in your (html-)output when echoing the result. Thus i recommend, you try</p> <pre><code> $forwardformat = preg_replace('/\s+/','',$forward); </code></pre> <p>HTH</p> <p>Argelbargel</p>
25,116,634
0
Ruby/Rspec: should be_false vs should == false <p>Here's my code: </p> <pre><code>class Dictionary def entries @entries ||= {} end def add(hash) if hash.class == Hash hash.each_pair do |k, v| entries[k] = v end else makehash = {hash =&gt; nil} self.add(makehash) end @entries = entries end def keywords @entries.keys end def include?(k) if @entries == nil false elsif self.keywords.include?(k) true else false end end end </code></pre> <p>And here's the test I'm running it against:</p> <pre><code>require 'dictionary' describe Dictionary do before do @d = Dictionary.new end it 'can check whether a given keyword exists' do @d.include?('fish').should be_false end </code></pre> <p>Now, that test will fail. However, if I change it to </p> <pre><code> it 'can check whether a given keyword exists' do @d.include?('fish').should == false end </code></pre> <p>then it passes.</p> <p>How can I change my code so that <code>should be_false</code> passes instead of <code>should == false</code>? Thanks.</p>
11,365,207
0
How to store credentials for third party services in Rails <p>I am setting up a redirection through SendGrid for the mails sent by my rails application. However I am not really satisfied with the way I'm told to store the credentials.</p> <p>As it is specified <a href="http://docs.sendgrid.com/documentation/get-started/integrate/examples/rails-example-using-smtp/" rel="nofollow">there</a>, they suggest to overwrite ActionMailers defaults in the config/environment.rb file. I've found out that my predecessor created a initializers/smtp.rb file where he defined the previous settings, but by discovering this file, I discovered the SMTP password...</p> <p>If I modify any of these files, anuone having access to the git repository will have access to the credentials (including the front-end and back-end freelances we work with).</p> <p>I was thinking of creating a file that would stay on the server's shared folder (like the database.yml file) and that would be symlinked to the app each time we deploy thanks to capistrano.</p> <p>What do you think of it? Would it be okay to just move this initializers/smtp.rb to the server's shared folder and symlink it when deploying? </p>
25,904,215
0
<p>The labels and the button should have the same parent.</p> <p>Make these changes:</p> <pre><code>add = Label(app, text="Addition").grid(row=0, column=0) sub = Label(app, text="Subtraction").grid(row=1,column=0) mul = Label(app, text="Multiplication").grid(row=0, column=1) div = Label(app, text="Division").grid(row=1, column=1) </code></pre>
25,033,616
0
<p>It's not possible if you don't have control over the parent site (in this case ebay.co.uk). Protocols, domains, and ports must match if you wan't target your scripts to parent site.</p> <p>If those frames were using the same domain, this would work:</p> <pre><code>&lt;button id="totop" onclick="window.parent.parent.scrollTo(0,0)"&gt; Scroll parent to top &lt;/button&gt; </code></pre> <p>If you had control over the parent site's (ebay.co.uk) web server, you could create a reverse proxy to fool the system. For example in Apache httpd you could create a reverse proxy like this:</p> <pre><code>ProxyPass /iframe http://vi.vipr.ebaydesc.com ProxyPassReverse /iframe http://vi.vipr.ebaydesc.com </code></pre> <p>And set the iframe's src to <a href="http://ebay.co.uk/iframe" rel="nofollow">http://ebay.co.uk/iframe</a></p> <pre><code>&lt;iframe src="http://ebay.co.uk/iframe"&gt;&lt;/iframe&gt; </code></pre> <p>This would allow you to target scripts to ebay.co.uk from the iframe.</p> <p>Anyway, in this case it's impossible.</p>