pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
21,452,002
0
<p>A comment does nothing (but your database driver might complain if there is not command at all):</p> <pre><code>/* Hello, world! */ </code></pre> <p>Unknown <a href="http://www.sqlite.org/pragma.html" rel="nofollow">PRAGMA</a> statements are ignored, and do not return anything:</p> <pre><code>PRAGMA testing_porpoises; </code></pre> <p>If you need a statement that returns an empty result set, you need a SELECT:</p> <pre><code>SELECT 0 WHERE 0; </code></pre>
25,689,156
0
<p>It should work fine if you remove the <code>;</code> at the end. (Tested)</p>
33,318,146
0
<p>Make change in your gruntfile.js</p> <p>htmlmin. files.src: ['<em>.html', '{,</em>/}*.html']and </p> <p>copy.dist.files.src:[ '<em>.{ico,png,txt}', '.htaccess', '</em>.html', '{,<em>/}</em>.html', 'images/{,<em>/}</em>.{webp}', 'styles/fonts/{,<em>/}</em>.*' ]</p> <p>In this way it is working for me.</p>
38,153,362
0
<p>In C a value of 0 means false and any other means true. Strings end in a null character with a value of 0. This while loop copies all the characters from s to d until the null (end of string) is reached.</p> <p>The assignment <code>*d++ = *s++</code> returns the same value as <code>*s++</code> is assigned to <code>*d</code></p> <p>After the loop both <code>s</code> and <code>d</code> will be pointing after the null character. Note that the null is also copied.</p>
8,610,479
0
<p>This loading message is generated by ShadowBox lightbox plugin because you have an error in your kjquery.js file at line 5, missing a <code>)</code> as Keith comented.</p> <p>As soon as you fix this error, all should work.</p>
18,583,439
0
<p>You need to simply tell it that the three corner symbols are different.</p> <pre><code> Scanner keys = new Scanner(System.in); int x = 0; int y = 0; public void getInput() { x = keys.nextInt(); y = keys.nextInt(); createart(); } public void createart() { System.out.print("00"); int counter = 0; while (counter &lt; x - 4) { System.out.print(1); counter++; } System.out.println("00"); counter = 0; System.out.print("0"); while (counter &lt; x - 2) { System.out.print(1); counter++; } System.out.print("0"); counter = 0; int counter2 = 0; while (counter &lt; y - 4) { System.out.println(""); while (counter2 &lt; x) { System.out.print(1); counter2++; } counter++; } System.out.println(""); counter = 0; while (counter &lt; x - 2) { System.out.print(1); counter++; } counter = 0; System.out.println("0"); System.out.print("00"); while (counter &lt; x - 4) { System.out.print(1); counter++; } System.out.print("00"); } </code></pre> <p>Simple logic. </p>
25,333,120
0
<p>There's 2 ways you could solve this that don't require your application code to be aware of your container.</p> <p>The first method, instead replacing the registered instance of <code>UserModel</code> with a new instance, you'd just update the registered instances properties to the new values. This is probably the simplest, if your type is mutable and not overly complex.</p> <p>This second method would be appropriate if updating the original <code>UserModel</code> instance is undesirable or impossible. Basically, just add a layer of indirection:</p> <pre class="lang-cs prettyprint-override"><code>// ------------------------- // add this class: public class Changeable&lt;T&gt; { public T Value { get; set; } } // ------------------------- // set up registrations like so: // register the default value like so builder.RegisterInstance( new Changeable&lt;UserModel&gt; { Value = new UserModel { Id = Migration001.GuestUserId, Email = Migration001.GuestEmail, PasswordHash = Migration001.GuestPassword } }); // register UserModel directly, which can be used by all the classes that don't // need to change the instance builder.Register(c =&gt; c.Resolve&lt;Changeable&lt;UserModel&gt;&gt;().Value); </code></pre> <p>Now your service classes can take a constructor parameter of either <code>Changeable&lt;UserModel&gt;</code> or just <code>UserModel</code> depending on whether they need to be able to change the instance or not, with no more direct reference to the container.</p>
37,059,064
0
<p>In your env file, the value should not have any single or double quotes.</p>
33,842,179
0
<p>You have to use <code>then</code> method from fetchGraph or else return data from success method of <code>$http</code>.</p> <p>My recommendation, you can keep watch on the <code>self.items</code>. so whenever it change you can re-draw your graph.</p> <pre><code>$scope.$watch( "self.items", function () { //re-draw your graph $scope.$apply(); // not needed always, just a precaution } ); </code></pre>
28,346,534
0
Select count breaks in do-while loop <p>Where I work we need to register computers into a database, before we just used pen an paper, but I was asked to create an easier method. So I made a small local homepage.</p> <p>The computers are registered by a tag and number. The tag combined with the number must be unique, I made this loop that increment the entered number until it finds a free one.</p> <pre><code> $checkUnique = openConnection("stationer")-&gt;prepare("SELECT COUNT(1) FROM `dator` WHERE `tag_id`=:id AND `tag_number`=:number"); do{ $checkUnique -&gt; bindParam(":number", $_POST['number']); $checkUnique -&gt; bindParam(":id", $_POST['tag']); $checkUnique -&gt; execute(); $checkUniqueResult = $checkUnique-&gt;fetchColumn(); if($checkUniqueResult != 0 &amp;&amp; empty($searchTagNumber)){ $errors[] = "Non-unique tag and number"; break; } $_POST['number'] = $searchTagNumber == "+" ? $_POST['number']+1 : $_POST['number']-1; if($_POST['number'] &lt;= 0){ $errors[] = "The tag number can't be 0 or lower"; break; } }while($checkUniqueResult &gt; 0); </code></pre> <p>But for some odd reason, it appear to randomly stop, even if the tag and number isn't unique, with no error messages, and I have no idea what causes it.</p>
14,955,256
0
C# prevent excel file from getting modified <p>Hi I'm searching a way to <strong>prevent</strong> an <strong>excel file</strong> from being <strong>modified</strong>. I <strong>don't want to use hidden fields</strong>, where you have to place a calculated hashcode in.</p> <p>My program should be able to note that a file has been modified outside the application when I reopen the file. </p> <p><strong>EDIT: Sorry i forgot to mention I also don't want to use a password</strong>, because the excel file may be only edited in the application and not outside...</p> <p>Is there a solution for this?</p> <p>Thanks in advance</p>
24,145,737
0
<p>Something like this?</p> <p><img src="https://i.stack.imgur.com/WZMY9.png" alt="enter image description here"></p> <pre><code>&lt;Grid HorizontalAlignment="Center" VerticalAlignment="Center"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="25"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.Resources&gt; &lt;Style TargetType="Rectangle"&gt; &lt;Setter Property="Stroke" Value="Black"/&gt; &lt;Setter Property="StrokeThickness" Value="1"/&gt; &lt;Setter Property="Height" Value="11"/&gt; &lt;Setter Property="Width" Value="11"/&gt; &lt;!-- For hittestvisibility --&gt; &lt;Setter Property="Fill" Value="Transparent"/&gt; &lt;/Style&gt; &lt;/Grid.Resources&gt; &lt;Line X1="0" Y1="1" X2="0" Y2="0" Stretch="Fill" Stroke="Black" /&gt; &lt;Rectangle VerticalAlignment="Top" HorizontalAlignment="Center"/&gt; &lt;Grid Grid.Row="1" Height="200" Width="200" Margin="-5"&gt; &lt;Rectangle Margin="5" Height="Auto" Width="Auto" Fill="{x:Null}"/&gt; &lt;Rectangle VerticalAlignment="Top" HorizontalAlignment="Left"/&gt; &lt;Rectangle VerticalAlignment="Top" HorizontalAlignment="Center"/&gt; &lt;Rectangle VerticalAlignment="Top" HorizontalAlignment="Right"/&gt; &lt;Rectangle VerticalAlignment="Center" HorizontalAlignment="Left"/&gt; &lt;Rectangle VerticalAlignment="Center" HorizontalAlignment="Right"/&gt; &lt;Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Left"/&gt; &lt;Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Center"/&gt; &lt;Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Right"/&gt; &lt;!-- The Content --&gt; &lt;Rectangle Width="Auto" Height="Auto" Margin="20" Fill="Green"/&gt; &lt;TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Content"/&gt; &lt;/Grid&gt; &lt;/Grid&gt; </code></pre> <p>The terminology is <a href="http://help.adobe.com/en_US/illustrator/cs/using/WS714a382cdf7d304e7e07d0100196cbc5f-6480a.html#WS714a382cdf7d304e7e07d0100196cbc5f-647ba" rel="nofollow noreferrer">Bounding Box</a></p>
17,343,781
0
<p>Don't reinvent the wheel, building a custom testing software mini empire from scratch. Use SOAPUI open source version to test web services. It allows you to:</p> <ul> <li>generate SOAP tests from web service endpoint WSDL, saving manual labour</li> <li>avoid processing "pre-canned" SOAP strings and parsing files </li> <li>automatically generate mocks of your service endpoints, including ability to programmatically control custom responses. </li> <li>implement test step logic including loops, branches, invoking other test steps, running scripts, and reading/writing parameters from/to property files and data sources (although you must programatically navigate &amp; modify XmlHolder instances via scripts if you wish to "data-drive" your tests)</li> <li>Execute SOAP, REST, security &amp; load testing of web services, and also JDBC and HTTP test calls. </li> <li>Integrates with the common build and continuous integration tools for test automation (TDD &amp; continuous delivery). </li> <li>Use SOAPUI operations within your IDE, via plugins. </li> </ul> <p>It's considered fairly standard "best practice" for testing web services.</p> <p>To checks SOAP response messages for valid content, using the open source version of SOAPUI:</p> <ul> <li>you can use <a href="http://www.soapui.org/Functional-Testing/xpath-and-xquery-assertions.html" rel="nofollow">XPath or XQuery expressions to validate the XML</a>.</li> <li><p>you can use <a href="http://www.soapui.org/Functional-Testing/script-assertions.html" rel="nofollow">script assertions</a></p> <p>E.g. if your SOAP response is:</p> <pre><code> &lt;soap:Body&gt; &lt;GetEnumResponse xmlns="http://www.xyz.com/"&gt; &lt;GetEnumResult&gt; &lt;ErrorCode&gt;0&lt;/ErrorCode&gt; &lt;StatusId&gt;0&lt;/StatusId&gt; &lt;/GetEnumResult&gt; &lt;enumsInformation&gt; &lt;EnumInformation&gt; &lt;TransactionId&gt;0&lt;/TransactionId&gt; &lt;ConstraintId&gt;5000006&lt;/ConstraintId&gt; &lt;EnumValue&gt;xyz&lt;/EnumValue&gt; &lt;Index&gt;10&lt;/Index&gt; &lt;/EnumInformation&gt; &lt;/enumsInformation&gt; &lt;/GetEnumResponse&gt; &lt;/soap:Body&gt; </code></pre> <p>You can script:</p> <pre><code> import com.eviware.soapui.support.XmlHolder def holder = new XmlHolder(messageExchange.responseContentAsXml) holder.namespaces["tal"]="http://www.xyz.com/" def node = holder.getNodeValue("//tal:ConstraintId[1]"); log.info(node); assert node == "5000006"; </code></pre></li> <li><p>You can even use the maximum power of standard java regex processing. </p> <p>Create java classes that do the regex processing and put them into a jar file and place in soapUIinstallation/bin/ext as explained <a href="http://technicaltesting.wordpress.com/tag/soapui/" rel="nofollow">here</a>.</p> <p>Or wrap your SOAPUI Test inside a JUnit test method, and add standard java code at end to check regexs. This also eases test automation &amp; allows any non-web service tests to be executed as well. This approach works with SOAPUI open source version, whereas the alternative of using SOAPUI assertion steps requires the Pro version.</p> <p>Steps:</p> <ol> <li>If you choose, install the SOAPUI plugin in your IDE</li> <li>Use SOAPUI to create a test suite</li> <li>Use SOAPUI to create test case(s) within the test suite</li> <li>Use SOAPUI to create test step(s) within the test suite. This is the core of using SOAPUI. </li> <li>Create a Java project in your IDE. Within this project, add a JUnit test case.</li> <li>Add all JARs from SoapUI bin and lib directories to Java Build Path.</li> <li>Within the Junit Test case, add code to execute a SOAPUI test step</li> <li>Obtain the MessageExchange object, get the response from it, and then get headers, content or attachments. Run a regex check on result.</li> </ol> <p>The following is indicative only. Not intended to be a working example.</p> <pre><code> package com.example; import org.junit.Test; import com.eviware.soapui.tools.SoapUITestCaseRunner; public class SoapUIProject { // runs an entire SOAPUI test suite @Test public void soapTest1() throws Exception { SoapUITestCaseRunner runner = new SoapUITestCaseRunner(); runner.setProjectFile("/path/to/your/W3Schools-Tutorial-soapui-project.xml"); runner.run(); } // runs a single SOAPUI test step - and checks response matches a regex @Test public void soapTest2() throws Exception { WsdlProject project = new WsdlProject( "src/dist/sample-soapui-project.xml" ); TestSuite testSuite = project.getTestSuiteByName("My Test Suite"); TestCase testCase = testSuite.getTestCaseByName("My Test Case"); TestCaseRunner testCaseRunner = new WsdlTestCaseRunner(testCase,null); // Must have test step setup as WsdlMessageExchange for cast to work WsdlMessageExchangeTestStepResult testStepResult = (WsdlMessageExchangeTestStepResult)testStep.runTestStepByName("My Test Step"); // TestStep testStep = testCase.getTestStepByName("My Test Step"); // TestCaseRunContext testCaseRunContext = new WsdlTestRunContext(testStep); // testStep.prepare(testCaseRunner, testCaseRunContext); // WsdlMessageExchangeTestStepResult testStepResult = (WsdlMessageExchangeTestStepResult)testStep.run(testCaseRunner, testCaseRunContext); MessageExchange[] messageExchanges = testStepResult.getMessageExchanges(); for (MessageExchange me : messageExchanges) { String response = me.getResponseContentAsXML(); // do any desired regex processing // can use any desired assertions } assertEquals( Status.FINISHED, runner.getStatus() ); } } </code></pre></li> </ul> <p>Further refs: <a href="http://www.soapui.org/Scripting-Properties/tips-a-tricks.html#3-xml-nodes" rel="nofollow">http://www.soapui.org/Scripting-Properties/tips-a-tricks.html#3-xml-nodes</a> <a href="http://books.google.com.au/books?id=DkWx7xZ263gC&amp;printsec=frontcover#v=onepage&amp;q&amp;f=false" rel="nofollow">http://books.google.com.au/books?id=DkWx7xZ263gC&amp;printsec=frontcover#v=onepage&amp;q&amp;f=false</a></p>
34,092,263
0
Saving a field generated in ng-repeat in AngularJS <p>So, what I need here is to save a data in an array for every field generated in ng-repeat. My code looks something like this:</p> <pre><code>&lt;tr ng-repeat = "feature in filteredFeatures"&gt; &lt;td&gt;{{feature.name}}&lt;/td&gt; &lt;td&gt;&lt;input type="number" ng-model=""&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>So, whatever the user writes on the input field I want it to be saved, but certainly I have no idea how.</p>
18,374,019
0
<p>Hunspell is likely the most famous spell checker around:<br> <a href="http://hunspell.sourceforge.net/" rel="nofollow">http://hunspell.sourceforge.net/</a></p> <p>There are multiple versions of hunspell, but Aspell is an alternative:<br> <a href="http://aspell.net/" rel="nofollow">http://aspell.net/</a></p>
34,331,395
0
<p>Thanks for your question. It is possible to process multiple refunds (or rebates as we refer to them) against a single transaction. This isn't setup by default on your account, however. You can email your account manager and request that multiple rebates be enabled.</p> <p>Best,</p> <p>SeΓ‘n</p> <p><strong>Channel Support</strong></p> <p><strong>Realex Payments</strong></p>
7,438,268
0
elasticsearch boosting slowing query <p>this is a very novice question but I'm trying to understand how boosting certain elements in a document works. </p> <p>I started with this query, </p> <pre><code>{ "from": 0, "size": 6, "fields": [ "_id" ], "sort": { "_score": "desc", "vendor.name.stored": "asc", "item_name.stored": "asc" }, "query": { "filtered": { "query": { "query_string": { "fields": [ "_all" ], "query": "Calprotectin", "default_operator": "AND" } }, "filter": { "and": [ { "query": { "query_string": { "fields": [ "targeted_countries" ], "query": "All US" } } } ] } } } } </code></pre> <p>then i needed to boost certain elements in the document more than the others so I did this </p> <pre><code>{ "from": 0, "size": 60, "fields": [ "_id" ], "sort": { "_score": "desc", "vendor.name.stored": "asc", "item_name.stored": "asc" }, "query": { "filtered": { "query": { "query_string": { "fields": [ "item_name^4", "vendor^4", "id_plus_name", "category_name^3", "targeted_countries", "vendor_search_name^4", "AdditionalProductInformation^0.5", "AskAScientist^0.5", "BuyNowURL^0.5", "Concentration^0.5", "ProductLine^0.5", "Quantity^0.5", "URL^0.5", "Activity^1", "Form^1", "Immunogen^1", "Isotype^1", "Keywords^1", "Matrix^1", "MolecularWeight^1", "PoreSize^1", "Purity^1", "References^1", "RegulatoryStatus^1", "Specifications/Features^1", "Speed^1", "Target/MoleculeDescriptor^1", "Time^1", "Description^2", "Domain/Region/Terminus^2", "Method^2", "NCBIGeneAliases^2", "Primary/Secondary^2", "Source/ExpressionSystem^2", "Target/MoleculeSynonym^2", "Applications^3", "Category^3", "Conjugate/Tag/Label^3", "Detection^3", "GeneName^3", "Host^3", "ModificationType^3", "Modifications^3", "MoleculeName^3", "Reactivity^3", "Species^3", "Target^3", "Type^3", "AccessionNumber^4", "Brand/Trademark^4", "CatalogNumber^4", "Clone^4", "entrezGeneID^4", "GeneSymbol^4", "OriginalItemName^4", "Sequence^4", "SwissProtID^4", "option.AntibodyProducts^4", "option.AntibodyRanges&amp;Modifications^1", "option.Applications^4", "option.Conjugate^3", "option.GeneID^4", "option.HostSpecies^3", "option.Isotype^3", "option.Primary/Secondary^2", "option.Reactivity^4", "option.Search^1", "option.TargetName^1", "option.Type^4" ], "query": "Calprotectin", "default_operator": "AND" } }, "filter": { "and": [ { "query": { "query_string": { "fields": [ "targeted_countries" ], "query": "All US" } } } ] } } } } </code></pre> <p>the query slowed down considerably, am I doing this correctly? Is there a way to speed it up? I'm currently in the process of doing the boosting when I index the document, but using it in the query that way is best for the way my application runs. Any help is much appreciated </p>
29,489,857
0
<p>As far as I know you can't build your custom transitions and use them like normal WinRT Transitions, that is, inside a TransitionCollection.</p> <pre><code>&lt;ListView.Transitions&gt; &lt;TransitionCollection&gt; &lt;myTransitions:PotatoeTransition/&gt; &lt;/TransitionCollection&gt; &lt;/ListView.Transitions&gt; </code></pre> <p>You can't do the above as far as I know. (ignore the fact that I exemplified with a ListView, it applies to everything, I think) </p> <p>You'll probably have to use a Storyboard that animates both the RenderTransform (TranslateTransform) and the Opacity to achieve your objective.<br> I think you can still create a Behavior though if you want to make it more reusable. </p>
12,981,417
0
Why does svn authz need read access by default? <p>I need to give read/write access for a user to an exactly one repository.</p> <p>Why this doesn't work?</p> <pre><code>[groups] dev = dvolosnykh,sam [/ukk] ukk = rw [/] @dev = rw </code></pre> <p>Why should I add this?</p> <pre><code>[/] @dev = rw * = r # read access for everyone. Why? </code></pre> <p>I'm using dav_svn, apache2, Linux Ubuntu server 11.04</p> <p>My dav_svn.conf:</p> <pre><code>&lt;Location /svn&gt; DAV svn SVNParentPath /var/svn SVNListParentPath On AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/apache2/dav_svn.passwd AuthzSVNAccessFile /etc/apache2/dav_svn.authz Require valid-user &lt;/Location&gt; </code></pre>
31,563,017
0
anglularJs custom directive not loading <p>I am trying to create a custom directive in the below manor:</p> <p>my main html file:</p> <pre><code>&lt;body ng-app="boom"&gt; &lt;!--&lt;section ng-include="'data-table.html'"&gt;&lt;/section&gt;--&gt; &lt;data-table&gt;&lt;/data-table&gt; &lt;/body&gt; </code></pre> <p>my app.js file:</p> <pre><code>(function () { var app = angular.module('boom', ['ajs-directives']); })(); </code></pre> <p>my ajs-directive.js file:</p> <pre><code>(function () { var app = angular.module('ajs-directives', []); app.directive('dataTable', function () { return { restrict: 'E', templateUrl: 'data-table.html', controller: function () { this.dataSet = dataSet; }, controllerAs: 'tableData' }; }); var dataSet = [ { prop1: 'one', prop2: 'two', prop3: 'three' }, { prop1: 'four', prop2: 'five', prop3: 'six' } ]; })(); </code></pre> <p>And my data-table.html file:</p> <pre><code>&lt;div class="table-wrapper"&gt; &lt;table class="table table-fixed"&gt; &lt;thead class="header"&gt; &lt;tr&gt; &lt;th&gt;Entity&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;/table&gt; &lt;div id="media_table_height" class="table-content scroll-outer"&gt; &lt;div class="scroll-inner"&gt; &lt;table class="table-fixed"&gt; &lt;tbody ng-repeat="data in tableData.dataSet"&gt; &lt;tr class="data-row"&gt; &lt;td&gt;{{data.prop1}}&lt;/td&gt; &lt;/tr&gt; &lt;tr class="data-row"&gt; &lt;td&gt;{{data.prop2}}&lt;/td&gt; &lt;/tr&gt; &lt;tr class="data-row"&gt; &lt;td&gt;{{data.prop3}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The issue I have is that nothing renders in my main html file. Just the <code>&lt;data-table&gt;&lt;/data-table&gt;</code> tags are visible. I get no console errors in Google Chrome.</p> <p>You might be able to see from my main html file that I have tried adding in the data-table.html file using the <code>ng-include="'data-table.html'"</code> attribute (and obviously creating a controller in the ajs-directive.js file). When I did it this way it worked fine.</p> <p>Just wondering why it won't work when I am using the directive - have been googling and tweaking for a few days but can't figure it out.</p>
40,995,374
0
<p>There is no such thing as "Abi64". Since you tagged the question MASM, we can guess that you're using the Windows platform, and clearly the "64" means that this is 64-bit code, so that does narrow down the possibilities tremendously. However, there are still two common calling conventions for 64-bit code on Windows. One of them is <code>__vectorcall</code> and the other is the Microsoft x64 calling convention (the one that was originally invented to make all other calling conventions obsolete but&hellip;didn't).</p> <p>Since the Microsoft x64 calling convention is the most common, and in this particular case, using <code>__vectorcall</code> wouldn't change anything, I'll assume it's the one that you're using. And then the code required becomes absolutely trivial. All you need to do is jump from <code>f1</code> to <code>f2</code>, since the stack will be set up identically. <code>f1</code>'s first two parameters are the two parameters that should be passed to <code>f2</code>, and the return value of <code>f2</code> is the return value of <code>f1</code>. Therefore:</p> <pre><code>f1: rex_jmp r8 ; third parameter (pointer to f2) is passed in r8 </code></pre> <p>This is not only trivial to write, but it is the most optimal implementation for both size and speed.<br> You can even modify the <code>v1</code> or <code>v2</code> parameters beforehand if you want, e.g.:</p> <pre><code>f1: inc ecx ; increment v1 (passed in ecx) ; multiply v2 (xmm1) by v1 (ecx) movd xmm0, ecx cvtdq2ps xmm0, xmm0 mulss xmm1, xmm0 rex_jmp r8 ; third parameter (pointer to f2) is passed in r8 </code></pre> <p>In case you wanted to do something more complicated, here's how it would work:</p> <pre><code>f1: sub rsp, 40 ; allocate the required space on the stack call r8 ; call f2 through the pointer, passed in r8 add rsp, 40 ; clean up the stack ret </code></pre> <p>Note that you do not need the prologue/epilogue code that you've shown in the question, though it won't hurt anything if you choose to include it.</p> <p>However, the shuffling of parameters that you were doing in the example code shown in the question is <em>wrong</em>! In the Microsoft x64 calling convention, the first up-to-four integer arguments are passed in registers, from left to right, in RCX, RDX, R8, and R9. All other integer arguments are passed on the stack. The first up-to-four floating-point values are also passed in registers, from left to right, in XMM0, XMM1, XMM2, and XMM3. The rest are passed on the stack, along with structs too large for registers.</p> <p>The weird thing, though, is that the slots are "fixed", so only 4 total register args can be used, even when you have a mix of integer and fp args. Thus:</p> <pre><code>╔═══════════╦══════════════════════════╗ β•‘ β•‘ TYPE β•‘ β•‘ PARAMETER ╠═════════╦════════════════╣ β•‘ β•‘ Integer β•‘ Floating-Point β•‘ ╠═══════════╬═════════╬════════════════╣ β•‘ First β•‘ RCX β•‘ XMM0 β•‘ ╠═══════════╬═════════╬════════════════╣ β•‘ Second β•‘ RDX β•‘ XMM1 β•‘ ╠═══════════╬═════════╬════════════════╣ β•‘ Third β•‘ R8 β•‘ XMM2 β•‘ ╠═══════════╬═════════╬════════════════╣ β•‘ Fourth β•‘ R9 β•‘ XMM3 β•‘ ╠═══════════╬═════════╩════════════════╣ β•‘ (rest) β•‘ on stack β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• </code></pre> <p>It doesn't matter that the second parameter is the first floating-point value that is being passed. It doesn't go in XMM0 because it's the first floating-point value, it goes in XMM1 because it's the second parameter and therefore in the second "slot". (This is different from <a href="https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI" rel="nofollow noreferrer">the x86-64 System V ABI</a>, where the first 6 integer args go in registers, whether or not there are FP args).</p> <p>More detailed documentation on Windows parameter passing is available <a href="https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx" rel="nofollow noreferrer">here</a>, including examples.</p>
19,110,774
0
Widevine Test content for player validation <p>I know that the Widevine DRM scheme is supported in the 4+ version of the Android devices. I have created a media player application, how do I validate my player for playback of Widevine evcrypted content.</p>
30,340,116
0
<p>The problem appears to go away when you go download and install the new command line tools for 6.3.2.</p>
9,825,691
0
<p>yuo can add a screen for enter a coupons.<br> and the user can go in there and insrert his code and if it is correct you can give him whatever you want.</p>
22,956,303
0
<p>The storyboard animation retains a reference to the item until the animation is complete.</p> <p>You should do the following:</p> <ol> <li>Move storyboards into resources, enabling you to access them from code behind.</li> <li>Create a field to reference the MyItem to be deleted.</li> <li>Set that field when "Delete" button is clicked</li> <li>Attach a StoryBoard.Completed event handler to the "fadeOut" storyboard, that removes the MyItem to be deleted from your collection, once the storyboard animation is done.</li> </ol> <p>Here is a solution that works:</p> <p>Code-behind:</p> <pre><code>using System; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Input; using System.Windows.Media.Animation; namespace WpfApplication2 { /// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { private MyItem _itemToDelete; public ICommand DeleteCommand { get; private set; } public MainWindow() { InitializeComponent(); DeleteCommand = new MyCommand&lt;MyItem&gt;(Delete); this.Loaded += MainWindow_Loaded; } void MainWindow_Loaded(object sender, RoutedEventArgs e) { var fadeOutStoryBoard = TryFindResource("fadeOut"); if (fadeOutStoryBoard != null &amp;&amp; fadeOutStoryBoard is Storyboard) { (fadeOutStoryBoard as Storyboard).Completed += fadeOutStoryBoard_Completed; } } void fadeOutStoryBoard_Completed(object sender, EventArgs e) { if (this._itemToDelete != null) { MyItems myItems = Resources["myItems"] as MyItems; myItems.Remove(this._itemToDelete); } } private void Delete(MyItem myItem) { this._itemToDelete = myItem; } } public class MyItem : DependencyObject { public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(string), typeof(MyItem)); public string Name { get { return (string)GetValue(NameProperty); } set { SetValue(NameProperty, value); } } } public class MyItems : ObservableCollection&lt;MyItem&gt; { } public class MyCommand&lt;T&gt; : ICommand { private readonly Action&lt;T&gt; executeMethod = null; private readonly Predicate&lt;T&gt; canExecuteMethod = null; public MyCommand(Action&lt;T&gt; execute) : this(execute, null) { } public MyCommand(Action&lt;T&gt; execute, Predicate&lt;T&gt; canExecute) { executeMethod = execute; canExecuteMethod = canExecute; } public event EventHandler CanExecuteChanged; public void NotifyCanExecuteChanged(object sender) { if (CanExecuteChanged != null) CanExecuteChanged(sender, EventArgs.Empty); } public bool CanExecute(object parameter) { return canExecuteMethod != null &amp;&amp; parameter is T ? canExecuteMethod((T)parameter) : true; } public void Execute(object parameter) { if (executeMethod != null &amp;&amp; parameter is T) executeMethod((T)parameter); } } } </code></pre> <p>XAML:</p> <pre><code> &lt;Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication2" Title="MainWindow" Height="350" Width="525" DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt; &lt;Window.Resources&gt; &lt;local:MyItems x:Key="myItems"&gt; &lt;local:MyItem Name="Item 1" /&gt; &lt;local:MyItem Name="Item 2" /&gt; &lt;local:MyItem Name="Item 3" /&gt; &lt;/local:MyItems&gt; &lt;Style TargetType="{x:Type ListBoxItem}"&gt; &lt;Setter Property="OverridesDefaultStyle" Value="True" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ListBoxItem}"&gt; &lt;ContentPresenter Margin="0,0,0,4" /&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;Storyboard x:Key="fadeIn"&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="controlBox" Storyboard.TargetProperty="Opacity" To="1" /&gt; &lt;/Storyboard&gt; &lt;Storyboard x:Key="fadeOut"&gt; &lt;DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="controlBox" Storyboard.TargetProperty="Opacity" To="0" /&gt; &lt;/Storyboard&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;ListBox ItemsSource="{StaticResource myItems}"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Border Margin="5" Padding="5" BorderBrush="Blue" BorderThickness="1"&gt; &lt;Border.Triggers&gt; &lt;EventTrigger RoutedEvent="MouseEnter"&gt; &lt;BeginStoryboard Storyboard="{StaticResource fadeIn}"&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;EventTrigger RoutedEvent="MouseLeave"&gt; &lt;BeginStoryboard Storyboard="{StaticResource fadeOut}"&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Border.Triggers&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;ColumnDefinition Width="Auto" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Grid.Column="0" Text="{Binding Name}" /&gt; &lt;StackPanel Grid.Column="1" x:Name="controlBox" Opacity="0"&gt; &lt;Button Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:MainWindow}}}" CommandParameter=" {Binding}"&gt;Delete&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre>
35,574,206
0
<p>In fact, your issue is related to the content negotiation feature of HTTP (Conneg). This leverages two headers:</p> <ul> <li><code>Content-Type</code>: the format of the text payload of a request or a response. In your case, this header tells to the client the structure of the data you return.</li> <li><code>Accept</code>: the format of the text payload you expect in the response. This header is used within requests and is automatically set by the browser according to what it supports. The server is responsible of taking into account this header to return the supported content.</li> </ul> <p>See this article for more details:</p> <ul> <li>Understanding HTTP content negotiation: <a href="http://restlet.com/blog/2015/12/10/understanding-http-content-negotiation/" rel="nofollow">http://restlet.com/blog/2015/12/10/understanding-http-content-negotiation/</a></li> </ul> <p>Restlet provides out of the box content negotiation. I mean you return a text, it will automatically set the <code>Content-Type</code> header in the response to <code>text/plain</code>:</p> <pre><code>@Get public String represent(){ return "Hello World"; } </code></pre> <p>You have completely the hand if you want return another content type. Here is a sample:</p> <pre><code>@Get public Representation represent() { return new StringRepresentation( "&lt;tag&gt;Hello World&lt;/tag&gt;", MediaType.APPLICATION_XML); } </code></pre> <p>You can also define a parameter at the <code>@Get</code> level to take into account the provided <code>Accept</code> header:</p> <pre><code>@Get('xml') public Representation represent() { return new StringRepresentation( "&lt;tag&gt;Hello World&lt;/tag&gt;", MediaType.APPLICATION_XML); } @Get('json') public Representation represent() { return new StringRepresentation( "{ \"message\": \"Hello World\" }", MediaType.APPLICATION_JSON); } // By default - if nothing matches above @Get public Representation represent() { return new StringRepresentation( "Hello World", MediaType.PLAIN_TEXT); } </code></pre> <p>Another thing is that Restlet allows to leverage beans directly at the level of server resource methods instead of <code>String</code> or <code>Representation</code>. This corresponds to the converter feature. To use it, you need to register a converter. For example, simply add the jar file (org.restlet.ext.jackson with dependencies) from the Jackson extension of Restlet. A converter based of Jackson will be automatically registered. This way text payload will be converter to bean and bean to text.</p> <p>Now you will be able to use something like that:</p> <pre><code>@Get('json') public Message represent() { Message message = new Message(); message.setMessage("Hello world"); return message; } </code></pre> <p>based on a <code>Message</code> class you create:</p> <pre><code>public class Message { private String message; public String getMessage() { return this.message; } public void setMessage(String message) { this.message = message; } } </code></pre>
10,847,039
0
<p>Here is the step by step procedure to get you started:</p> <p><strong>Step 1:</strong> Download Solr. It's just a zip file.</p> <p><strong>Step 2:</strong> Copy from your <code>SOLR_HOME_DIR/dist/apache-solr-1.3.0.war</code> to your tomcat webapps directory: <code>$CATALINA_HOME/webapps/solr.war</code> – Note the war file name change. That’s important.</p> <p><strong>Step 3:</strong> Create your solr home directory at a location of your choosing. This is where the configuration for that solr install resides. The easiest way to do this is to copy the <code>SOLR_HOME_DIR/examples/solr</code> directory to wherever it is you want your solr home container to be. Say place it in <code>C:\solr</code>.</p> <p><strong>Step 4:</strong> Hope you have set your environment variables, if not then please set <code>JAVA_HOME</code>, <code>JRE_HOME</code>, <code>CATALINA_OPTS</code>, <code>CATALINA_HOME</code>. Note that <code>CATALINA_HOME</code> refers to your Tomcat directory &amp; <code>CATALINA_OPTS</code> refers to the amount of heap memory you want to give to your Solr.</p> <p><strong>Step 5:</strong> Start tomcat. Note this is only necessary to allow tomcat to unpack your war file. If you look under <code>$CATALINA_HOME/webapps</code> there should now be a solr directory.</p> <p><strong>Step 6:</strong> Stop tomcat</p> <p><strong>Step 7:</strong> Go into that solr directory and edit <code>WEB-INF/web.xml</code>. Scroll down until you see an entry that looks like this: </p> <pre><code>&lt;!-- People who want to hardcode their "Solr Home" directly into the WAR File can set the JNDI property here... --&gt; &lt;!-- &lt;env-entry&gt; &lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt; &lt;env-entry-value&gt;/Path/To/My/solr/Home/solr/&lt;/env-entry-value&gt; &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt; &lt;/env-entry&gt; --&gt; </code></pre> <p>Set your Solr home (for example: <code>C:\solr</code>) and uncomment the env entry.</p> <p><strong>Step 8:</strong> Start Tomcat again, and things should be going splendidly. You should be able to verify that solr is running by trying the url <code>http://localhost:8080/solr/admin/</code>.</p> <p>The other answers here are good enough to get you integrate Solr with your ASP.Net &amp; it should be pretty simple as Solr exposes HTTP.</p>
28,513,071
0
<p>Try changing this line:</p> <pre><code>RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?(.*)$ </code></pre> <p>to</p> <pre><code>RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/?([^/]+(?:/[^/]+|)) </code></pre> <p>So the regex will only attempt to capture as many as 2 virtual paths.</p>
11,647,017
0
<p>try this</p> <pre><code> header('Location: '.$nick.''); </code></pre>
19,267,010
0
<p>If you want a really real-time(around 200ms) response for your search application, for both the first time search query response and further suggested search response, Hadoop is not a good choice, not even Hive, HBase, or even Impala (or Apache Drill, Google Dremel like system). </p> <p>Hadoop is a batch processing system which is good for write once, read multiple times use cases. And the strength of it is good at scalability and I/O throuput. The trend I saw is that many organizations are using that as a data warehouse for offline data mining and BI analysis purpose as a replacement for data warehosue based on relational databases.</p> <p>Hive and HBase all provides extra features on top of Hadoop, but neither of those could possibly reach 200ms real time for average complex query workload.</p> <p>Check the high level view of how 'real-time' each possible solution can really reach, on <a href="http://incubator.apache.org/drill/" rel="nofollow">Apache Drill</a> homepage. CloudEra Impala, or Apache Drill, which borrows the idea from Google Dremel, have the intention to enhance the query speed on top of Hadoop by doing query optimization, column based storage, massive parallelism of I/O. I believe these 2 are still in early stage to achieve the goals they claim. Some <a href="http://architects.dzone.com/articles/meet-impala-open-source-real" rel="nofollow">initial performance benchmarking result of Impala</a> I found.</p> <p>If you decide to go with Hadoop or related solution stack, there are possible ways to load data from MySQL to Hadoop using <a href="http://sqoop.apache.org/" rel="nofollow">Sqoop</a> or other customized data load applications leveraging Hadoop Distributed File System API. But if you will have new data coming into MySQL time to time, then you need to schedule a job to run periodically to do delta load from MySQL to Hadoop. </p> <p>On the other hand, the workload to build a Hadoop cluster and find or build suitable data loading tool from MySQL to Hadoop might be a huge workload. Also you need to find a suitable extra layer for runtime data access and build code around that, no mater Impala or other things. To solve your own problem, it's probably better to build your own customized solution, like using in memory cache for hot records with the meta data in your database, along with some index mechanism to quickly locate the data you need for suggested search query calculation. If the memory on one machine cannot hold enough records, a memory cache grid or cluster component comes in handy like <a href="http://memcached.org/" rel="nofollow">Memcached</a> or Reddis, <a href="http://ehcache.org/" rel="nofollow">EhCache</a>, etc. </p>
40,665,526
0
<p>Not easily, the default size of a JLabel, JTextArea etc. is delegated to the "look and feel", this determines the size using the font metrics of the font, the size and the text. </p> <p>Thefore bigger font, bigger buttons.</p> <p>I'd advise you to just accept this, and use a layout manager that deals with the nicely... </p> <p>i.e. don't assume precise layout, instead use something grid-based with enough free-space so that font size can vary.</p> <p>If you're still desperate to do this you could override the preferred size of the controls with the following, although this pre-supposes you're using a layout manager that respects these hints.</p> <pre><code>public static void main(String [] args) { JFrame frame = new JFrame(); JTextField small = new JTextField("small"); JTextField big = new JTextField("big"); big.setFont(big.getFont().deriveFont(Font.BOLD, 40)); big.setPreferredSize(new Dimension(123, 20)); big.setMaximumSize(new Dimension(123, 20)); frame.setLayout(new FlowLayout()); frame.add(small); frame.add(big); frame.setVisible(true); } </code></pre>
151,059
0
<p>you're telling the system that whatever work would have been done in the finalizer has already been done, so the finalizer doesn't need to be called. From the .NET docs:</p> <blockquote> <p>Objects that implement the IDisposable interface can call this method from the IDisposable.Dispose method to prevent the garbage collector from calling Object.Finalize on an object that does not require it.</p> </blockquote> <p>In general, most any Dispose() method should be able to call GC.SupressFinalize(), because it should clean up everything that would be cleand up in the finalizer.</p> <p>SupressFinalize is just something that provides an optimization that allows the system to not bother queing the object to the finalizer thread. A properly written Dispose()/finalizer should work properly with or without a call to GC.SupressFinalize().</p>
15,594,360
0
<p>On a quick glance, I see a couple of instances of:</p> <pre><code>IF NEW.id_club = NULL ... </code></pre> <p>There may be more problems, I stopped looking there.<br> Nothing is <strong><em>ever</em></strong> the same as <code>NULL</code>. Use instead:</p> <pre><code>IF NEW.id_club <b>IS</b> NULL ...</code></pre> <p>Make sure you understand the nature of a <code>NULL</code> value, before you go on writing complex triggers. Basics first. <a href="http://www.postgresql.org/docs/current/interactive/functions-comparison.html" rel="nofollow">Start in the manual here</a>.</p>
38,121,725
0
bootstrap accordion content very long <p>I have bootatrsp accordion in my site. in one accordion panel I have a lot of content. when I scroll down to read the rest of the content and then click the next panel, then the one above(wich is open) closes and move up. the rest of the panels move up with it and now I can't see the relevat content because it scrolled up. how can I make the open panel of the accordion to always be in viewport of the screen no metter which panel i clicked.</p> <p>here is the code i used:</p> <pre><code> &lt;div class="row divAccordion" id="referNav"&gt; &lt;div id="accordion" role="tablist" aria-multiselectable="true"&gt; &lt;div class="panel panel-default visible-True"&gt; https://box.2beweb.chttps://jsfiddle.net/tartash/y5nc0u4w/3/# &lt;a name="collapseOne"&gt;&lt;/a&gt; &lt;div class="panel-heading" role="tab" id="headingOne"&gt; &lt;h4 class="panel-title"&gt; &lt;a id="referLink1" class="openPanel" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"&gt;&lt;i class="fa fa-plus-circle fa-minus-circle"&gt;&lt;/i&gt; Lorem Ipsum &lt;/a&gt; &lt;/h4&gt; &lt;/div&gt; &lt;div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne"&gt; &lt;div&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ut orci magna. Pellentesque sagittis nibh in venenatis dapibus. Duis vitae accumsan enim, nec viverra mauris. Curabitur posuere, odio id sagittis consectetur, quam sapien cursus eros, a consequat enim lacus a dolor. Sed urna augue, ullamcorper sed urna id, hendrerit tristique mi. Mauris id lorem a nisi viverra venenatis et ac ligula. Aenean varius neque sed lectus elementum, in fermentum metus commodo. Fusce congue erat et elit fringilla, at feugiat dolor luctus. Nulla facilisi. &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-------------------------------------------------------------------&gt; &lt;div class="panel panel-default visible-True"&gt; &lt;a name="collapseTwo"&gt;&lt;/a&gt; &lt;div class="panel-heading" role="tab" id="headingTwo"&gt; &lt;h4 class="panel-title"&gt; &lt;a id="referLink2" class="collapsed openPanel" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"&gt;&lt;i class="fa fa-plus-circle"&gt;&lt;/i&gt; Duis &lt;/a&gt; &lt;/h4&gt; &lt;/div&gt; &lt;div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo"&gt; Duis tempor molestie maximus. Phasellus aliquet hendrerit ante quis condimentum. Vestibulum scelerisque, nibh in ornare tincidunt, arcu mauris rhoncus lectus, vel blandit leo diam eget dui. Nunc sed porta libero, ac interdum urna. &lt;/div&gt; &lt;/div&gt; &lt;!-------------------------------------------------------------------&gt; &lt;div class="panel panel-default visible-False"&gt; &lt;a name="collapseThree"&gt;&lt;/a&gt; &lt;div class="panel-heading" role="tab" id="headingThree"&gt; &lt;h4 class="panel-title"&gt; &lt;a id="referLink3" class="collapsed openPanel" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"&gt;&lt;i class="fa fa-plus-circle"&gt;&lt;/i&gt; Aliquam &lt;/a&gt; &lt;/h4&gt; &lt;/div&gt; &lt;div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree"&gt; Aliquam at lorem id nibh blandit feugiat. Curabitur fermentum, ligula a aliquet malesuada, augue ligula feugiat odio, quis lobortis nisl tortor a nisl. Etiam vitae lacus sit amet odio placerat faucibus. Suspendisse orci diam, mollis eget interdum quis, tincidunt non lorem. Quisque imperdiet, tellus et iaculis lobortis, massa tortor ullamcorper neque, posuere sollicitudin massa risus commodo tellus. Phasellus a tristique nibh. Sed aliquet quam velit. Sed lorem mi, sodales vitae varius quis, pretium vitae enim. Donec eu congue eros. Praesent quis felis neque. Sed volutpat volutpat sodales. Cras nulla orci, fermentum et urna nec, tincidunt suscipit arcu. Maecenas imperdiet ornare commodo. Praesent luctus tellus vel blandit pretium. Donec in dolor ut lectus vehicula efficitur vel nec leo. Proin sit amet fermentum elit. &lt;/div&gt; &lt;/div&gt; &lt;!-------------------------------------------------------------------&gt; &lt;div class="panel panel-default visible-False"&gt; &lt;a name="collapseFour"&gt;&lt;/a&gt; &lt;div class="panel-heading" role="tab" id="headingFour"&gt; &lt;h4 class="panel-title"&gt; &lt;a id="referLink4" class="collapsed openPanel" data-toggle="collapse" data-parent="#accordion" href="#collapseFour" aria-expanded="false" aria-controls="collapseFour"&gt;&lt;i class="fa fa-plus-circle"&gt;&lt;/i&gt; Lorem ipsum dolor &lt;/a&gt; &lt;/h4&gt; &lt;/div&gt; &lt;div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour"&gt; Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ut orci magna. Pellentesque sagittis nibh in venenatis dapibus. Duis vitae accumsan enim, nec viverra mauris. Curabitur posuere, odio id sagittis consectetur, quam sapien cursus eros, a consequat enim lacus a dolor. Sed urna augue, ullamcorper sed urna id, hendrerit tristique mi. Mauris id lorem a nisi viverra venenatis et ac ligula. Aenean varius neque sed lectus elementum, in fermentum metus commodo. Fusce congue erat et elit fringilla, at feugiat dolor luctus. Nulla facilisi. Duis tempor molestie maximus. Phasellus aliquet hendrerit ante quis condimentum. Vestibulum scelerisque, nibh in ornare tincidunt, arcu mauris rhoncus lectus, vel blandit leo diam eget dui. Nunc sed porta libero, ac interdum urna. Fusce quis libero eu neque congue gravida et vitae mi. Mauris egestas ex eu neque consequat suscipit. In mattis diam non metus luctus rhoncus. Donec elementum consectetur ipsum, vel fringilla leo ullamcorper sit amet. Sed vestibulum pretium rutrum. Pellentesque hendrerit ipsum magna, aliquam vestibulum justo varius in. Proin iaculis velit felis, at posuere nunc mattis quis. Mauris mattis lectus in tempus volutpat. Curabitur sed nibh vel tellus aliquet faucibus. Maecenas sit amet enim ullamcorper, fringilla odio vitae, elementum metus. Quisque at justo vitae lectus porttitor pretium. Aliquam at lorem id nibh blandit feugiat. Curabitur fermentum, ligula a aliquet malesuada, augue ligula feugiat odio, quis lobortis nisl tortor a nisl. Etiam vitae lacus sit amet odio placerat faucibus. Suspendisse orci diam, mollis eget interdum quis, tincidunt non lorem. Quisque imperdiet, tellus et iaculis lobortis, massa tortor ullamcorper neque, posuere sollicitudin massa risus commodo tellus. Phasellus a tristique nibh. Sed aliquet quam velit. Sed lorem mi, sodales vitae varius quis, pretium vitae enim. Donec eu congue eros. Praesent quis felis neque. Sed volutpat volutpat sodales. Cras nulla orci, fermentum et urna nec, tincidunt suscipit arcu. Maecenas imperdiet ornare commodo. Praesent luctus tellus vel blandit pretium. Donec in dolor ut lectus vehicula efficitur vel nec leo. Proin sit amet fermentum elit. Integer luctus dapibus sagittis. Vestibulum eget lectus id felis suscipit hendrerit ullamcorper vel nisl. Duis facilisis ligula eget ultrices fringilla. Etiam volutpat luctus nulla quis dictum. Sed consequat lorem id magna efficitur rhoncus. Donec massa sem, mattis in massa non, fringilla ultricies nisi. Proin aliquet rutrum lectus id tempus. Donec justo lorem, blandit ac hendrerit vitae, dictum in ligula. Sed ut mollis sem, eu consequat turpis. Aliquam ultrices risus vel nulla finibus, quis cursus tellus suscipit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce non est lacus. Sed sed ultricies neque. Morbi nunc dui, varius bibendum erat non, semper tincidunt nulla. Etiam viverra feugiat arcu nec tempor. Quisque tempor vitae arcu non euismod. Nullam eu sem id quam pharetra blandit quis ut massa. Quisque molestie scelerisque lacus in ultricies. Nam venenatis scelerisque nunc, sed pellentesque tortor ultrices vel. Curabitur ac finibus lacus. Morbi bibendum urna interdum, ullamcorper sapien vitae, molestie orci. Vestibulum viverra mollis purus, sed mattis metus convallis sed. Quisque ipsum nisi, tincidunt pretium commodo et, vestibulum a tortor. Donec imperdiet diam non nulla dictum malesuada. Maecenas pellentesque dolor vel erat hendrerit pellentesque. Nulla in eros et nunc varius dapibus. Aliquam pharetra ornare facilisis. Phasellus pharetra mauris vel felis porttitor efficitur eget nec sem. Etiam vel fringilla turpis. Suspendisse potenti. Ut fringilla feugiat lacinia. Etiam mattis mauris velit, et dictum ex scelerisque et. &lt;/div&gt; &lt;/div&gt; &lt;!-------------------------------------------------------------------&gt; &lt;div class="panel panel-default visible-False"&gt; &lt;a name="collapseFive"&gt;&lt;/a&gt; &lt;div class="panel-heading" role="tab" id="headingFive"&gt; &lt;h4 class="panel-title"&gt; &lt;a id="referLink5" class="collapsed openPanel" data-toggle="collapse" data-parent="#accordion" href="#collapseFive" aria-expanded="false" aria-controls="collapseFive"&gt;&lt;i class="fa fa-plus-circle"&gt;&lt;/i&gt; Nullam eu sem &lt;/a&gt; &lt;/h4&gt; &lt;/div&gt; &lt;div id="collapseFive" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFive"&gt; Nullam eu sem id quam pharetra blandit quis ut massa. Quisque molestie scelerisque lacus in ultricies. Nam venenatis scelerisque nunc, sed pellentesque tortor ultrices vel. Curabitur ac finibus lacus. Morbi bibendum urna interdum, ullamcorper sapien vitae, molestie orci. Vestibulum viverra mollis purus, sed mattis metus convallis sed. Quisque ipsum nisi, tincidunt pretium commodo et, vestibulum a tortor. Donec imperdiet diam non nulla dictum malesuada. Maecenas pellentesque dolor vel erat hendrerit pellentesque. Nulla in eros et nunc varius dapibus. Aliquam pharetra ornare facilisis. Phasellus pharetra mauris vel felis porttitor efficitur eget nec sem. Etiam vel fringilla turpis. Suspendisse potenti. Ut fringilla feugiat lacinia. Etiam mattis mauris velit, et dictum ex scelerisque et. &lt;/div&gt; &lt;/div&gt; &lt;!-------------------------------------------------------------------&gt; &lt;div class="panel panel-default visible-True"&gt; &lt;a name="collapseSix"&gt;&lt;/a&gt; &lt;div class="panel-heading" role="tab" id="headingSix"&gt; &lt;h4 class="panel-title"&gt; &lt;a id="referLink6" class="collapsed openPanel" data-toggle="collapse" data-parent="#accordion" href="#collapseSix" aria-expanded="false" aria-controls="collapseSix"&gt;&lt;i class="fa fa-plus-circle"&gt;&lt;/i&gt; Integer luctus &lt;/a&gt; &lt;/h4&gt; &lt;/div&gt; &lt;div id="collapseSix" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingSix"&gt; Integer luctus dapibus sagittis. Vestibulum eget lectus id felis suscipit hendrerit ullamcorper vel nisl. Duis facilisis ligula eget ultrices fringilla. Etiam volutpat luctus nulla quis dictum. Sed consequat lorem id magna efficitur rhoncus. Donec massa sem, mattis in massa non, fringilla ultricies nisi. Proin aliquet rutrum lectus id tempus. Donec justo lorem, blandit ac hendrerit vitae, dictum in ligula. Sed ut mollis sem, eu consequat turpis. Aliquam ultrices risus vel nulla finibus, quis cursus tellus suscipit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce non est lacus. Sed sed ultricies neque. Morbi nunc dui, varius bibendum erat non, semper tincidunt nulla. Etiam viverra feugiat arcu nec tempor. Quisque tempor vitae arcu non euismod. &lt;/div&gt; &lt;/div&gt; &lt;!-------------------------------------------------------------------&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>thank you in advance </p>
29,892,790
0
<p>This is happening because in HTML you have multiple textareas with same <code>id</code> attribute that is <code>txtcomment</code>. You should try giving each textarea, comments anchor tag a unique id.</p> <p>use <code>id="txtComment.'.$row["id"].'"</code> and <code>id="leavecomment.'.$row["id"].'"</code></p> <blockquote> <p>NOTE: when an HTML page have multiple DOM element with same <code>id</code>, it will traverse through the last one and return the last occurrence of element.</p> </blockquote>
13,275,812
0
How to get, set and select elements with data attributes? <p>I'm having some trouble with data-attributes, I can't get anything to work for some reason so I must be doing something wrong:</p> <p>Set:</p> <pre><code>$('#element').data('data1', '1'); //Actually in my case the data is been added manually </code></pre> <p>Does that make a difference?</p> <p>Get:</p> <pre><code>$('#element').data('data1'); </code></pre> <p>Select:</p> <pre><code>$('#element[data1 = 1]') </code></pre> <p>None of this works for me, am I making this up or how is it?</p>
7,015,264
0
I have an encrypted value, why wont it go into the varbinary field? <p>I just need to fix a couple of bad records. I am able to swap the month with the year and re-encrypt. But when I try and put it into the MS SQL SERVER varbinary field again it is getting truncated. What is the correct way to update the table with the new encrypted values?</p> <pre><code>Conn.Open strDSN Dim sql : sql = "Select * FROM tmpRefill WHERE CC &lt;&gt; 'NULL' AND CustId = 9944" rs.Open sql, Conn Dim custId, email, cc, newCC, upSQL Do Until rs.EOF Response.Write rs("CustId") Response.Write("&lt;br /&gt;") Response.Write rs("email") Response.Write("&lt;br /&gt;") cc = EnCrypt(rs("CC")) Response.Write cc Response.Write("&lt;br /&gt;") cc = Split(cc,"-") newCC = cc(0) &amp; "-" &amp; cc(2) &amp; "-" &amp; cc(1) &amp; "-" &amp; cc(3) Response.Write newCC Response.Write("&lt;br /&gt;") newCC = EnCrypt(newCC) Response.Write newCC Response.Write("&lt;br /&gt;") Response.Write("&lt;br /&gt;&lt;br /&gt;") rs.MoveNext Loop upSQL = "UPDATE tmpRefill SET CC = CONVERT(VARBINARY(500), '" &amp; newCC &amp; "') WHERE CustId = 9944" Conn.Execute (upSQL) </code></pre> <p>The datatype on the table column is varbinary(500) so I dont understand why I have to convert it to insert it.</p>
8,740,204
0
<p>Try <a href="http://jasarien.com/?p=428" rel="nofollow">SBJSON</a> to parse the JSON in objective-C.</p> <p>You can get the SBJSON from <a href="https://github.com/stig/json-framework" rel="nofollow">here</a></p>
37,165,143
0
<p>Try processing the json data form the url using JsonSlulrper as follows:</p> <pre><code>def resp = new JsonSlurper().parseText(url.text) </code></pre> <p>Also in your HTML views/layouts, make sure you apply encoding:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; ........ </code></pre>
23,367,655
0
Parse all HTML code <p>I need to copy all HTML code on the page.</p> <p>I do so:</p> <pre><code>URL url = new URL(testurl); URLConnection connection = url.openConnection(); connection.connect(); Scanner in = new Scanner(connection.getInputStream()); while(in.hasNextLine()) { htmlText=htmlText+in.nextLine(); } in.close(); </code></pre> <p>But if the page is large, it takes a lot of time.</p> <p>Is there a faster method?</p>
32,389,637
0
<p>Interface methods cannot have implementation before Java 8. Starting in Java 8 this is possible, but only with <a href="https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html" rel="nofollow">default methods</a> and static methods.</p> <blockquote> <p>In addition to default methods, you can define static methods in interfaces. (A static method is a method that is associated with the class in which it is defined rather than with any object. Every instance of the class shares its static methods.) </p> </blockquote> <p>You are probably looking for an <a href="https://docs.oracle.com/javase/tutorial/java/IandI/abstract.html" rel="nofollow">abstract class</a> which lets you have both <code>abstract</code> methods (methods that must be implemented by non-abstract subclasses) and normal methods that can be given implementation in the <code>abstract</code> class itself (subclasses have the option to override them of course).</p> <p>But I'm not sure if you want to use an abstract class or interface. Going by the class names, <code>Faculty</code> would have <code>Person</code>s, but I don't see why one should extend/implement the other. They seem to be different things. You might want to reconsider your design and also read this: <a href="http://stackoverflow.com/questions/2586389/when-best-to-use-an-interface-in-java">When best to use an interface in java</a></p>
2,457,248
0
<p>After rereading my original post I see it looks confusing as hell... what I ended up doing was; creating a second method getUserRecords that got a 'flag', I call getUserRecords from my first, getUser method and return a new object type with the flag included in the new object.</p>
27,028,708
0
<p>You can do this using scripting variable and using the <code>-v</code> option of <code>SQLCMD</code> utility. A small example from <a href="http://msdn.microsoft.com/en-us/library/ms188714.aspx" rel="nofollow"> MSDN Documentation</a></p> <p>Consider that the script file name is <code>testscript.sql</code>, <code>Col1</code> is a scripting variable; your SQL script look like</p> <pre><code>USE test; SELECT x.$(Col1) FROM Student x WHERE marks &lt; 5; </code></pre> <p>You can then specify the name of the column that you want returned by using the <code>-v</code> option like</p> <pre><code>sqlcmd -v Col1 = "FirstName" -i c:\testscript.sql </code></pre> <p>Which will resemble to below query</p> <pre><code>SELECT x.FirstName FROM Student x WHERE marks &lt; 5; </code></pre> <p><strong>EDIT:</strong></p> <p>If you just want to capture the output from your script file then you can use <code>-o</code> parameter and specify a outfile like</p> <pre><code>sqlcmd -v Col1 = "FirstName" -i c:\testscript.sql -o output.txt </code></pre>
27,918,243
0
<p><code>List</code> implements <code>Iterable</code> and therefore is an <code>Iterable</code> (see <a href="https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:core.List" rel="nofollow">https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:core.List</a> just below the title)</p>
26,546,604
0
Winform viewing <p>Since I add an extra screen to my developpment laptop and set an extended desktop, the view of the forms change by the way it show in the picture below two form with same code in windows 8 <img src="https://i.stack.imgur.com/ipfl2.png" alt="Two winforms with same in windows 8"></p>
1,336,851
0
<p>From python <a href="http://docs.python.org/library/string.html" rel="nofollow noreferrer">docs</a>:</p> <blockquote> <p>Advanced usage: you can derive subclasses of Template to customize the placeholder syntax, delimiter character, or the entire regular expression used to parse template strings. To do this, you can override these class attributes:</p> <ul> <li><p>delimiter – This is the literal string describing a placeholder introducing delimiter. The default value $. Note that this should not be a regular expression, as the implementation will call re.escape() on this string as needed.</p></li> <li><p>idpattern – This is the regular expression describing the pattern for non-braced placeholders (the braces will be added automatically as appropriate). The default value is the regular expression [_a-z][_a-z0-9]*.</p></li> </ul> </blockquote> <p>Example:</p> <pre><code>from string import Template class MyTemplate(Template): delimiter = '#' idpattern = r'[a-z][_a-z0-9]*' &gt;&gt;&gt; s = MyTemplate('#who likes $what') &gt;&gt;&gt; s.substitute(who='tim', what='kung pao') 'tim likes $what' </code></pre> <hr> <p>In python 3:</p> <blockquote> <p><em>New in version 3.2.</em></p> <p>Alternatively, you can provide the entire regular expression pattern by overriding the class attribute pattern. If you do this, the value must be a regular expression object with four named capturing groups. The capturing groups correspond to the rules given above, along with the invalid placeholder rule:</p> <ul> <li>escaped – This group matches the escape sequence, e.g. $$, in the default pattern.</li> <li>named – This group matches the unbraced placeholder name; it should not include the delimiter in capturing group.</li> <li>braced – This group matches the brace enclosed placeholder name; it should not include either the delimiter or braces in the capturing group.</li> <li>invalid – This group matches any other delimiter pattern (usually a single delimiter), and it should appear last in the regular expression.</li> </ul> </blockquote> <p>Example:</p> <pre><code>from string import Template import re class TemplateClone(Template): delimiter = '$' pattern = r''' \$(?: (?P&lt;escaped&gt;\$) | # Escape sequence of two delimiters (?P&lt;named&gt;[_a-z][_a-z0-9]*) | # delimiter and a Python identifier {(?P&lt;braced&gt;[_a-z][_a-z0-9]*)} | # delimiter and a braced identifier (?P&lt;invalid&gt;) # Other ill-formed delimiter exprs ) ''' class TemplateAlternative(Template): delimiter = '[-' pattern = r''' \[-(?: (?P&lt;escaped&gt;-) | # Expression [-- will become [- (?P&lt;named&gt;[^\[\]\n-]+)-\] | # -, [, ], and \n can't be used in names \b\B(?P&lt;braced&gt;) | # Braced names disabled (?P&lt;invalid&gt;) # ) ''' &gt;&gt;&gt; t = TemplateClone("$hi sir") &gt;&gt;&gt; t.substitute({"hi": "hello"}) 'hello sir' &gt;&gt;&gt; ta = TemplateAlternative("[-hi-] sir") &gt;&gt;&gt; ta.substitute({"hi": "have a nice day"}) 'have a nice day sir' &gt;&gt;&gt; ta = TemplateAlternative("[--[-hi-]-]") &gt;&gt;&gt; ta.substitute({"hi": "have a nice day"}) '[-have a nice day-]' </code></pre> <p>Apparently it is also possible to just omit any of the regex groups <code>escaped</code>, <code>named</code>, <code>braced</code> or <code>invalid</code> to disable it.</p>
24,577,065
0
<p>Here You have two options. Either do this by subselects or once per save/update walk through all the information descriptions and update the missing languages with the texts from the default ones.</p> <p>The first solution could be:</p> <pre><code>SELECT id.information_id, id.language_id, id.description, CASE WHEN id.title IS NOT NULL /* or CASE WHEN id.title &lt;&gt; '' - depending on the real value in DB when it's empty */ THEN id.title ELSE (SELECT title FROM information_description WHERE language_id = 1) AS title FROM information_description id WHERE id.language_id = 2 </code></pre> <p>I would call such query only in the case when the language ID differs from the default one. Since this may look like working solution I don't like it simply because it increases the DB effort.</p> <p>Instead of this I recommend to simply update Your missing data in similar way (this could be done maybe only once per life and you are done):</p> <pre><code>UPDATE information_description id SET id.title = (SELECT title FROM information_description WHERE language_id = 1 AND information_id = id.information_id) WHERE id.language_id &lt;&gt; 1 AND id.title IS NULL </code></pre> <p>for title and</p> <pre><code>UPDATE information_description id SET id.description = (SELECT description FROM information_description WHERE language_id = 1 AND information_id = id.information_id) WHERE id.language_id &lt;&gt; 1 AND id.description IS NULL </code></pre> <p>for description fields...</p>
32,920,293
0
The code is giving Multiple Marker at this line <p>This line giving errors I am not able to find any clue kindly help me..?? I have added all the related jar files then also its giving error please check code and help</p> <pre><code>Properties properties = System.getProperties(); properties.setProperty("mail.smtp.host", host); </code></pre>
4,562,075
0
<p>unsigned = a none positive / negative number, so you couldnt have -1 as the "-" is a sign.</p> <p>zerofill = fill it with zeros by default. Not necessary as the column's already got the auto_increment / pk attributes</p> <p>key = index this column i.e. make SELECTS that search on this column faster.</p> <p>Ta </p>
24,728,787
0
<p>I posted a fix for this <a href="http://stackoverflow.com/a/24728537/2016196">here</a></p> <p>You can use this function to modify <code>JSON.stringify</code> to encode <code>arrays</code>, just post it near the beginning of your script (check the link above for more detail):</p> <pre><code>// Upgrade for JSON.stringify, updated to allow arrays (function(){ // Convert array to object var convArrToObj = function(array){ var thisEleObj = new Object(); if(typeof array == "object"){ for(var i in array){ var thisEle = convArrToObj(array[i]); thisEleObj[i] = thisEle; } }else { thisEleObj = array; } return thisEleObj; }; var oldJSONStringify = JSON.stringify; JSON.stringify = function(input){ if(oldJSONStringify(input) == '[]') return oldJSONStringify(convArrToObj(input)); else return oldJSONStringify(input); }; })(); </code></pre>
34,248,084
0
<p>I think this tutorial will help you a lot to access Windows IoT device via PowerShell:<br/> <a href="https://www.hackster.io/AnuragVasanwala/windows-10-iot-core-setting-startup-app-887ed0" rel="nofollow">https://www.hackster.io/AnuragVasanwala/windows-10-iot-core-setting-startup-app-887ed0</a></p> <p>This article reveals how to set specific Universal App as startup app but also covers the basic aspects of PowerShell, how to connect to it and some known issue(s).</p>
24,192,384
0
<p>Instead of having multiple divs within the gray div, and checking whether a certain one is clicked or not, and then removing the clicked class, you could just use jQuery's <code>.html()</code> or <code>.text()</code> to set up the corresponding text within your gray div. Read about them more here: </p> <p><a href="http://api.jquery.com/html/" rel="nofollow">http://api.jquery.com/html/</a></p> <p><a href="http://api.jquery.com/text/" rel="nofollow">http://api.jquery.com/text/</a></p>
25,186,839
0
<p>Well you cannot actually get session time with an AJAX request as the request it self will also reset the session timeout time. What you can do is get it when you are rendering the page in a js function and start a counter with <code>setTimeout</code> when and show your message pop when less then 30 seconds left.</p>
38,405,091
0
Straighten and concatenate the individual grids from ndgrid <p>I'm trying to do the following in a general way:</p> <pre><code>x = {0:1, 2:3, 4:6}; [a,b,c] = ndgrid(x{:}); Res = [a(:), b(:), c(:)] Res = 0 2 4 1 2 4 0 3 4 1 3 4 0 2 5 1 2 5 0 3 5 1 3 5 0 2 6 1 2 6 0 3 6 1 3 6 </code></pre> <p>I believe I have to start the following way, but I can't figure out how to continue:</p> <pre><code>cell_grid = cell(1,numel(x)); [cell_grid{:}] = ndgrid(x{:}); [cell_grid{:}] ans = ans(:,:,1) = 0 0 2 3 4 4 1 1 2 3 4 4 ans(:,:,2) = 0 0 2 3 5 5 1 1 2 3 5 5 ans(:,:,3) = 0 0 2 3 6 6 1 1 2 3 6 6 </code></pre> <p>I can solve this in many ways for the case with three variables <code>[a, b, c]</code>, both with and without loops, but I start to struggle when I get more vectors. Reshaping it directly will not give the correct result, and mixing reshape with permute becomes really hard when I have arbitrary number of dimensions.</p> <p>Can you think of a clever way to do this that scales to 3-30 vectors in <code>x</code>?</p>
29,208,748
0
Some questions with the source of the libuv? <p>Recently,I read the source of libuv. There are some questions when read the QUEUE.h</p> <p><strong>Firstly:</strong> The macro define below:</p> <pre><code>typedef void *QUEUE[2]; #define QUEUE_NEXT(q) (*(QUEUE **) &amp;((*(q))[0])) #define QUEUE_PREV(q) (*(QUEUE **) &amp;((*(q))[1])) </code></pre> <p>Can I redefine the QUEUE_PREV(q) as:</p> <pre><code>#define QUEUE_PREVR(q) ((QUEUE *) &amp;((*(q))[1])) </code></pre> <p><strong>what is the diffrence between them?</strong></p> <p><strong>Secondly:</strong> I try the code below:</p> <pre><code>typedef struct{ int i1; int i5 ; int i6; }s1; typedef struct { int j1; int j2; int j3; }s2; s1 i = { 1, 2 ,61}; s2 j = { 97, 99, 90 }; QUEUE a; a[0] = &amp;i; a[1] = &amp;j; cout &lt;&lt; (QUEUE*)(&amp;((*(&amp;a))[1])) &lt;&lt; endl; cout &lt;&lt; *(QUEUE*)(&amp;((*(&amp;a))[1])) &lt;&lt; endl; </code></pre> <p><strong>The result is same on the console,But why? Don't the "*" works?? I write this code with VS2013.</strong></p>
16,964,975
0
How to choose the right kernel functions <p>I have a very general question: how do I choose the right kernel function for SVM? I know the ultimate answer is try all the kernels, do out-of-sample validation, and pick the one with best classification result. But other than that, is there any guideline of trying the different kernel functions? </p>
7,228,982
0
<p>If you are using OS X hardware with an NVIDIA GPU, both <a href="http://www.culatools.com/" rel="nofollow">CULA</a> and <a href="http://www.accelereyes.com/" rel="nofollow">Jacket</a> includes SVD routines, and both are available for OS X (as far as I know). But I am not aware of anything similar for OpenCL.</p>
4,415,024
0
<p>This is an old question but you never really got an answer about run vs poll. </p> <p>io_service::run will keep running as long as there is something to do, such as waiting on a deadline timer or IO completion notification, etc. This is why there is the work object to keep run from exiting. </p> <p>io_service::poll will only execute ready handlers, and will not return until there are no more handlers ready to be dispatched. </p> <p>The difference in other words is that run will wait for a pending handler to be ready, like a timer or IO completion notification, while poll will return in that situation. </p> <p>This behavior is useful if you want to perform some idle processing. </p>
14,858,239
0
<p>The error above occurs when you return certain objects (XML, Socket) from a function call, but the return values does not get assigned anywhere.</p> <pre><code>function test() { var xml = new XML('&lt;test /&gt;'); return xml; } test(); </code></pre> <p>The above will cause an error. To get around it you have to assign the return value somewhere.</p> <pre><code>var result = test(); </code></pre> <hr> <p>Try to put all collect all function calls result. I am not sure which one causes the error.</p> <pre><code>var reply = ""; var conn = new Socket; // access Adobe’s home page if (conn.open ("www.adobe.com:80")) { // send a HTTP GET request var result = conn.write ("GET /index.html HTTP/1.0\n\n"); // and read the server’s reply reply = conn.read(999999); var close = conn.close(); } </code></pre>
30,642,633
0
How to sort Arraylist consisting of pojo class in java <p>I have POJO class Student like this</p> <pre><code>class Student { private int score; private String FirstName; //Getters and setters ................. } </code></pre> <p>I am creating ArrayList like this</p> <pre><code>public static void main(String[] args) { List&lt;Student&gt; al_students= new ArrayList&lt;Student&gt;(); Student s1= new Student(); s1.setScore(90); s1.setFirstName("abc"); al_students.add(s1); Student s2= new Student(); s2.setScore(95); s2.setFirstName("def"); al_students.add(s2); Student s3= new Student(); s3.setScore(85); s3.setFirstName("xyz"); al_students.add(s3); } </code></pre> <p>Now I want to sort it based on scores in descending order i.e<br> output</p> <pre><code>1)def 95 2)abc 90 3)xyz 85 </code></pre>
589,655
0
<p>It says in the <a href="http://www.boost.org/users/faq.html" rel="nofollow noreferrer">Boost Faq</a>:</p> <blockquote> <p>What do the Boost version numbers mean? The scheme is x.y.z, where x is incremented only for massive changes, such as a reorganization of many libraries, y is incremented whenever a new library is added, and z is incremented for maintenance releases. y and z are reset to 0 if the value to the left changes.</p> </blockquote>
27,452,005
0
<p>One possibility is that your <code>Stripe.rb</code> edits have not been loaded.</p> <ol> <li><p>Quit your server with <code>ctrl + c</code></p></li> <li><p><code>$ spring stop</code><br> => Spring stopped</p></li> <li><p><code>$ rails server</code></p></li> </ol>
35,309,518
0
<p>This is not a perfect solution, but at least gets you going. Probably this is caused by some bug in compass which leads to invalid <code>sass_path</code>. So set the <code>sass_path</code> manually like this: </p> <pre><code>project_type = :stand_alone # Set this to the root of your project when deployed: project_path = "../../" http_path = "www" # The path to the project when running within the web server. css_dir = "www/css" # relative to project_path sass_dir = "www/sass" # relative to project_path sass_path = File.expand_path(File.join(project_path, sass_dir)) images_dir = "www/images" # relative to project_path javascripts_dir = "www/js" # relative to project_path # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed output_style = :compressed # To enable relative paths to assets via compass helper functions. Uncomment: relative_assets = true # generate sourcemaps sourcemap = true </code></pre> <p>And then you should be able to build individual sass files by using command <code>compass compile ../../www/sass/builder.scss</code></p>
1,689,242
0
Conditionally ignoring tests in JUnit 4 <p>OK, so the <code>@Ignore</code> annotation is good for marking that a test case shouldn't be run.</p> <p>However, sometimes I want to ignore a test based on runtime information. An example might be if I have a concurrency test that needs to be run on a machine with a certain number of cores. If this test were run on a uniprocessor machine, I don't think it would be correct to just pass the test (since it hasn't been run), and it certainly wouldn't be right to fail the test and break the build.</p> <p>So I want to be able to ignore tests at runtime, as this seems like the right outcome (since the test framework will allow the build to pass but record that the tests weren't run). I'm fairly sure that the annotation won't give me this flexibility, and suspect that I'll need to manually create the test suite for the class in question. However, the documentation doesn't mention anything about this and looking through the <a href="http://junit.org/apidocs/junit/framework/TestSuite.html" rel="nofollow noreferrer">API</a> it's also not clear how this would be done programmatically (i.e. how do I programatically create an instance of <code>Test</code> or similar that is equivalent to that created by the <code>@Ignore</code> annotation?).</p> <p>If anyone has done something similar in the past, or has a bright idea of how else I could go about this, I'd be happy to hear about it.</p>
34,965,429
0
Giving VersionPress write permissions via ssh on bitnami WP ami running on EC2 instance <p>Thanks in advance for your patience and support helping me with this issue. I can normally work around most problems by reading online, but when it comes to linux and ssh I cant - it's too complex. No two explanations seem the same.</p> <p>The problem is this:</p> <p>I launched an EC2 instance using the bitnami wordpress ami (i think its an ami?) and everything works great. </p> <p>Im super excited about this new wordpress project called VersionPress, link below. </p> <p>I managed to install git and get a tick in that box. Now I need to satisfy the plugin's requirements for write permission on several folders.</p> <p>I've been reading up on chmod, and checking out what permission are currently in place using ssh, but can not, for the life of me, make sense of it. </p> <p>The info on what VersonPress needs is here: <a href="http://docs.versionpress.net/en/getting-started/installation-uninstallation" rel="nofollow">http://docs.versionpress.net/en/getting-started/installation-uninstallation</a></p> <p>If we take for example the plugins own folder /versionpress, I can navigate to it and see the current permissions using ls:</p> <p>drwxr-xr-x 7 bitnami bitnami ... versionpress</p> <p>So I'm like ok, I suppose I'd better give group write permissions. But, no version of the chmod command I write will execute and even then, it's only one of the folders that I need to change. </p> <p>UPDATE: I added '~' and got chmod working on the /versionpress dir</p> <p>As a next step I tried to change rights on /wordpress dir. This was initially unsuccessful until I applied command with Sudo. </p> <p>VersionPress still reports it does not have the correct permissions however. </p> <p>Error msg: VersionPress needs write access in the site root, its nested directories and the system temp directory. Please update the permissions.</p> <p>END UPDATE</p> <p>Anyone experienced this, got VersionPres up and running on EC2 or with any advice to move me forward? </p> <p>Thanks.</p>
18,543,228
0
Statically linking a C library with a Haskell library <p>I have a Haskell project that aims to create some C++ bindings. I've written the C wrappers and compiled them into a stand-alone statically linked library. </p> <p>I'd like to write the Haskell bindings to link statically to the C wrappers so that I don't have to distribute the C wrappers separately but I can't seem to get it working and would appreciate some help.</p> <p>I specify the C library as an extra library but my <code>cabal build</code> step doesn't seem to add it to compile command.</p> <p>I've created a small project to illustrate this (<a href="http://github.com/deech/CPlusPlusBindings">http://github.com/deech/CPlusPlusBindings</a>).</p> <p>It contains a small C++ class (<a href="https://github.com/deech/CPlusPlusBindings/tree/master/cpp-src">https://github.com/deech/CPlusPlusBindings/tree/master/cpp-src</a>), the C wrapper (<a href="https://github.com/deech/CPlusPlusBindings/tree/master/c-src">https://github.com/deech/CPlusPlusBindings/tree/master/c-src</a>), a working C test routine (<a href="https://github.com/deech/CPlusPlusBindings/tree/master/c-test">https://github.com/deech/CPlusPlusBindings/tree/master/c-test</a>) and the Haskell file (<a href="https://github.com/deech/CPlusPlusBindings/blob/master/src/BindingTest.chs">https://github.com/deech/CPlusPlusBindings/blob/master/src/BindingTest.chs</a>).</p> <p>The C library is added in Setup.hs not in the Cabal file because that's how I have it my real project which builds the C library using "make" through Cabal just before the build stepf. I have verified that at the build step the <code>extraLibs</code> part of <code>BuildInfo</code> contains the library name and <code>extraLibDirs</code> contains the right directory. </p> <p>The output of my <code>cabal build</code> is:</p> <pre><code>creating dist/setup ./dist/setup/setup build --verbose=2 creating dist/build creating dist/build/autogen Building CPlusPlusBinding-0.1.0.0... Preprocessing library CPlusPlusBinding-0.1.0.0... Building library... creating dist/build /usr/local/bin/ghc --make -fbuilding-cabal-package -O -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -isrc -idist/build/autogen -Idist/build/autogen -Idist/build -I/home/deech/Old/Haskell/CPlusPlusBinding/c-src -I/home/deech/Old/Haskell/CPlusPlusBinding/cpp-includes -optP-include -optPdist/build/autogen/cabal_macros.h -package-name CPlusPlusBinding-0.1.0.0 -hide-all-packages -package-db dist/package.conf.inplace -package-id base-4.6.0.1-8aa5d403c45ea59dcd2c39f123e27d57 -XHaskell98 -XForeignFunctionInterface BindingTest Linking... /usr/bin/ar -r dist/build/libHSCPlusPlusBinding-0.1.0.0.a dist/build/BindingTest.o /usr/bin/ar: creating dist/build/libHSCPlusPlusBinding-0.1.0.0.a /usr/bin/ld -x --hash-size=31 --reduce-memory-overheads -r -o dist/build/HSCPlusPlusBinding-0.1.0.0.o dist/build/BindingTest.o In-place registering CPlusPlusBinding-0.1.0.0... /usr/local/bin/ghc-pkg update - --global --user --package-db=dist/package.conf.inplace </code></pre> <p>Unfortunately neither the compilation nor the linking step uses the C library. There are no other warnings or errors.</p>
36,125,312
0
<p>If you study the following simplified example you will understand why deleting elements of the array over which you are iterating caused the result you obtained.</p> <pre><code>s = "two lions" s = s.split("") puts "s.split=#{s}" for i in 0..s.length - 1 do puts "i=#{i}" str = s[i] puts " str=/#{str}/" if ["a","e","i","o","u"].include?(s[i]) puts " str is a vowel" s.delete_at(i) puts " s after delete_at(#{i})=#{s}" end end puts "s after loop=#{s}" puts "s.join=#{s.join}" s.join </code></pre> <p>prints</p> <pre><code>s.split=["t", "w", "o", " ", "l", "i", "o", "n", "s"] i=0 str=/t/ i=1 str=/w/ i=2 str=/o/ str is a vowel s after delete_at(2)=["t", "w", " ", "l", "i", "o", "n", "s"] </code></pre> <p>The space is skipped.</p> <pre><code>i=3 str=/l/ i=4 str=/i/ str is a vowel s after delete_at(4)=["t", "w", " ", "l", "o", "n", "s"] </code></pre> <p>"o" is now at index 4 and "n" is at index 5.</p> <pre><code>i=5 str=/n/ i=6 str=/s/ i=7 str=// i=8 str=// s after loop=["t", "w", " ", "l", "o", "n", "s"] s.join=tw lons </code></pre>
18,650,163
0
<p>index.php or index.html <em>should</em> be the default files loaded by your server when visiting a site, not home.html. Try clearing your cache. If that doesn't help it could be an issue in httpd.conf - but that sounds kind of extreme in this scenario.</p> <p>You can also look into using mod_rewrite in your .htaccess file so the redirect happens at the server level</p> <pre><code>Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / # redirect home.html to index.php RewriteRule ^home.html index.php [R=301,L] </code></pre>
9,957,399
0
<p>You can put condition on the rows that you want to fetch, the where clause is responsible for it. The columns that you want are to be specified in the select statement only, there is no way to specify which column to be selected. Once you have the results you can decide which columns to use, depending upon the value.</p>
6,363,825
0
TableViewer cell editor not working - SWT <p>I am trying to implement an editable table viewer in Eclipse SWT. I think I've done everything ok until now, problem is the table is not editable - nothing happens if I click on any row. </p> <p>I have registered some CellEditors with all my columns:</p> <pre><code>CellEditor[] editors = new CellEditor[columnNames.length]; editors[0] = new TextCellEditor(table); //do the above for all columns tableViewer.setCellEditors(editors); </code></pre> <p>and then I specify a cell modifier for my table:</p> <pre><code>tableViewer.setCellModifier(new CellModifier(this)); </code></pre> <p>The CellModifier class looks like this:</p> <pre><code>public class CellModifier implements ICellModifier{ private DBStructureView dbView; public CellModifier(DBStructureView view){ super(); this.dbView = view; } @Override public boolean canModify(Object element, String property) { return true; } @Override public Object getValue(Object element, String property) { int columnIndex = dbView.getColumnNames().indexOf(property); Object result = null; AttributeNode node = (AttributeNode) element; switch(columnIndex){ case 0://row id result = node.getRow(); case 1://name result = node.getName(); case 2://value result = node.getValue(); default: result = "unknown"; } System.out.println(result); return result; } @Override public void modify(Object element, String property, Object value) { int columnIndex = dbView.getColumnNames().indexOf(property); TableItem item = (TableItem) element; AttributeNode node = (AttributeNode)item.getData(); String valueString; switch(columnIndex){ case 0: valueString = ((String) value).trim(); node.setRow(valueString); break; case 1: valueString = ((String) value).trim(); node.setName(valueString); break; case 2: valueString = ((String) value).trim(); node.setValue(valueString); break; default: break; } } } </code></pre> <p>Having done all this, what can go wrong?</p> <p>Thanks in advance!</p>
27,820,681
0
illegal text-relocoation (direct reference) to (global,weak) for architecture i386 <p>Searching about shows this error in a number of mailing lists, but neither a general solution nor explanation is forthcoming.</p> <p>What does <code>illegal text-relocoation (direct reference) to (global,weak)</code> mean and how can it be resolved.</p> <p>Specifically, I have built ffmpeg-2.5.2 using <a href="https://github.com/kewlbear/FFmpeg-iOS-build-script" rel="nofollow">this script</a>. When building XCode tests that use it, there is the following error:</p> <pre><code>ld: illegal text-relocoation (direct reference) to (global,weak) _ff_h264_cabac_tables in &lt;...&gt;/myLib.a(cabac.o) from _ff_h264_decode_mb_cabac in &lt;...&gt;/myLib.a(h264_cabac.o) for architecture i386 </code></pre> <p>Does this require compiler/linker options to fix, or some kind of code change?</p>
9,701,198
0
<p>The betterway to Achieve this effect is to measure speed/over/distance this formula will be easier and a lot less code.Doing it this way you wouldnt need any tween library's.</p> <pre><code> var MaskCenter=100; var speed=1/10; var distance=boxdummy.mouseX-MaskCenter; if(mouseX&lt;250){ box.x-=(distance*speed); } if (mouseX&gt;250) { box.x -= speed + accel; } </code></pre> <p>Something like that! </p> <p>If you cant work it, let me know i will make up a (fla) file for you</p>
10,739,574
0
<p>Have you considered a <a href="http://www.smashingmagazine.com/2008/05/06/25-wysiwyg-editors-reviewed/" rel="nofollow">WYSIWYG editor</a>? For example the editor in which you typed your question in this site is <a href="http://code.google.com/p/wmd/" rel="nofollow">WMD</a> and it allows to bold the text.</p>
32,065,980
0
Is there an alternate syntax to typedef function pointers? <p>For doing a typedef for a function pointer, we do something like this,</p> <pre><code>typedef int (*func) (char*); typedef struct{ char * name; func f1; } </code></pre> <p>As opposed to this, I came across a code, which I don't understand.</p> <pre><code>typedef int rl_icpfunc_t (char *); typedef struct { char *name; /* User printable name of the function. */ rl_icpfunc_t *func; /* Function to call to do the job. */ char *doc; /* Documentation for this function. */ }COMMAND; </code></pre> <p>This is a code snippet from an example of the libedit library. Can someone please explain this to me?</p>
24,334,727
1
Is is possible to put a time.sleep(n) in a list comprehension? <p>Is it possible to put a <code>time.sleep(n)</code> in a list comprehension to print each item in the list with a delay between each print?</p> <pre><code>import random, time outside_lights = ['LED_fgate', 'LED_rgate', 'LED_mandoor', 'LED_garage', 'LED_garWin', 'LED_rgb', 'LED_deckOld', 'LED_deckNew', 'LED_cleartube', 'LED_cleartube2' ] random.shuffle(outside_lights, random.random) print [i for i in outside_lights] </code></pre>
22,323,217
0
mongo_client() fail with error MONGO_CONN_ADDR_FAIL <p>I want to use mongodb c driver in my project, I'm on Windows 7 so built it with command :</p> <blockquote> <p>scons --m32 --c99</p> </blockquote> <p>My problem is I can't make the <a href="http://api.mongodb.org/c/current/tutorial.html#connecting" rel="nofollow">Connecting example</a> work :</p> <pre><code>#include &lt;stdio.h&gt; #define MONGO_HAVE_STDINT #include "mongo.h" int main() { mongo conn[1]; int status = mongo_client( conn, "127.0.0.1", 27017 ); printf("status %d, err %d", status, conn-&gt;err); mongo_destroy( conn ); return 0; } </code></pre> <p>Whether mongod is running on my machine or not, the output of executing the exe is : </p> <blockquote> <p>$ ./mongodb_example.exe status -1, err 3</p> </blockquote> <p>Error <code>3</code> <a href="http://api.mongodb.org/c/current/api/mongo_8h.html#a5e6f76bd796c89973ffb463e676237bba616d4918c05106a74cb200834ad0ec4e" rel="nofollow">corresponds</a> to MONGO_CONN_ADDR_FAIL error code (An error occured while calling getaddrinfo()).</p> <p>Any suggestion about how to connect successfully ?</p> <p><strong>Updates:</strong> </p> <ul> <li>version is <code>mongodb-mongo-c-driver-v0.8.1-0-g8f27c0f</code></li> </ul>
10,207,141
0
Windows Phone 7 Play Vimeo Video <p>I am trying to get Vimeo videos to play in a windows 7 phone app, we need to online streaming specific video from vimeo in our Application. i have revieved following links but still i have not found any solution.</p> <ul> <li><a href="http://stackoverflow.com/questions/7521981/play-vimeo-videos-in-windows-7-phone">Play Vimeo Videos in Windows 7 phone</a></li> <li><a href="http://stackoverflow.com/questions/7511851/windows-phone-7-playing-streaming-video">Windows Phone 7 - Playing streaming video</a></li> </ul> <p>any one know how to play online stream Vimeo video in Windows Phone 7 Application?</p> <p>Thanks In Advance.</p>
7,012,138
0
ASP.NET web control panel for a desktop application <p>I'm working on a C# windows application but I'd like to create a website to be hosted on the same machine that could provide monitoring, other people on the network would be able to login and see the state of certain variables, maybe trigger methods to turn things on and off. I'm looking for a point in the right direction as to how I'd go about doing this?</p> <p>Thanks, Ben</p>
26,749,255
0
<p>Before using the "prompt" module, I used the ReadLine interface; sadly I had the same problem. However, the fix was simple:</p> <blockquote> <p>Remove the <code>rli.close();</code> and then run it.</p> <p>Then re-add the <code>rli.close();</code> and it works!</p> </blockquote> <p>Thanks mscdex for the input, though :)</p>
18,755,341
0
Handle $_GET requests with Clean URLs <p>I am have a clear URL based system so the categories will be shown like this </p> <pre><code>http://www.mysite.com/category/23/cat-name </code></pre> <p>Inside the categories page I have some sorting and pages options such as sorting by latests and lower price. Also, I have a pages navigation system</p> <p>The problem is when the request is happening inside the page the <code>$_GET[]</code> doesn't show the variables I need. However it shows in the URL as </p> <pre><code>http://www.mysite.com/category/23/cat-name?page=3 </code></pre> <p>The <code>$_GET</code> variable only shows the id of the category which is in our case now = <code>23</code> and ignored the page number which is in the url.</p> <p><code>.htaccess</code> content</p> <pre><code>RewriteEngine On RewriteRule ^category/([0-9]+)/[a-z][-a-z0-9]*$ cat.php?id=$1 </code></pre>
16,483,488
0
jsf listener on fullcalendar <p>I want to use the FullCalendar jQuery Plugin with JSF.</p> <p>But how can I add an f:ajax listener to an e.g. eventClick of the FullCalendar?</p> <p>Here's the code where I want to add a listener to:</p> <pre><code>&lt;ui:define name="content"&gt; &lt;div id="calendar"&gt; &lt;f:ajax event="eventClick" listener="#{scheduleController.onDateSelect}"/&gt; &lt;/div&gt; &lt;/ui:define&gt; &lt;ui:define name="jsFiles"&gt; &lt;script&gt; $(document).ready(function() { var calendar = $('#calendar').fullCalendar({ header : { left : 'prev,next today', center : 'title', right : 'month,agendaWeek,agendaDay' }, selectable : true, selectHelper : true, select : function(start, end, allDay) { var title = prompt('Event Title:'); if (title) { calendar.fullCalendar('renderEvent', { title : title, start : start, end : end, allDay : allDay }, true // make the event "stick" ); } calendar.fullCalendar('unselect'); }, editable : true, eventClick : function(event, element) { event.title = "CLICKED!"; $('#calendar').fullCalendar('updateEvent', event); } }); }); &lt;/script&gt; &lt;/ui:define&gt; </code></pre>
10,846,196
0
how is code for sending parameters to the JSON type URL? <p>hi all i am getting response like below URL but i have to pass NSString type parameters to the My required URL as like shown below how is code for sending request to the URL in iPhone? so plz give me any one for my request.</p> <h1>define kLatestKivaLoansURL [NSURL URLWithString: @"http://eventappmobiledev.cloudapp.net/EventDataService.svc/GetTechnologies?APIKey=62CB769C-E17E-484E-BE51-C144D062D076"]</h1>
29,102,751
0
<p>Use single table inheritance of Post model</p> <pre><code> class class Post &lt; ActiveRecord::Base ..... end </code></pre> <p>Than inherit this Post model into these model.</p> <pre><code>class VideoPost &lt; Post end class ImagePost &lt; Post end </code></pre> <p>At migration you need to create a type column for different type of post. For details look at this <a href="http://blog.thirst.co/post/14885390861/rails-single-table-inheritance" rel="nofollow">blog post</a></p>
39,413,786
1
Can I make an ipywidget floatslider with a list of values? <p>I would like to make an ipywidget floatslider, but passing it a list of values, rather than a range and step. Is there a way to do this, or is making a dropdown widget the only option?</p>
36,355,248
0
<p>You need to quote the argument, and you should use single quotes, <code>'</code>, in order to stop your shell from attempting to evaluate anything inside it.</p> <p>What happens is that every ampersand, "&amp;", on your command line launches a background process.</p> <p>The first process is <code>./demo 1 https://www.google.co.in/search?sourceid=chrome-psyapi2</code>, and all the following are assignments to variables.</p> <p>You can see from the output (it looks like you didn't post all of it)</p> <pre><code>[1] 8680 [2] 8681 [3] 8682 [4] 8683 [5] 8684 [6] 8685 [7] 8686 [2] Done ion=1 [3] Done espv=2 [4] Done ie=UTF-8 [6]- Done q=size%20of%20unsigned%20char%20array%20c%2B%2B </code></pre> <p>that background process 2 is <code>ion=1</code> (pid 8681), process 3 (pid 8682) is <code>espv=2</code>, and so on. </p>
4,116,288
0
<p>Unless you have a compelling reason to use Axis I would rather stay with JAX-WS and JAXB. It's included in JDK 6 but could be used with JDK 5 as well. Supported in all modern Java EE containers (Websphere, Weblogic) but could be used in Servlet containers (Tomcat, Jetty) with just few jars from Reference Implementation (Metro). Minimum dependencies and 'just works' for most of the scenarios.</p>
19,335,973
0
<p>In base class, create abstract virtual method that returns some kind of "ID". (string, int, enum, whatever).</p> <p>In "save" method, write ID first, for all classes. You could embed ID writing into base class, so derived classes won't override this behavior.</p> <pre><code>typedef SomeType ClassId; class Serializeable{ protected: virtual ClassId getClassId() const = 0; virtual void saveData(OutStream &amp;out) = 0; public: void save(OutStream &amp;out){ out &lt;&lt; getClassId(); saveData(out); } }; </code></pre> <p>Make a factory, that constructs required class given its ID.</p> <p>--edit--</p> <p>Example with factory (C++03 standard):</p> <pre><code>#include &lt;map&gt; #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;QSharedPointer&gt; #include &lt;utility&gt; typedef std::string ClassId; typedef std::ostream OutStream; class Serializeable{ protected: virtual void saveData(OutStream &amp;out) = 0; public: virtual ClassId getClassId() const = 0; void save(OutStream &amp;out){ out &lt;&lt; getClassId(); saveData(out); } virtual ~Serializeable(){ } }; class Derived: public Serializeable{ protected: virtual void saveData(OutStream &amp;out){ out &lt;&lt; "test"; } public: virtual ClassId getClassId() const{ return "Derived"; } }; typedef QSharedPointer&lt;Serializeable&gt; SerializeablePtr; //basically std::shared_ptr SerializeablePtr makeDerived(){ return SerializeablePtr(new Derived()); } class ClassFactory{ protected: typedef SerializeablePtr (*BuilderCallback)(); typedef std::map&lt;ClassId, BuilderCallback&gt; BuilderMap; BuilderMap builderMap; template&lt;class C&gt; static SerializeablePtr defaultBuilderFunction(){ return SerializeablePtr(new C()); } public: SerializeablePtr buildClass(ClassId classId){ BuilderMap::iterator found = builderMap.find(classId); if (found == builderMap.end()) return SerializeablePtr();//or throw exception return (*(found-&gt;second))(); } void registerClass(ClassId classId, BuilderCallback callback){ builderMap[classId] = callback; } template&lt;typename T&gt; void registerClassByValue(const T &amp;val){ registerClass(val.getClassId(), ClassFactory::defaultBuilderFunction&lt;T&gt;); } template&lt;typename T&gt; void registerClassWithTemplate(ClassId classId){ registerClass(classId, ClassFactory::defaultBuilderFunction&lt;T&gt;); } }; int main(int argc, char** argv){ ClassFactory factory; std::string derivedId("Derived"); factory.registerClass(derivedId, makeDerived); SerializeablePtr created = factory.buildClass(derivedId); created-&gt;save(std::cout); std::cout &lt;&lt; std::endl; Derived tmp; factory.registerClassByValue(tmp); created = factory.buildClass(derivedId); created-&gt;save(std::cout); std::cout &lt;&lt; std::endl; factory.registerClassWithTemplate&lt;Derived&gt;(derivedId); created = factory.buildClass(derivedId); created-&gt;save(std::cout); std::cout &lt;&lt; std::endl; return 0; } </code></pre> <p><code>QSharedPointer</code> is smart pointer class from Qt 4, roughly equivalent to <code>std::shared_ptr</code>. Use either <code>std::shared_ptr</code> or <code>boost::shared_ptr</code> instead of <code>QSharedPointer</code> in your code.</p>
39,195,448
0
Getting Leaks Even After pthread_detach <p>I am trying to make self-cleanup thread code to release pthread_t resources if I terminate the whole program from a side thread using pthread_detach, but I am still getting memory leaks reports from valgrind with possibly lost bytes. Here is my sample code snippet:</p> <pre><code>pthread_t main_thread; pthread_t second_thread; void* thread_func() { pthread_detach(pthread_self()); exit(0); } int main() { main_thread = pthread_self(); // record main thread in case needed later pthread_create(&amp;second_thread, NULL, thread_func, NULL); while(1); // making main thread wait using a busy-wait (in case pthread_join) interferes // with pthread_detach (that's another question though: does pthread_join called // from another thread overlaps with pthread_detach from the same thread?) } </code></pre> <p><br></p> <p>Can anyone please help me indicate where I forgot to release any allocated resources?</p>
1,060,506
0
F# using sequence cache correctly <p>I'm trying to use Seq.cache with a function that I made that returns a sequence of primes up to a number N excluding the number 1. I'm having trouble figuring out how to keep the cached sequence in scope but still use it in my definition.</p> <pre><code>let rec primesNot1 n = {2 .. n} |&gt; Seq.filter (fun i -&gt; (primesNot1 (i / 2) |&gt; Seq.for_all (fun o -&gt; i % o &lt;&gt; 0))) |&gt; Seq.append {2 .. 2} |&gt; Seq.cache </code></pre> <p>Any ideas of how I could use Seq.cache to make this faster? Currently it keeps dropping from scope and is only slowing down performance.</p>
529,098
0
Removing duplicate rows from table in Oracle <p>I'm testing something in Oracle and populated a table with some sample data, but in the process I accidentally loaded duplicate records, so now I can't create a primary key using some of the columns.</p> <p>How can I delete all duplicate rows and leave only one of them?</p>
5,850,190
0
<p>A very crude way of doing it would be, simply subtracting the registration date from the current time, and get the total months from the number of days:</p> <pre><code>TimeSpan age = DateTime.Now - registrationDate; int months = (int) (age.TotalDays/30); </code></pre> <p>After a few years (about six or seven) you'll get extra months counted. Counting in months is not easy because a month is not an exact quantity. I'm guessing that a vehicle being six years old is probably very common, so this may not be a good fit.</p> <p>A better alternative would be to subtract the years and the months directly:</p> <pre><code>int fullYears = (now.Year - registrationDate.Year) * 12; int partialYear = now.Month - registrationDate.Month; int months = fullYears + partialYear; </code></pre>
5,846,473
0
<p>Try put this code in your page</p> <pre><code>&lt;script type="text/javascript"&gt; Sys.Application.add_load(function () { Sys.Extended.UI.MaskedEditBehavior.prototype._MoveDecimalPos = function () { var e = this.get_element(); var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(e); var curpos = this._LogicFirstPos; var max = this._LogicLastPos; var posDc = -1; while (curpos &lt; max) { if (wrapper.get_Value().substring(curpos, curpos + 1) == this.get_CultureDecimalPlaceholder()) { posDc = curpos + 1; break; } curpos++; } if (posDc == -1) { return; } this.setSelectionRange(posDc, posDc); }; }); &lt;/script&gt; </code></pre>
26,612,737
1
Is there a way to append/extend a list with another list at a specific index in python? <p>In other words, I want to accomplish something like the following:</p> <pre><code>a = [1, 2, 3, 7, 8] b = [4, 5, 6] # some magic here to insert list b into list a at index 3 so that a = [1, 2, 3, 4, 5, 6, 7, 8] </code></pre>
15,459,922
0
How to run an Android app in IntelliJ Simulator <p>I installed IntelliJ 12 and Android SDK 10 and 17. I setup a simple "hello world" android app in IntelliJ. Then I run the app in emulator using IntelliJ. IntelliJ executes the following command:</p> <pre><code>"D:\Program Files\Android\android-sdk\tools\emulator.exe" -avd AVD_for_Nexus_S_by_Google -netspeed full -netdelay none </code></pre> <p>Android emulator runs but the "hello world" app is not inside it:</p> <p><img src="https://i.imgur.com/8PfaqxW.png" alt=""></p> <p>What should I do in order to make the emulator execute "hello world" app? I guess there should be some reference to the app in the above command. </p>
39,467,407
0
<p>One-liner direct computation (no Date object):</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function daysInMonth(m, y) {//m is 1-based, feb = 2 return 31 - (--m ^ 1? m % 7 &amp; 1: y &amp; 3? 3: y % 25? 2: y &amp; 15? 3: 2); } console.log(daysInMonth(2, 1999)); // February in a non-leap year console.log(daysInMonth(2, 2000)); // February in a leap year</code></pre> </div> </div> </p> <p>Variation with 0-based months:</p> <pre><code>function daysInMonth(m, y) {//m is 0-based, feb = 1 return 31 - (m ^ 1? m % 7 &amp; 1: y &amp; 3? 3: y % 25? 2: y &amp; 15? 3: 2); } </code></pre>
5,753,775
0
<p>Refer to this link. you will find many examples related to animation.</p> <p><a href="http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CAAnimation_class/Introduction/Introduction.html" rel="nofollow">http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CAAnimation_class/Introduction/Introduction.html</a></p> <p><a href="http://www.vellios.com/2010/07/11/simple-iphone-animation-tutorial/" rel="nofollow">http://www.vellios.com/2010/07/11/simple-iphone-animation-tutorial/</a></p>
26,766,682
0
<p>How about something like this?</p> <pre><code>string result = Regex.Replace(searchText, "(?s)^(\\d+/\\d+/\\d+ \\d+:\\d+:\\d+ [APM]{2}) (\\d+) (.*)$", ""); </code></pre> <p>This regex returns the date and time in the first group, the ID in the second and everything else (the message) in the last. </p> <p>The standard form of the above regex is</p> <pre><code>^(\d+/\d+/\d+ \d+:\d+:\d+ [APM]{2}) (\d+) (.*)$ </code></pre>
29,215,102
0
<p>Well, this is easy:</p> <pre><code>var DATES=[];for (var i=0;i&lt;mlength;DATES.push([]),i++); </code></pre> <p>Just push an empty array to <code>DATES</code> <code>mlength</code> number of times.</p>
7,905,816
0
<p>Here's my wild guess: <strong>cache</strong></p> <p>It could be that you can fit 2 rows of 2000 <code>double</code>s into the cache. Which is slighly less than the 32kb L1 cache. (while leaving room other necessary things)</p> <p>But when you bump it up to 2048, it uses the <strong><em>entire</em></strong> cache (and you spill some because you need room for other things)</p> <p>Assuming the cache policy is LRU, spilling the cache just a tiny bit will cause the entire row to be repeatedly flushed and reloaded into the L1 cache.</p> <p>The other possibility is cache associativity due to the power-of-two. Though I think that processor is 2-way L1 associative so I don't think it matters in this case. (but I'll throw the idea out there anyway)</p> <p><strong>Possible Explanation 2:</strong> Conflict cache misses due to super-alignment on the L2 cache.</p> <p>Your <code>B</code> array is being iterated on the column. So the access is strided. Your total data size is <code>2k x 2k</code> which is about 32 MB per matrix. That's much larger than your L2 cache.</p> <p>When the data is not aligned perfectly, you will have decent spatial locality on B. Although you are hopping rows and only using one element per cacheline, the cacheline stays in the L2 cache to be reused by the next iteration of the middle loop.</p> <p>However, when the data is aligned perfectly (2048), these hops will all land on the same "cache way" and will far exceed your L2 cache associativity. Therefore, the accessed cache lines of <code>B</code> will not stay in cache for the next iteration. <strong><em>Instead, they will need to be pulled in all the way from ram.</em></strong></p>
3,050,950
0
<p>I'm guessing that it has to do with using a keyword as a function name. I tried defining a function <code>print()</code> in a module just now for testing and got the same sort of error. Try changing the name of this function slightly and see if it fixes the problem.</p>