pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
12,293,806
0
<p>From javadoc of <a href="http://weka.sourceforge.net/doc.dev/weka/filters/unsupervised/attribute/MathExpression.html" rel="nofollow">MathExpression</a></p> <blockquote> <p>The 'A' letter refers to the value of the attribute being processed. Other attribute values (numeric only) can be accessed through the variables A1, A2, A3, ...</p> </blockquote> <p>Your filter applies to all attributes of your dataset. If I load iris dataset and apply following filter.</p> <blockquote> <p>weka.filters.unsupervised.attribute.MathExpression -E log(A).</p> </blockquote> <p>your attribute ,sepallength values change as following.</p> <pre><code>Before Filter After Filter Minimum 4.3 Minimum 1.459 Maximum 7.9 Maximum 2.067 Mean 5.843 Mean 1.755 StdDev 0.828 StdDev 0.141 </code></pre> <p>Also if you look to javadoc, there is no if else function but ifelse function. Therefore you should write something like</p> <pre><code>ifelse ( (A == 2 || A == 0), 1,0 ) </code></pre> <p>Also this filter applies to all attributes. If you want to change only one attribute and according to other attribute values ; then you need to use "Ignore range option" and use A1,A2 to refer to other attribute values.</p> <p>if you need to add new attribute use <a href="http://weka.sourceforge.net/doc.dev/weka/filters/unsupervised/attribute/AddExpression.html" rel="nofollow">AddExpression</a>.</p> <blockquote> <p>An instance filter that creates a new attribute by applying a mathematical expression to existing attributes. </p> </blockquote>
26,662,283
0
<p>In order to compute the rmse it is neccessary to have a maximum of 1 y value per x value, mathematically speaking a "function". You can plot later again the way your sketch shows it. But for the computation: rotate by 90 degree.</p> <p>For the optimization, you need an initiall guess (your <code>Alpha</code>), which is not defined. However, with some minor changes in the code below, one can get the optimal parameters. Also it might be better readable. The plot is shown below.</p> <pre><code>plot(r, XMean ,'ko', 'markerfacecolor', 'black') % // need a "function" (max 1y value for 1x-value) Eqn = @(par, x) par(1).*( 1 - ( (par(2) - x) / par(3) ).^2 ); par0 = [1, 1, 1]; % // an initial guess as start for optimization par_fit = nlinfit(r, XMean, Eqn, par0 ); % // optimize hold on r_fit = linspace(min(r), max(r)); % // more points for smoother curve plot(r_fit, Eqn(par_fit, r_fit), 'r') </code></pre> <p><img src="https://i.stack.imgur.com/w6PDy.png" alt="enter image description here"> The optimal parameters i get returned are</p> <pre><code>par_fit = 0.1940 -0.4826 9.0916 </code></pre> <p>You might want to rotate the plot again to get it into the right orientation, as in your sketch.</p> <h1>Additional Info: polyfit() instead of nlinfit</h1> <p>Since one can compute this flow profile analytically, one knows in advance that is is a parabola. You can also use <code>polyfit</code> to fit a parabola.</p> <pre><code>par_poly_fit = polyfit(r, XMean, 2) % // it yields the values: par_poly_fit = -0.0023 -0.0023 0.1934 </code></pre> <p>Plotting that paraobla gives a line pretty much identical to the line, which we got with the optimizer, but it is just more stable since it does not depend on an initial value.</p> <pre><code> plot(r_fit, polyval(par_poly_fit, r_fit),'g--' </code></pre>
9,525,576
0
<p>according to <a href="http://www.connectionstrings.com/Articles/Show/use-application-name-sql-server" rel="nofollow">this link</a> you can put space there</p>
25,371,760
0
<p>Alright, since I got no answers for this question, I'm going to post the solution that worked for me.</p> <p>Using Cordova’s hooks (<code>after_prepare</code>) I was able to copy the splash screen files from <code>/www</code> to the correct Android and iOS platform directories.</p> <p>The hook lives in <code>/hooks/after_prepare/030_resource_files.js</code> and it gets executed by Cordova right after the prepare step.</p> <p>This is what my code looked like at the end:</p> <pre><code>#!/usr/bin/env node // Reference: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/ // // This hook copies various resource files from our version control system directories into the appropriate platform specific location // var appName = "MyAwesomeApp"; // configure all the files to copy. Key of object is the source file, value is the destination location. It's fine to put all platforms' icons and splash screen files here, even if we don't build for all platforms on each developer's box. var filestocopy = [{ "www/res/screens/android/drawable/splash.png": "platforms/android/res/drawable/splash.png" },{ "www/res/screens/android/drawable-hdpi/splash.png": "platforms/android/res/drawable-hdpi/splash.png" }, { "www/res/screens/android/drawable-ldpi/splash.png": "platforms/android/res/drawable-ldpi/splash.png" }, { "www/res/screens/android/drawable-mdpi/splash.png": "platforms/android/res/drawable-mdpi/splash.png" }, { "www/res/screens/android/drawable-xhdpi/splash.png": "platforms/android/res/drawable-xhdpi/splash.png" }, { "www/res/screens/ios/Resources/splash/Default@2x~iphone.png": "platforms/ios/" + appName + "/Resources/splash/Default@2x~iphone.png" }, { "www/res/screens/ios/Resources/splash/Default-568h@2x~iphone.png": "platforms/ios/" + appName + "/Resources/splash/Default-568h@2x~iphone.png" }, { "www/res/screens/ios/Resources/splash/Default~iphone.png": "platforms/ios/" + appName + "/Resources/splash/Default~iphone.png" }]; var fs = require('fs'); var path = require('path'); // no need to configure below var rootdir = process.argv[2]; filestocopy.forEach(function(obj) { Object.keys(obj).forEach(function(key) { var val = obj[key]; var srcfile = path.join(rootdir, key); var destfile = path.join(rootdir, val); //console.log("copying "+srcfile+" to "+destfile); var destdir = path.dirname(destfile); if (fs.existsSync(srcfile) &amp;&amp; fs.existsSync(destdir)) { fs.createReadStream(srcfile).pipe(fs.createWriteStream(destfile)); } }); }); </code></pre> <p>Still pretty difficult to get it working as there are a lot of pieces that have to fit together for it to work, but it was the hooks that helped me solve my problem.</p> <p>Source: The <em>Copy Icons and Splashscreens</em> section of an article by Holly Schinsky was incredibly helpful and where I took most of the code from: <a href="http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/" rel="nofollow">http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/</a></p>
1,749,604
0
<p>Multi-dispatch is the ability to choose which version of a function to call based on the runtime type of the arguments passed to the function call.</p> <p>Here's an example that won't work right in C++ (untested):</p> <pre><code>class A { }; class B : public A { }; class C : public A { } class Foo { virtual void MyFn(A* arg1, A* arg2) { printf("A,A\n"); } virtual void MyFn(B* arg1, B* arg2) { printf("B,B\n"); } virtual void MyFn(C* arg1, B* arg2) { printf("C,B\n"); } virtual void MyFn(B* arg1, C* arg2) { printf("B,C\n"); } virtual void MyFn(C* arg1, C* arg2) { printf("C,C\n"); } }; void CallMyFn(A* arg1, A* arg2) { // ideally, with multi-dispatch, at this point the correct MyFn() // would be called, based on the RUNTIME type of arg1 and arg2 pFoo-&gt;MyFn(arg1, arg2); } ... A* arg1 = new B(); A* arg2 = new C(); // Using multi-dispatch this would print "B,C"... but because C++ only // uses single-dispatch it will print out "A,A" CallMyFn(arg1, arg2); </code></pre>
29,051,652
0
<p>You can use the following</p> <p><code>var result = db.tableName.Where(o =&gt; mylist.conains(o.item_ID) &amp;&amp; o.readed).ToList();</code></p>
7,592,747
0
how to remove namespace and retain only some of the elements from the original XML document using XSL? <p>Below is my XML. I wanted to parse this using XSL. What I want to achieve is to remove the namespace (xmlns) then just retain some of the elements and their attributes. I found a way to remove the namespace but when I put it together with the code to retain some of the elements, it doesn't work. I already tried the identity but still didn't work. </p> <p>I hope someone out there could share something. Thank you very much in advance.</p> <p>XML Input:</p> <pre><code>&lt;Transaction xmlns="http://www.test.com/rdc.xsd"&gt; &lt;Transaction&gt; &lt;StoreName id="aa"&gt;STORE A&lt;/StoreName&gt; &lt;TransNo&gt;TXN0001&lt;/TransNo&gt; &lt;RegisterNo&gt;REG001&lt;/RegisterNo&gt; &lt;Items&gt; &lt;Item id="1"&gt; &lt;ItemID&gt;A001&lt;/ItemID&gt; &lt;ItemDesc&gt;Keychain&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;Item id="2"&gt; &lt;ItemID&gt;A002&lt;/ItemID&gt; &lt;ItemDesc&gt;Wallet&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;/Items&gt; &lt;IDONTLIKETHIS_1&gt; &lt;STOREXXX&gt;XXX-&lt;/STOREXXX&gt; &lt;TRANSXXX&gt;YYY&lt;/TRANSXXX&gt; &lt;/IDONTLIKETHIS_1&gt; &lt;IDONTLIKETHIS_2&gt; &lt;STOREXXX&gt;XXX-&lt;/STOREXXX&gt; &lt;TRANSXXX&gt;YYY&lt;/TRANSXXX&gt; &lt;/IDONTLIKETHIS_2&gt; &lt;/Transaction&gt; &lt;Transaction&gt; </code></pre> <p>Expected XML Output:</p> <pre><code>&lt;Transaction&gt; &lt;Transaction&gt; &lt;StoreName id="aa"&gt;STORE A&lt;/StoreName&gt; &lt;TransNo&gt;TXN0001&lt;/TransNo&gt; &lt;RegisterNo&gt;REG001&lt;/RegisterNo&gt; &lt;Items&gt; &lt;Item id="1"&gt; &lt;ItemID&gt;A001&lt;/ItemID&gt; &lt;ItemDesc&gt;Keychain&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;Item id="2"&gt; &lt;ItemID&gt;A002&lt;/ItemID&gt; &lt;ItemDesc&gt;Wallet&lt;/ItemDesc&gt; &lt;/Item&gt; &lt;/Items&gt; &lt;/Transaction&gt; &lt;Transaction&gt; </code></pre> <p>Code used to remove the namespace (xmlns):</p> <pre><code>&lt;xsl:template match="*"&gt; &lt;xsl:element name="{local-name()}"&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@*"&gt; &lt;xsl:attribute name="{local-name()}"&gt; &lt;xsl:value-of select="."/&gt; &lt;/xsl:attribute&gt; &lt;/xsl:template&gt; </code></pre>
16,282,192
0
<p>To find the intersection of two curves:</p> <p>Declare g1 and g2 as explicit anonymous functions</p> <pre><code>g1 = @(x)(sqrt(2*x - 1)); g2 = @(x)(-0.4*x.^2 + 4.5); </code></pre> <p>Choose a range for x to test over:</p> <pre><code>xmin = 0; xmax = 100; xres = 0.1; x = xmin:xres:xmax; </code></pre> <p>Find in the curves</p> <pre><code>G1 = g1(x); G2 = g2(x); </code></pre> <p>Now find the index where the graphs cross each other:</p> <pre><code>ind = find(diff(G1 &gt; G2)); </code></pre> <p>Now it's easy to convert that index to an <code>x</code> value:</p> <pre><code>xval = xmin + (ind(1)-1)*xres </code></pre> <p><strong>EDIT:</strong></p> <p>So I'm assuming now that your (V1,V2) is just a unit direction vector from the origin? If so we can create a straight line y = mx+c and find where that intersect g1 and g2. </p> <pre><code>m = V2/V1; c = Y - m*X; line = @(x)(m*x + c); </code></pre> <p>now just follow the procedure above to find the point of intersection of <code>line</code> and <code>g1</code> and also of <code>line</code> and <code>g2</code>. If V1 is negative, then set <code>xmax = X</code> otherwise set <code>xmin = X</code> so that you look for the intersection point in the right direction. The <code>xval</code> line will probably error if there is no point of intersection so add some error checking in there. And then just pick the smallest xval if V1 was positive or the larger if V1 is negative</p> <pre><code>if V1 &gt;= 0 xmin = X; xmax = X + 100; else xmin = X - 100; xmax = X; end; xres = 0.1; x = xmin:xres:xmax; G1 = g1(x); G2 = g2(x); L = line(x); ind1 = find(diff(G1 &gt; L)); xval1 = xmin + (ind1(1)-1)*xres ind2 = find(diff(G2 &gt; L)); xval2 = xmin + (ind2(1)-1)*xres xval = (V1 &gt; 0)*max(xval1, xval2) + (V2 &lt; 0)*max(xval1, xval2); yval = line(xval); </code></pre>
4,675,010
0
<p>Process isOK your window.confirm within the function of the button</p> <pre><code>$('#button1').click(function(){ if(window.confirm("Are you sure?")) alert('Your action here'); }); </code></pre> <p>The issue you're going to have is the click has already happened when you trigger your "Are You Sure" Calling preventDefault doesn't stop the execution of the original click if it's the one that launched your original window.confirm. </p> <p>Bit of a chicken/egg problem.</p> <p>Edit: after reading your edited question:</p> <pre><code> var myClick = null; //get a list of jQuery handlers bound to the click event var jQueryHandlers = $('#button1').data('events').click; //grab the first jquery function bound to this event $.each(jQueryHandlers,function(i,f) { myClick = f.handler; return false; }); //unbind the original $('#button1').unbind('click'); //bind the modified one $('#button1').click(function(){ if(window.confirm("Are You Sure?")){ myClick(); } else { return false; } }); </code></pre>
35,313,683
0
Can´t load store of a combo in ExtJS4 <p>I can´t load the store data when the view is loaded. This is my store: (strEstadosMtoOrganismos.js)</p> <pre><code>Ext.define('TelicitaApp.store.filtros.strEstadosMtoOrganismos', { extend: 'Ext.data.Store', model: 'TelicitaApp.model.filtros.mdlEstadosMtoOrganismos', autoLoad: false, proxy: { type: 'ajax', api: {read: './data/php/filtros/Tmc_EstadosMtoOrganismos.php?despliegue='+TelicitaApp.Settings.despliegue}, reader: { type: 'json', root: 'data', totalProperty: 'total', successProperty: 'success' } } }); </code></pre> <p>This is my view: (viewGridMtoOrganismos.js)</p> <pre><code>Ext.define('TelicitaApp.view.mantenimientos.organismos.viewGridMtoOrganismos', { extend: 'Ext.grid.Panel', alias: 'widget.viewGridMtoOrganismos', requires: [ ], initComponent: function() { var toolbar1 = { xtype : 'toolbar', dock : 'top', items: [ { iconCls:'limpiar-icon', text:'Limpiar', handler: function() {}, }, '-&gt;', { iconCls:'refresh', text:'Recargar', handler: function() {}, } ] }; var toolbar2 = { xtype: 'toolbar', dock: 'top', items: [ {text:'&lt;span style="color:#C85E00;"&gt;Estado&lt;/span&gt;'}, { xtype: 'combo', value: 'Todos', queryMode: 'remote', triggerAction: 'all', editable: false, displayField: 'label', valueField: 'value', store: 'filtros.strEstadosMtoOrganismos' } ] } Ext.apply(this, { frame: true, bodyPadding: '5 5 0', fieldDefaults: { labelAlign: 'top', msgTarget: 'side' }, forceFit: true, height: 300, stripeRows: true, loadMask: true, tbar: { xtype: 'container', layout: 'anchor', defaults: {anchor: '0'}, defaultType: 'toolbar', items: [ toolbar1,toolbar2 ] }, columns: [ {header:'&lt;span style="color:blue;"&gt;Id&lt;/span&gt;', xtype: 'numbercolumn',format:'0', width:35, sortable: true}, ] }); this.callParent(arguments); } }); </code></pre> <p>This is my controller: (ctrlMtoOrganismos.js)</p> <pre><code>Ext.define('TelicitaApp.controller.ctrlMtoOrganismos', { extend: 'Ext.app.Controller', models:[ 'mantenimientos.organismos.mdlMtoOrganismos', 'filtros.mdlEstadosMtoOrganismos' ], stores:[ 'mantenimientos.organismos.strMtoOrganismos', 'filtros.strEstadosMtoOrganismos' ], views: [ 'mantenimientos.organismos.viewModuloMtoOrganismos' ], refs: [ ], init: function() { this.control({ }); }, onLaunch: function() { }, }); </code></pre> <p>If I set the autoload property in the store to true,it load the data when the app launch.But I want to load the data when the view is loaded. Once the view is loaded,if i expand the combo it launch the php file taht fills the combo,but I want it to load the data automatically after the view is loaded,not when you expand the combo.</p>
16,397,973
0
<p>You cant fill <code>std::vector</code> using memcpy (Well.. there is a way, but for you is better to think it as if not). Use <code>std::copy</code> or fill it by yourself.</p>
14,380,983
0
SQL Error: ORA-00904: : invalid identifier in CREATE AS SELECT <p>I am trying to create a table from 2 other tables in Oracle SQL Developer:</p> <pre><code>CREATE TABLE share_stock( share_id NUMBER(6,0), share_price NUMBER(10,2), company_id NUMBER(6,0), company_name VARCHAR2(50), ticker_symbol VARCHAR2(4), AS SELECT share_price.share_price_id, share_price.price, share_price.company_id, company.name, company.ticker_symbol FROM share_price, company WHERE share_price.company_id = company.company_id, CONSTRAINT sh_pk PRIMARY KEY (share_price.share_price_id), CONSTRAINT sh_pr_fk FOREIGN KEY (share_price.share_price_id) REFERENCES share_price(share_price_id) ); </code></pre> <p>Basically I am trying to perform a CREATE AS SELECT, but I am getting this error:</p> <blockquote> <p>Error at Command Line:294 Column:28 Error report: SQL Error: ORA-00904: : invalid identifier 00904. 00000 - "%s: invalid identifier"</p> </blockquote> <p>I have tried to correct my syntax and I have not managed to get it right so far, Any ideas would be helpful,</p> <p>Thanks in advance.</p>
14,841,031
0
<p>All you have to do is correct your signatures like so:</p> <pre><code>const T&amp; operator [](char* b) const; T&amp; operator [](char* b); </code></pre> <p>I've removed the <code>const</code> qualifier from the second operator.</p> <blockquote> <p>if I use <code>AssArray["llama"]=T</code>, how am I supposed to get the value of T into the operator overloading-function?</p> </blockquote> <p>You don't. You just return a reference to where the new value should be stored, and the compiler will take care of the rest. If <code>"llama"</code> does not exist in the array, you need to create an entry for it, and return a reference to that entry.</p>
13,068,898
0
<p>I don't know how many frames you have in the <code>scene1</code>. But I am sure if your code is in the first frame of <code>scene 1</code> you can't see that because you haven't stopped there rather you are playing it to what is next(<code>gotoAndPlay</code>). So, if you want to see the changes made dynamically you should stop there(where your code is).</p> <p>The Other Issue. In AS3, If you do some dynamic actions in the stage like the following, then it won't get removed when you moving to another scene.</p> <ol> <li>add a movieclip,</li> <li>swap depth or changing child index,</li> <li>start drag and so on.</li> </ol> <p>I hope there is only one <code>stage</code> for the whole application. So, the objects in the stage are always visible regardless of what scene we are in.</p>
9,969,236
1
How to implement Priority Queues in Python? <p>Sorry for such a silly question but Python docs are confusing.. . </p> <p><strong>Link 1: Queue Implementation</strong> <a href="http://docs.python.org/library/queue.html">http://docs.python.org/library/queue.html</a></p> <p>It says thats Queue has a contruct for priority queue. But I could not find how to implement it.</p> <pre><code>class Queue.PriorityQueue(maxsize=0) </code></pre> <p><strong>Link 2: Heap Implementation</strong> <a href="http://docs.python.org/library/heapq.html">http://docs.python.org/library/heapq.html</a></p> <p>Here they says that we can implement priority queues indirectly using heapq</p> <pre><code>pq = [] # list of entries arranged in a heap entry_finder = {} # mapping of tasks to entries REMOVED = '&lt;removed-task&gt;' # placeholder for a removed task counter = itertools.count() # unique sequence count def add_task(task, priority=0): 'Add a new task or update the priority of an existing task' if task in entry_finder: remove_task(task) count = next(counter) entry = [priority, count, task] entry_finder[task] = entry heappush(pq, entry) def remove_task(task): 'Mark an existing task as REMOVED. Raise KeyError if not found.' entry = entry_finder.pop(task) entry[-1] = REMOVED def pop_task(): 'Remove and return the lowest priority task. Raise KeyError if empty.' while pq: priority, count, task = heappop(pq) if task is not REMOVED: del entry_finder[task] return task raise KeyError('pop from an empty priority queue' </code></pre> <p>Which is the most efficient priority queue implementation in python? And how to implement it? </p>
18,494,742
0
<p>you need to <a href="http://qt-project.org/doc/qt-4.8/qobject.html#installEventFilter" rel="nofollow">install an event filter</a>, there is a nice example in documentation. </p>
9,220,667
0
<p>As Diodeus said, <a href="http://seleniumhq.org/" rel="nofollow">Selenium</a> is probably the most popular browser automation library right now (I believe Facebook uses it). Other frameworks you may wish to investigate:</p> <ul> <li><a href="http://watir.com/" rel="nofollow">Watir</a></li> <li><a href="http://www.getwindmill.com/" rel="nofollow">Windmill</a></li> <li><a href="http://sahi.co.in/w/" rel="nofollow">Sahi</a></li> </ul> <p>In addition, you'll want to consider cross-browser testing when setting up an automated suite of tests. You can roll your own for this, or if you'd rather throw money at the problem, <a href="http://www.browserstack.com/automated-browser-testing-api" rel="nofollow">BrowserStack</a> now offers an API that allows your tests to run on a range of browsers.</p>
6,007,932
0
securimage validation <p>hi everyone i am trying to get validate captcha on my form but i would like validation to take place on the form without a change of state. </p> <p>currently the page refreshes to display the error message and the page loses all form values and i can understand that this can be frustrating to users who have to retype the information.</p> <p>how can i get the error message to display right below the captcha image area? this way the user can make the necessary corrections to their mistake without re-entering everything.</p> <pre><code>&lt;?php session_start(); include_once ("resources/Connections/kite.php"); include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php'; $securimage = new Securimage(); ?&gt; &lt;div class="c13"&gt; &lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td width="69%" align="center"&gt;&lt;p class="c6"&gt;New Account&lt;/p&gt; &lt;?php $username = mysql_real_escape_string($_POST['username']); $email = mysql_real_escape_string($_POST['email']); $password = mysql_real_escape_string($_POST['password']); $password = mysql_real_escape_string($_POST['password2']); //check if the form has been submitted if(isset($_POST['submit'])){ if ($securimage-&gt;check($_POST['captcha_code']) == false) { // the code was incorrect // you should handle the error so that the form processor doesn't continue // or you can use the following code if there is no validation or you do not know how echo "The security code entered was incorrect.&lt;br /&gt;&lt;br /&gt;"; echo "Please go &lt;a href='javascript:history.go(-1)'&gt;back&lt;/a&gt; and try again."; } else //success echo '&lt;p class="c7"&gt;Thanks for signing up. We have just sent you an email at &lt;b&gt;'.$email.'&lt;/b&gt;. Please click on the confirmation link within this message to complete registration.&lt;br&gt;&lt;img src="resources/img/spacer.gif" alt="" width="1" height="20"&gt;&lt;br&gt;&lt;span class="c12"&gt; &lt;input name="" type="button" class="c11" value="Register" onClick="location.href=\'main.php\'"/&gt; &lt;/span&gt;&lt;br&gt;&lt;img src="resources/img/spacer.gif" alt="" width="1" height="15"&gt;&lt;/p&gt;&lt;/div&gt;'; include_once ("resources/php/footer.php"); exit; } ?&gt; &lt;p class="c7"&gt;Just enter your details to get started&lt;/p&gt; &lt;div class="c10"&gt; &lt;form action="&lt;?php echo $PHP_SELF;?&gt;" method="post" id="register" name="register"&gt; &lt;table width="100%" border="0" cellpadding="0" cellspacing=""&gt; &lt;tr&gt; &lt;td colspan="3" class="c8" height="25px" valign="bottom"&gt;Username&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="46%"&gt;&lt;/td&gt; &lt;td width="46%"&gt;&lt;/td&gt; &lt;td width="54%" class="c8"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;span id="sprytextfield2"&gt; &lt;input name="username" type="text" class="required"/&gt; &lt;span class="textfieldRequiredMsg"&gt;A value is required.&lt;/span&gt;&lt;span class="textfieldMaxCharsMsg"&gt;Exceeded maximum number of characters.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8" height="25px" valign="bottom"&gt;Email&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="c8"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;span id="sprytextfield3"&gt; &lt;input name="email" type="text" class="required"/&gt; &lt;span class="textfieldRequiredMsg"&gt;A value is required.&lt;/span&gt;&lt;span class="textfieldMaxCharsMsg"&gt;Exceeded maximum number of characters.&lt;/span&gt;&lt;span class="textfieldInvalidFormatMsg"&gt;Invalid format.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8" height="25px" valign="bottom"&gt;Password (minimum of 8 characters)&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="c8"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;span id="sprytextfield4"&gt; &lt;input name="password" type="password" class="required" id="password"/&gt; &lt;span class="textfieldRequiredMsg"&gt;A value is required.&lt;/span&gt;&lt;span class="textfieldMinCharsMsg"&gt;Minimum number of characters not met.&lt;/span&gt;&lt;span class="textfieldMaxCharsMsg"&gt;Exceeded maximum number of characters.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8" height="25px" valign="bottom"&gt;Confirm Password&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td class="c8"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;span id="spryconfirm1"&gt; &lt;input name="password2" type="password" class="required"/&gt; &lt;span class="confirmRequiredMsg"&gt;A value is required.&lt;/span&gt;&lt;span class="confirmInvalidMsg"&gt;The values don't match.&lt;/span&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8" height="25px" valign="bottom"&gt;Enter Code&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;img id="captcha" src="resources/securimage/securimage_show.php" alt="CAPTCHA Image" /&gt;&amp;nbsp; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;input type="text" name="captcha_code" size="10" maxlength="6" /&gt; &lt;a href="#" onclick="document.getElementById('captcha').src = 'resources/securimage/securimage_show.php?' + Math.random(); return false"&gt;Swap image&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;span class="c12"&gt;&lt;img src="resources/img/spacer.gif" width="1" height="40" alt="" /&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" class="c8"&gt;&lt;span class="c12"&gt; &lt;input name="submit" type="submit" class="c11" value="Continue"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/div&gt; &lt;br /&gt;&lt;/td&gt; &lt;td width="31%" valign="middle" align="center"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre>
14,072,639
0
Reading SyndicationFeed in ThreadPool.RunAsync <p>I'm developing a Windows 8 Metro RSS Feed app. Therefore I'm implementing a Background Task to check if new feeds are available and inform the user if so. I do this as follows:</p> <pre><code>public sealed class UpdateCheck : IBackgroundTask { public async void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral backgroundTaskDeferral = taskInstance.GetDeferral(); await StartUpdateCheck(); backgroundTaskDeferral.Complete(); } public IAsyncAction StartUpdateCheck() { return ThreadPool.RunAsync(async o =&gt; { SyndicationClient client = new SyndicationClient(); SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri("http://.../feed.xml")); ApplicationDataContainer applicationDataContainer = ApplicationData.Current.LocalSettings; string lastFeedId = (string) applicationDataContainer.Values["LastFeedId"]; if (lastFeedId != feed.Items.First().Id) { // inform user } }); } } </code></pre> <p>When I'm debugging the code and i want to step over the line <code>SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri("http://.../feed.xml"));</code> by hitting F10, nothing happens. The further code lines don't get executed. So, when i set a breakpoint <em>before</em> the <code>RetrieveFeedAsync</code> method, the breakpoint gets hit. <em>After</em> this line, no breakpoint gets hit.</p> <p>I'm reading the RSS-Feeds on another position in the code, which is not a BackgroundTask (and not in a <code>ThreadPool.RunAsync</code> lambda expression) and there everything works fine, so the <code>ThreadPool.RunAsync</code> method might causes the problem.</p>
12,666,182
0
<p>Math expressions can be very complex, I presume you are referring to arithmetic instead. The normal form (I hope my wording is appropriate) is 'sum of monomials'.</p> <p>Anyway, it's not an easy task to solve generally, and there is an ambiguity in your request: 2 expressions can be syntactically different (i.e. their syntax tree differ) but still have the same value. Obviously this is due to operations that leave unchanged the value, like adding/subtracting 0.</p> <p>From your description, I presume that you are interested in 'evaluated' identity. Then you could normalize both expressions, before comparing for equality.</p> <p>To evaluate syntactical identity, I would remove all parenthesis, 'distributing' factors over addends. The expression become a list of multiplicative terms. Essentially, we get a list of list, that can be sorted without changing the 'value'.</p> <p>After the expression has been flattened, all multiplicative constants must be accumulated. </p> <p>a simplified example:</p> <p><code>a+(b+c)*5</code> will be <code>[[1,a],[b,5],[c,5]]</code> while <code>a+5*(c+b)</code> will be <code>[[1,a],[5,c],[5,b]]</code></p> <p><strong>edit</strong> after some improvement, here is a <em>very</em> essential normalization procedure:</p> <pre><code>:- [library(apply)]. arith_equivalence(E1, E2) :- normalize(E1, N), normalize(E2, N). normalize(E, N) :- distribute(E, D), sortex(D, N). distribute(A, [[1, A]]) :- atom(A). distribute(N, [[1, N]]) :- number(N). distribute(X * Y, L) :- distribute(X, Xn), distribute(Y, Yn), % distribute over factors findall(Mono, (member(Xm, Xn), member(Ym, Yn), append(Xm, Ym, Mono)), L). distribute(X + Y, L) :- distribute(X, Xn), distribute(Y, Yn), append(Xn, Yn, L). sortex(L, R) :- maplist(msort, L, T), maplist(accum, T, A), sumeqfac(A, Z), exclude(zero, Z, S), msort(S, R). accum(T2, [Total|Symbols]) :- include(number, T2, Numbers), foldl(mul, Numbers, 1, Total), exclude(number, T2, Symbols). sumeqfac([[N|F]|Fs], S) :- select([M|F], Fs, Rs), X is N+M, !, sumeqfac([[X|F]|Rs], S). sumeqfac([F|Fs], [F|Rs]) :- sumeqfac(Fs, Rs). sumeqfac([], []). zero([0|_]). mul(X, Y, Z) :- Z is X * Y. </code></pre> <p>Some test:</p> <pre><code>?- arith_equivalence(a+(b+c), (a+c)+b). true . ?- arith_equivalence(a+b*c+0*77, c*b+a*1). true . ?- arith_equivalence(a+a+a, a*3). true . </code></pre> <p>I've used some SWI-Prolog builtin, like include/3, exclude/3, foldl/5, and <a href="http://www.swi-prolog.org/pldoc/doc_for?object=msort/2" rel="nofollow">msort</a>/2 to avoid losing duplicates.</p> <p>These are basic <a href="http://www.swi-prolog.org/pldoc/doc_for?object=section%282,%27A.2%27,swi%28%27/doc/Manual/apply.html%27%29%29" rel="nofollow">list manipulation</a> builtins, easily implemented if your system doesn't have them.</p> <p><strong>edit</strong></p> <p>foldl/4 as defined in SWI-Prolog apply.pl:</p> <pre><code>:- meta_predicate foldl(3, +, +, -). foldl(Goal, List, V0, V) :- foldl_(List, Goal, V0, V). foldl_([], _, V, V). foldl_([H|T], Goal, V0, V) :- call(Goal, H, V0, V1), foldl_(T, Goal, V1, V). </code></pre> <p><strong>handling division</strong></p> <p>Division introduces some complexity, but this should be expected. After all, it introduces a full <em>class</em> of numbers: rationals.</p> <p>Here are the modified predicates, but I think that the code will need much more debug. So I allegate also the 'unit test' of what this micro rewrite system can solve. Also note that I didn't introduce the negation by myself. I hope you can work out any required modification.</p> <pre><code>/* File: arith_equivalence.pl Author: Carlo,,, Created: Oct 3 2012 Purpose: answer to http://stackoverflow.com/q/12665359/874024 How to check if two math expressions are the same? I warned that generalizing could be a though task :) See the edit. */ :- module(arith_equivalence, [arith_equivalence/2, normalize/2, distribute/2, sortex/2 ]). :- [library(apply)]. arith_equivalence(E1, E2) :- normalize(E1, N), normalize(E2, N), !. normalize(E, N) :- distribute(E, D), sortex(D, N). distribute(A, [[1, A]]) :- atom(A). distribute(N, [[N]]) :- number(N). distribute(X * Y, L) :- distribute(X, Xn), distribute(Y, Yn), % distribute over factors findall(Mono, (member(Xm, Xn), member(Ym, Yn), append(Xm, Ym, Mono)), L). distribute(X / Y, L) :- normalize(X, Xn), normalize(Y, Yn), divide(Xn, Yn, L). distribute(X + Y, L) :- distribute(X, Xn), distribute(Y, Yn), append(Xn, Yn, L). sortex(L, R) :- maplist(dsort, L, T), maplist(accum, T, A), sumeqfac(A, Z), exclude(zero, Z, S), msort(S, R). dsort(L, S) :- is_list(L) -&gt; msort(L, S) ; L = S. divide([], _, []). divide([N|Nr], D, [R|Rs]) :- ( N = [Nn|Ns], D = [[Dn|Ds]] -&gt; Q is Nn/Dn, % denominator is monomial remove_common(Ns, Ds, Ar, Br), ( Br = [] -&gt; R = [Q|Ar] ; R = [Q|Ar]/[1|Br] ) ; R = [N/D] % no simplification available ), divide(Nr, D, Rs). remove_common(As, [], As, []) :- !. remove_common([], Bs, [], Bs). remove_common([A|As], Bs, Ar, Br) :- select(A, Bs, Bt), !, remove_common(As, Bt, Ar, Br). remove_common([A|As], Bs, [A|Ar], Br) :- remove_common(As, Bs, Ar, Br). accum(T, [Total|Symbols]) :- partition(number, T, Numbers, Symbols), foldl(mul, Numbers, 1, Total), !. accum(T, T). sumeqfac([[N|F]|Fs], S) :- select([M|F], Fs, Rs), X is N+M, !, sumeqfac([[X|F]|Rs], S). sumeqfac([F|Fs], [F|Rs]) :- sumeqfac(Fs, Rs). sumeqfac([], []). zero([0|_]). mul(X, Y, Z) :- Z is X * Y. :- begin_tests(arith_equivalence). test(1) :- arith_equivalence(a+(b+c), (a+c)+b). test(2) :- arith_equivalence(a+b*c+0*77, c*b+a*1). test(3) :- arith_equivalence(a+a+a, a*3). test(4) :- arith_equivalence((1+1)/x, 2/x). test(5) :- arith_equivalence(1/x+1, (1+x)/x). test(6) :- arith_equivalence((x+a)/(x*x), 1/x + a/(x*x)). :- end_tests(arith_equivalence). </code></pre> <p>running the unit test:</p> <pre><code>?- run_tests(arith_equivalence). % PL-Unit: arith_equivalence ...... done % All 6 tests passed true. </code></pre>
18,413,675
0
<ol> <li>Prepare a dictionary to store the results.</li> <li>Get the numbers of line with data you have using xlrd, then iterate over each of them. </li> <li>For each state code, if it's not <code>in</code> the dict, you create it also as a dict.</li> <li><p>Then you check if the entry you read on the second column exists within the state key on your results dict.</p> <p>4.1 If it does not, you'll create it also as a dict, and add the number found on the second column as a key to this dict, with a value of one.</p> <p>4.2 If it does, just increment the value for that key (+1).</p></li> </ol> <p>Once it has finished looping, your result dict will have the count for each individual entry on each individual state.</p>
31,685,896
0
<p>You can also try and use the center tag and put everything in between.Not the best way, but it works. &lt; center> &lt; /center></p>
11,689,759
0
11,943,350
0
Asynchronous vs Synchronous WebRequest, is it necessary? <p><strong>Background:</strong></p> <p>I am writing a RouteHandler as part of my MVC3 solution. It purpose is to get images and files from my cloud storage and deliver them to the browser while masking the cloud storage urls.</p> <p>So every thing from the "media" sub-domain gets routed to my MediaRouteHandler where I have implemented the logic to get the images.</p> <p>I am struggling to get an asynchronous implementation for the HttpWebRequest. At best it behaves erratically. Sometimes bringing down the images correctly sometimes not.</p> <p><strong>Question:</strong></p> <p>So, my question is.</p> <p>Does a standard browser load images synchronously or asynchronously? Or am I trying to do something that even the browsers don't generally do (and just wasting my time).</p> <p>i.e. If the default way a browser gets an image is from a synchronous thread, then I am happy just doing that. </p> <p>Is that the case?</p> <p>Thanks.</p> <p><strong>A bit of testing:</strong></p> <p>This is the result of my synchronous route handler. You will see that the image requests overlap, and by using fiddler to mimic modem download speeds, I can see them coming down at the same time at different speeds.</p> <p><img src="https://i.stack.imgur.com/hKrHv.jpg" alt="Synchronous Download Speeds"></p>
7,447,069
0
C++, diamond inheritance, where/when do pure virtuals need to be implemented? <p>C++: I have a base class A with a pure virtual function f() and then two classes B and C inherit virtually from A, and a class D that inherits from both B and C (the typical diamond structure):</p> <pre><code> A f() = 0 v/ \v B C \ / D </code></pre> <p>Where and when does f() = 0 need to be implemented in the following cases?</p> <ol> <li>Both B and C have also pure virtual functions (-> do abstract classes <em>must</em> implement inherited pure virtuals?)</li> <li>Only one of them (B XOR C) has a pure virtual function (-> does the other still <em>must</em> implement f()?)</li> <li>Neither B nor C have pure virtuals of their own (-> possible way to skip implementation in B and C and "pass it through" to D?)</li> <li>In which of the three above cases does D need to implement f()? In which cases is it optionally for D to implement f()? In which cases, if any, is it not possible for D to implement f()?</li> </ol> <p>Are there any other common suggestions for these kind of problems?</p> <p>Thanks.</p>
22,297,916
1
Fielding numbers using < and > values <p>So i wish to field these numbers into groups as you can see below, the and is incorrect and wish to know the correct method of doing so.</p> <p>After the "if" the code it assigns the a rating that co-incides with the score and then 1 is added to a counter that counts the number of groups with that rating. </p> <pre><code>#determining the meal rating and counting number of applied ratings and priniting def mealrating(score): for x in range(0,len(score)): if 1 &lt; and score[x] &gt;3: review[x] = poor p = p + 1 if 4 &lt; and score[x] &gt;6: review[x] = good g = g + 1 if 7 &lt; and score[x] &gt;10: review[x] = excellent e = e + 1 print('\n') print('%10s' % ('Poor:', p )) print('%10s' % ('Good', g )) print('%10s' % ('Excellent', e )) </code></pre>
1,023,374
0
<p>NSURLConnection is great for getting a file from the web... It doesn't "wait" per se but its delegate callbacks:</p> <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data - (void)connectionDidFinishLoading:(NSURLConnection *)connection </code></pre> <p>...allow you to be notified when data has been received and when the data has been completely downloaded. This way you can have the App show (if you like) a UIProgressBar as the data comes in and then handle the file as you please when it is completely received. </p>
28,667,150
0
<p>I recommend a lambda (like <a href="http://stackoverflow.com/users/1885037/kaveish">kaveish's</a> <a href="http://stackoverflow.com/a/26770618/309334">answer</a>). But you can have it return a function that checks the appropriate bounds to make everything more readable.</p> <pre><code>auto in = [](int min, int max, char const * const opt_name){ return [opt_name, min, max](unsigned short v){ if(v &lt; min || v &gt; max){ throw opt::validation_error (opt::validation_error::invalid_option_value, opt_name, std::to_string(v)); } }; }; opt::value&lt;unsigned short&gt;()-&gt;default_value(5) -&gt;notifier(in(0, 10, "my_opt")); </code></pre>
36,167,031
0
<p>Ok, I find out why!</p> <p>The 'print_endline' expect a string value, but the function 'String.[n]' returns a char.</p> <p>I just changed the 'print_endline' for 'print_char' and it worked.</p>
5,992,996
0
<p>change</p> <pre><code>void sillyFunction(string * str, int cool){ counter++; if (cool){ for (int i=0; i&lt;counter; i++) cout &lt;&lt; *str &lt;&lt; endl; } else { cout &lt;&lt; *str &lt;&lt; endl; } } </code></pre> <p>to</p> <pre><code>void sillyFunction(const char* str, int cool){ counter++; if (cool){ for (int i=0; i&lt;counter; i++) cout &lt;&lt; str &lt;&lt; endl; } else { cout &lt;&lt; str &lt;&lt; endl; } } </code></pre>
21,594,775
0
code on a jpg image generated dynamically <p>While I was looking for some info, I came across this image on a forum which i didn't understood how it worked. Its a JPG image which actually tells you your ip address and your browser. I think that maybe it was made by modifying htacess and replacing PHP for JPG, and with PHP generating the image dynamically but I'm not sure about it.</p> <p>Would this be the way that this works?</p> <p>Here is the image i saw: <a href="http://www.danasoft.com/sig/475388.jpg" rel="nofollow">http://www.danasoft.com/sig/475388.jpg</a></p> <p>Thanks</p>
24,579,128
0
R slow assignment in setRefClass <p>Perhaps this question should be in some programming forum, but I thought I would ask it in the statistics community. The following code illustrates the problem when performing global assignment in R's setRefClass:</p> <pre><code>class &lt;- setRefClass("class", fields = list( params = "numeric" ), methods = list( initialize = function() { params &lt;&lt;- 5 }, do.stuff = function() { for (i in 1:1e5) params &lt;&lt;- 2 } )) # FAST: params &lt;- 5 time &lt;- Sys.time(); for (i in 1:1e5) params &lt;- 2; time &lt;- Sys.time() - time print(time) # SLOW: newclass &lt;- class$new() time &lt;- Sys.time(); newclass$do.stuff(); time &lt;- Sys.time() - time print(time) </code></pre> <p>And pqR shows a slight improvement in runtime, but nothing drastic.</p> <p>I would like to know why this is happening... in my mind, assigning a variable should be fast. Maybe this has something to do with locating an object "slot" (variable location), similar to S3/S4 classes. I bet I can only observe such behavior with R, and not C++.</p>
35,235,466
0
group by average on a list of objects in C# <p>I have a list of objects where object looks like below</p> <pre><code>public class Sample { public DateTime _dt; public decimal _d; public decimal_value; } </code></pre> <p>I want a list grouped by year and month of a date and _d values with _value averaged.</p> <p>So if for month Jan, list has </p> <pre><code>one set of 31 values with _d =1, one set of 31 values with _d =5 </code></pre> <p>result list of Sample will have two values </p> <pre><code>1/1/2016 ,_d = 1 and average of _value 1/1/2016 ,_d = 5 and average of _value </code></pre>
5,470,141
0
<p>If this is only a timeout error, try putting set_time_limit(xx); on top of your code. With xx corresponding to the time to wait in seconds.</p> <p>Putting 0 means no time limit, but it may be endless if your script enters an infinite loop, of if it is waiting a feedback from your encoding command that never arrives...</p>
32,575,836
0
<p>To clarify.</p> <p><strong>If you want to skip the re-review process, don't update the VERSION ("Bundle versions string, short" in the Info.plist file), update the BUILD ("Bundle version" in the Info.plist file)</strong> </p> <p>so instead of doing <code>0.1 (1) -&gt; 0.2 (1)</code> instead do <code>0.1 (1) -&gt; 0.1 (2)</code></p> <p>Submit your updated build and in iTunes Connect press "Submit for Beta App Review" and then check the box "Build Changes" as a NO.</p>
28,789,665
0
<p>The following samples are all matched.</p> <pre><code>$samples = Array( 'what is 4+3', 'what is 2 plus 7', 'what is 3 * 2', 'what is 3x2', 'what is 4 times 2' ); foreach($samples as $sample) { $sample = preg_replace('/(times)|\*/', 'x', $sample); $sample = str_replace('plus', '+', $sample); preg_match('/what is \d ?[+x] ?\d/', $sample, $matches); var_dump($matches[0]); } </code></pre> <p>A bit nicer in JavaScript. Just including this for the fun of it.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var samples = [ 'what is 4+3', 'what is 2 plus 7', 'what is 3 * 2', 'what is 3x2', 'what is 4 times 2' ]; samples.forEach(function(sample) { sample = sample .replace(/(times)|\*/, 'x') .replace('plus', '+') ; var match = sample.match(/what is \d ?[+x] ?\d/); console.log(match); });</code></pre> </div> </div> </p>
15,175,227
0
ZK methode call when enter pressed <p>I have a textbox in zk. If I pressed tab call the onChanged event. What need I do for call onChange event when press enter? Currently when I press enter not happens anything at all.</p> <pre><code>&lt;textbox id="inputWord" width="200px" apply="com.wb.controlers.WBControler" /&gt; </code></pre> <p>WBControler.java (Extends GenericForwardComposer)</p> <pre><code>public void onChange$inputWord(Event event) throws Exception { Component c = event.getTarget(); if (c instanceof Textbox) { wordTextbox = (Textbox)c; } if (wordTextbox != null) { // do something } } </code></pre> <p>Thanks in advance. </p>
30,384,264
0
PHP, SQL Code not working <p>im ranning into some problems agian, and hope that your guys can help me.</p> <p>I have this code, that i can't get to work.</p> <p>see, the strange thing is, if i change</p> <pre><code>$query2 = mysqli_query($dblogin, "SELECT * FROM devices RIGHT JOIN repair ON devices.name = repair.modelid WHERE repair.modelid=$check"); </code></pre> <p>to</p> <pre><code>$query2 = mysqli_query($dblogin, "SELECT * FROM devices RIGHT JOIN repair ON devices.name = repair.modelid WHERE repair.modelid LIKE %iPad%"); </code></pre> <p>i will work, just fine :-/</p> <p>im really lost, and i tryed, to echo the $check, to see if there was an error in the $check variable. but thats works just fine.</p> <pre><code>&lt;div id="slidingDiv&lt;?=$row["id"] ?&gt;" class="toggleDiv row-fluid single-project"&gt; &lt;div class="span6"&gt; &lt;img src="adm/images/&lt;?=$row["image"] ?&gt;" alt="project &lt;?=$row["id"] ?&gt;" /&gt; &lt;/div&gt; &lt;div class="span6"&gt; &lt;div class="project-description"&gt; &lt;div class="project-title clearfix"&gt; &lt;h3&gt;&lt;?=$row["name"] ?&gt;&lt;/h3&gt; &lt;span class="show_hide close"&gt; &lt;i class="icon-cancel"&gt;&lt;/i&gt; &lt;/span&gt; &lt;/div&gt; &lt;div class="project-info"&gt; &lt;?php $check = $row["name"]; $query2 = mysqli_query($dblogin, "SELECT * FROM devices RIGHT JOIN repair ON devices.name = repair.modelid WHERE repair.modelid=$check"); while($row = mysqli_fetch_assoc($query2)) { ?&gt; &lt;div&gt; &lt;span&gt;&lt;?=$row["price"] ?&gt; ,-&lt;/span&gt;&lt;?=$row["name"] ?&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;div&gt; &lt;span&gt;Client&lt;/span&gt;Some Client Name &lt;/div&gt; &lt;div&gt; &lt;span&gt;Date&lt;/span&gt;July 2013 &lt;/div&gt; &lt;div&gt; &lt;span&gt;Skills&lt;/span&gt;HTML5, CSS3, JavaScript &lt;/div&gt; &lt;div&gt; &lt;span&gt;Link&lt;/span&gt;http://examplecomp.com &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Believe in yourself! Have faith in your abilities! Without a humble but reasonable confidence in your own powers you cannot be successful or happy.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>If i changes it, to this, it runs just fine</p> <pre><code>&lt;? $query = mysqli_query($dblogin, "select * from brands ORDER BY id"); while($row = mysqli_fetch_assoc($query)) { ?&gt; &lt;li class="filter" data-filter="&lt;?=$row["name"] ?&gt;"&gt; &lt;a href="#noAction"&gt;&lt;img class="aimg" style="height:50px;" src="adm/images/&lt;?=$row["image"] ?&gt;" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;? } ?&gt; &lt;/ul&gt; &lt;!-- Start details for portfolio project 1 --&gt; &lt;div id="single-project"&gt; &lt;? $query = mysqli_query($dblogin, "select * from devices ORDER BY name DESC"); while($row = mysqli_fetch_assoc($query)) { ?&gt; &lt;div id="slidingDiv&lt;?=$row["id"] ?&gt;" class="toggleDiv row-fluid single-project"&gt; &lt;div class="span6"&gt; &lt;img src="adm/images/&lt;?=$row["image"] ?&gt;" alt="project &lt;?=$row["id"] ?&gt;" /&gt; &lt;/div&gt; &lt;div class="span6"&gt; &lt;div class="project-description"&gt; &lt;div class="project-title clearfix"&gt; &lt;h3&gt;&lt;?=$row["name"] ?&gt;&lt;/h3&gt; &lt;span class="show_hide close"&gt; &lt;i class="icon-cancel"&gt;&lt;/i&gt; &lt;/span&gt; &lt;/div&gt; &lt;div class="project-info"&gt; &lt;?php $check = $row["name"]; $query2 = mysqli_query($dblogin, "select * from devices right join repair on devices.name = repair.modelid WHERE repair.modelid LIKE '%iPhone 6%'"); while($row = mysqli_fetch_assoc($query2)) { ?&gt; &lt;div&gt; &lt;span&gt;&lt;?=$row["price"] ?&gt; ,-&lt;/span&gt;&lt;?=$row["name"] ?&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;? } ?&gt; </code></pre> <p><strong>EDIT</strong></p> <pre><code>SELECT * FROM devices RIGHT JOIN repair ON devices.name = repair.modelid WHERE repair.modelid LIKE '%iPhone 6%' LIMIT 0 , 30 </code></pre> <p>Gives this result </p> <pre><code>id name brand image model-id id name modelid price brand date 7 iPhone 6 Apple iphone6_small.jpg 217 Front Glas Udskiftning iPhone 6 1300 1432215986 7 iPhone 6 Apple iphone6_small.jpg 218 Bagside (komplet) iPhone 6 2500 1432216016 7 iPhone 6 Apple iphone6_small.jpg 219 Tænd/sluk Udskiftning iPhone 6 500 1432216041 7 iPhone 6 Apple iphone6_small.jpg 220 Homeknap iPhone 6 500 1432216064 7 iPhone 6 Apple iphone6_small.jpg 221 Ørehøjtaler iPhone 6 500 1432216085 7 iPhone 6 Apple iphone6_small.jpg 222 Ladestik iPhone 6 500 1432216107 7 iPhone 6 Apple iphone6_small.jpg 223 Batteri iPhone 6 500 1432216124 7 iPhone 6 Apple iphone6_small.jpg 224 Vibrator iPhone 6 500 1432216136 7 iPhone 6 Apple iphone6_small.jpg 225 Mikrofon iPhone 6 500 1432216165 7 iPhone 6 Apple iphone6_small.jpg 226 Kamera iPhone 6 500 1432216177 7 iPhone 6 Apple iphone6_small.jpg 227 Højtaler (musik/lyd) iPhone 6 500 1432216191 7 iPhone 6 Apple iphone6_small.jpg 228 WIFI Antenne iPhone 6 500 1432218537 7 iPhone 6 Apple iphone6_small.jpg 229 Jackstik iPhone 6 500 1432218564 7 iPhone 6 Apple iphone6_small.jpg 230 Jailbreak iPhone 6 500 1432218593 7 iPhone 6 Apple iphone6_small.jpg 231 Bagside (komplet) iPhone 6 2500 1432218612 </code></pre>
39,848,722
0
<p>You can't use <code>u.name</code> like that. <code>u</code> is just a name that exists in Elixir when compiling the query to SQL. It gets renamed while it is compiled. You need to add another <code>?</code> to <code>fragment</code> and pass <code>u.name</code> for that:</p> <pre><code>def search(query, search_term) do from u in query, where: fragment("to_tsvector(?) @@ plainto_tsquery(?)", u.name, ^search_term), order_by: fragment("ts_rank(to_tsvector(?), plainto_tsquery(?)) DESC", u.name, ^search_term) end </code></pre>
21,142,756
0
Safely push updates to app with a constantly running service <p>I have an app on Google Play that uses a constantly running service to perform a specified task. Due to the nature that it is always running unless the user disables it, this seems to have caused problems with some users when I pushed out my first update. Some users report they must clear the cache a data of the updated app before it works properly, and others must uninstall and reinstall the app completely.</p> <p>Is there a method whereby when users update my app, the old version is completely wiped away, before the new version is installed?</p> <p>Thank you. </p>
10,283,066
0
<p>First of all, if I understood you, for what you want you are going to need jQuery, why? Because javascript doesn't know what CSS properties are affecting to an specific element.</p> <p>Second, the way you are using CSS is not the correct one, you are mixing desing and functionality and for the easiest task like this one you will encounter problems like this one. CSS is not intended to show or hide menus even if you can, CSS is to style things even dinamically but when the user interaction gets involved you are screwed. So be careful :P</p> <p>In jQuery should be something like this:</p> <pre><code>$(document)​.ready(function() { $('ul').on('click', 'li a', function() { $(this.parentElement.parentElement).hide(); }); });​ </code></pre> <p><a href="http://jsfiddle.net/5TBFr/25/" rel="nofollow">http://jsfiddle.net/5TBFr/25/</a></p>
31,573,817
0
Debugger not working in IE 11 F12 developer tools <p>My <kbd>F12</kbd> debugger in IE 11 is not working, it is just showing an empty window. Only the Network tab seems to work.</p> <p>We have been using Firefox until recently, environment changes have forced development to use IE.</p> <p>I've tried it on multiple pages and none are working.</p>
9,242,386
0
difference between output of sproc and functions <p>I have been asked this question in the technical interview.</p> <p>what is the difference between output of stored procedure and a function?</p> <p>Can anybody please explain this?</p>
20,771,147
0
<p>Just add below code in your edit-text</p> <pre><code>android:hint="Your Text"; // XML </code></pre> <p>or even you can set it run time by using following code</p> <pre><code>EditText text = new (EditText) findviewbyid (R.id.text1); text1.setHint("Enter your message here"); </code></pre>
33,730,857
0
Batch-Rename heterogeneous file extensions to one extension <p>I have multiple files each with a different extension in a folder. I need to rename all of them to one extension (.txt).</p> <p><a href="https://i.stack.imgur.com/ScJII.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ScJII.jpg" alt="enter image description here"></a></p> <p>I have tried with the following command:</p> <pre><code>ren *.* "%fname%:~0,-3%.txt" </code></pre> <p>But I receive the following error:</p> <pre><code>A duplicate file name exists, or the file cannot be found. </code></pre> <p>In short I need to convert all files in a folder of miscellaneous types to one type(.txt)</p> <p>Please help. Thanks in Advance</p>
24,805,623
0
<pre><code>$list = ['a', 'b', 'c', 'd', 'e', 'f', '1', '2', '3', '4', '5', '6', '7', '8', '9']; $list2 = []; $c = 0; $temp_array = []; for ($i = 0; $i &lt; Count($list); $i++) { $c++; array_push($temp_array, $list[$i]); if ($c &gt;= 2) { array_push($list2, $temp_array); $temp_array = []; $c = 0; } } print_r($list2); echo '&lt;br /&gt;List2: ' . count($list2) . '&lt;br /&gt;List: ' . count($list); </code></pre> <p><strong>EDIT:</strong> or the solution which Mark Baker provided with the <a href="http://php.net/manual/en/function.array-chunk.php" rel="nofollow">array_chunk()</a> function. It's less code.</p>
25,779,194
0
Stored procedure if record exists then update <p>I'm trying to check if a record exists and then update it if it does</p> <p>Here is what I current have: (Which obviously does not work)</p> <pre><code> CREATE PROCEDURE dbo.update_customer_m @customer_id INT , @firstname VARCHAR(30) , @surname VARCHAR(30) , @gender VARCHAR(6) , @age INT , @address_1 VARCHAR(50) , @address_2 VARCHAR(50) , @city VARCHAR(50) , @phone VARCHAR(10) , @mobile VARCHAR(11) , @email VARCHAR(30) , AS IF EXISTS ( SELECT * FROM dbo.Customer WHERE CustID = @customer_id ) BEGIN UPDATE dbo.Customer SET Firstname = @firstname, Surname = @surname, Age = @age, Gender = @gender, Address1 = @address_1, Address2 = @address_2, City = @city, Phone = @phone, Mobile = @mobile, Email = @email WHERE CustID = @customer_id END </code></pre> <p>Is there a better way of doing this that works?</p>
8,562,314
0
<p>There are 3 types of javascript popups:</p> <ol> <li>Alert - it has only "yes" button</li> <li>Confirmation - it has "yes" as well as "no" buttons</li> <li>Prompt - it has input area to write something and "yes" and "no" buttons</li> </ol> <p>You need to make sure which type of popup is shown and act accordingly.</p>
4,890,324
0
Controlling memory spikes when loading local (Office and iWork) files in UIWebView <p>I am using UIWebView to open local files of Office (ppt, xls, doc) and iWork (numbers, pages, key) formats, all less than 5 MB in size. To load them, I simply do:</p> <pre><code>NSURL *url = [NSURL fileURLWithPath:filepath]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [myWebView loadRequest:requestObj]; </code></pre> <p>When loading some of these files in web view (especially ppts with large number of images in them), the memory usage shoots up to almost 35 MB causing my app to crash. I have looked around various iOS forums but haven't really found a solution. Does using loadData:MIMEType:textEncodingName:baseURL: help in keeping the memory footprint down or are there any other tricks to using UIWebView?</p>
6,465,424
0
<p>does it have to be in MSI ? why not have a batch file (run.bat) and run your msi first followed by your app</p>
9,701,381
0
<p>Look at the Pinax project's <a href="https://github.com/pinax/pinax/blob/master/pinax/apps/account/auth_backends.py" rel="nofollow">account auth_backends </a>, there it replaces with own one. I think Pinax code helps you while changing Django's authentication backend.</p>
25,304,616
0
<p>It was expecting maybe like this</p> <pre><code>RULES_LIST = [ ('Name1', 1, 'Long string upto 40 chars'), ('Name2', 2, 'Long string upto 40 chars'), ('Name3', 3, 'Long string upto 40 chars'), ('Name4', 4, 'Long string upto 40 chars'), ('Name5', 5, 'Long string upto 40 chars'), ('Name6', 6, 'Long string upto 40 chars'), ('Name7', 7, 'Long string upto 40 chars'), ('Name8', 8, 'Long string upto 40 chars') ] </code></pre> <p>the closing square bracket.</p>
520,527
0
Why do some claim that Java's implementation of generics is bad? <p>I've occasionally heard that with generics, Java didn't get it right. (nearest reference, <a href="http://stackoverflow.com/questions/457822/what-are-the-things-java-got-right">here</a>)</p> <p>Pardon my inexperience, but what would have made them better?</p>
18,886,672
0
How do I match the root of a content URI in Android 4.3? <p>I'd like to return some results when someone hits the root of my ContentProvider, which has worked fine up until now. As of Android 4.3, however, I cannot match the root! Here's everything I've tried, and nothing will work. This returns -1 under 4.3, but not under earlier versions.</p> <p>How do I match that URI?</p> <pre><code>private int testMatch(){ UriMatcher mUriMatcher = new UriMatcher(0); mUriMatcher.addURI("com.someone.app.provider.thingy", "/#", 0); mUriMatcher.addURI("com.someone.app.provider.thingy", "/", 1); mUriMatcher.addURI("com.someone.app.provider.thingy", "", 2); mUriMatcher.addURI("com.someone.app.provider.thingy", "/*", 3); mUriMatcher.addURI("com.someone.app.provider.thingy", "#", 4); mUriMatcher.addURI("com.someone.app.provider.thingy", "*", 5); mUriMatcher.addURI("com.someone.app.provider", "thingy", 6); Uri uri=Uri.parse("content://com.someone.app.provider.thingy"); return mUriMatcher.match(uri); } </code></pre>
36,919,775
0
Data Between Two Tables <p>Excuse any novice jibberish I may use to explain my conundrum but hopefully someone here will be able to look past that and provide me with an answer to get me unstuck.</p> <p><strong>SESSIONS</strong></p> <pre><code>+--------+---------+----------+ | id | appID | userID | +--------+---------+----------+ | 1 | 1 | 96 | +--------+---------+----------+ | 2 | 2 | 97 | +--------+---------+----------+ | 3 | 1 | 98 | +--------+---------+----------+ </code></pre> <p><strong>USERS</strong></p> <pre><code>+--------+---------+ | id | name | +--------+---------+ | 96 | Bob | +--------+---------+ | 97 | Tom | +--------+---------+ | 98 | Beth | +--------+---------+ </code></pre> <p>For each session in the Sessions table that has an appID of <code>1</code>, I want to get the users <code>name</code> from the Users table. The Sessions <code>userID</code> column is linked with the Users tables <code>id</code> column. </p> <p>So my desired result would be:</p> <pre><code>["Bob", "Beth"] </code></pre> <p>Any suggestions/help?</p>
23,467,355
0
mobile webpage navigation breaks on focus input type text <p>![enter image description here][1]At the moment i am writing media querys for smartphones. But there occured a strange problem, and i just can´t find anything about it online..</p> <p>So the problem is that My navigation which is</p> <pre><code> position:fixed; top:0; left:0; ... </code></pre> <p>So everything seem to work but when i click on an input field and the mobile keyboard pops up the navigation bar keeps at it current point even if i scroll on.. So it seem the page got kind of "frozen" and the nav does not trigger any new</p> <pre><code> top:0; left:0; </code></pre> <p>Could someone give me a hind how to fix this? ... </p> <p><img src="https://i.stack.imgur.com/Vvnj1.png" alt="Normal fixed top:0; left:0;"></p> <p><img src="https://i.stack.imgur.com/mn7I1.png" alt="when the keyboard occurs the nav stays at it current position _&gt; when you do scroll up now.. the navigationbar will leave the window after a while"></p>
18,266,556
0
<p><a href="http://jsfiddle.net/cse_tushar/JENyF/1" rel="nofollow"><strong>DEMO</strong></a></p> <pre><code>function showValues() { var str = $('#form1').clone(); $.each(str[0], function (i, val) { var str_new = '&lt;pre&gt;' + str[0][i] + '&lt;/pre&gt;'; if (str_new === '&lt;pre&gt;[object HTMLSelectElement]&lt;/pre&gt;') { str[0][i].disabled = 'true'; } }); var str_serialize = str.serialize(); $('#test').text(str_serialize); console.log(str_serialize); } $('#sbt').click(function () { showValues(); }); </code></pre> <p>new <code>var str</code> clone of the <code>form</code> with id <code>form1</code></p> <p>used <code>$.each()</code> to loop around the array of clone variable </p> <p>using <code>'&lt;pre&gt;' + str[0][i] + '&lt;/pre&gt;'</code> these tags it returns like for select tag <code>&lt;pre&gt;[object HTMLSelectElement]&lt;/pre&gt;</code> object type</p> <p>if <code>&lt;pre&gt;[object HTMLSelectElement]&lt;/pre&gt;</code> is matched then i <code>disabled</code> it in the clone</p> <p>in the end i used <code>serialize()</code> to the clone and it worked.</p>
30,176,918
0
handling button click in notification <p>I have got a notification with one Button and I want to do something, when I click the button of the notification. </p> <p>Is there a possibility like <code>OnClickListener</code> to handle that?</p> <p>Here is the code for the notification: </p> <pre><code> private void notification_anzeigen(){ Intent intent = new Intent(this, GestureAnyWhere.class); // String notificationMessage = "GestureAnyWhere läuft im Hintergrund"; // intent.putExtra("NotificationMessage", notificationMessage); // intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); // build notification // the addAction re-use the same intent to keep the example short Notification n = new Notification.Builder(this) .setContentTitle("GestureAnyWhere läuft im Hintergrund") //.setContentText("GestureAnyWhere muss im Hintergrund ausgeführt werden, um Gesten zu erkennen") .setSmallIcon(R.drawable.ic_launcher) // muss rein, ansonsten wird keine Notifikation angezeigt .setContentIntent(pIntent) .addAction(R.drawable.ic_launcher, "Plus-Button", pIntent) .setStyle(new Notification.BigTextStyle().bigText("Auf den Plus-Button drücken, um auf aktueller Seite Gesten zu erkennen")) .setAutoCancel(true).build(); n.setLatestEventInfo(getApplicationContext(), "Plus-Button", "neu", pIntent); NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, n); } </code></pre> <p>Sorry that the question isn't clear. So I try to specifiy it a little bit better:</p> <ul> <li>I have got a background service which starts, when I minimize my application</li> <li>when the service is starting, a new notification will be shown to inform the user, that the application works in background now</li> <li>The background service shall be there in order to detect gestures, which are drawn outside the application </li> <li>When I click onto the notification and the application starts again, the service shall be stoped (otherwise I can draw inside my application and not click onto something anymore) -> so that is the first point I want to do: stop a background service, when I click onto the notification </li> <li>When I mimimize my application and start the service I am only able to draw onto the homescreen right now -> so that is the second point I want to do: when the user click onto a button under the notification an Activity shall be called in order that the user could draw on the current View</li> </ul> <p>Because I only want to know how a click onto a notification (or a Button under the notification) is handled in generally I don't provide the code for the service and all other stuff. </p> <p>I hope the question and what I want to do is a little bit clearer. </p> <p>Thanks a lot. </p>
16,714,469
0
How to cleanup an SVN checkout with lots of locks in externals <p>At the moment <code>svn cleanup</code> doesn't go into externals according to this <a href="http://subversion.tigris.org/issues/show_bug.cgi?id=2325" rel="nofollow">bug</a>. What's the best way to remove all the checkout locks from a project and all it's externals?</p>
22,647,715
0
<p>This is a synchronous request. Try using the below code to this the server synchronously. At least this will make sure everything is running fine. responseData can be written in a file to see the response.</p> <pre><code>NSURL *url = [NSURL URLWithString:@"http://127.0.0.1:8080/Jersey/rest/hello"]; NSURLResponse *urlResponse = nil; NSData *responseData = nil; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; [request addValue:@"text/html; charset=UTF-8" forHTTPHeaderField:@"Content-Type"]; responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;urlResponse error:&amp;theError]; </code></pre>
39,898,196
0
<pre><code>&lt;?php $Student = array(array("Adam",10,10,10), array("Ricky",10,11,10), array("Bret",15,14,10), array("Ram",14,17,10) ); for($i=0;$i&lt;=3;$i++){ for($j=0;$j&lt;=3;$j++){ print_r($Student[$i][$j]); echo "&lt;br&gt;"; } } ?&gt; </code></pre>
36,640,380
0
How to make my android app downloadable from Facebook page <p>I am making one android app and I want to post one advertisement on Facebook page that will have one video regarding my app and a link to download my android app. The user should be able to see the advertisement with video and if he wish to download my android app then after click on given link it should go to Play Store and will be able to download the app.</p> <p>Anyone please help me to do this. How I can do this ?. I don't have any idea.</p> <p>Thanks in advance.</p>
19,974,279
0
<p>no there isn't ready made code. we wrote our own solution and I know of a few other ones.. the MAP you use really doesn't matter.</p> <p>the grouping can happen 'on the model'</p>
30,620,268
0
<p>I think that you can not do a release of a project which depends on projects in Snapshot version.</p> <p>Maybe this could help to configure your pom.xml</p> <p><a href="http://stackoverflow.com/questions/245932/how-to-release-a-project-which-depends-on-a-3rd-party-snapshot-project-in-maven">how to release a project which depends on a 3rd party SNAPSHOT project in maven</a></p>
37,397,863
0
<p>Accordion behavior is dependent on the <code>panel</code> class (<a href="http://getbootstrap.com/javascript/#collapse-options" rel="nofollow">http://getbootstrap.com/javascript/#collapse-options</a>). So the immediate child of the parent <code>#sidebar-admin</code> must be a <code>.panel</code>..</p> <p><a href="http://www.codeply.com/go/Zq1utEY3dV" rel="nofollow">http://www.codeply.com/go/Zq1utEY3dV</a></p> <pre><code>&lt;ul id="sidebar-admin" class="nav collapse"&gt; &lt;li class="panel"&gt; &lt;a class="users collapsed sidebar-subparent" data-toggle="collapse" data-parent="#sidebar-admin" href="#sidebar-users"&gt; &amp;nbsp; &amp;nbsp;&lt;i class="fa fa-user" style="margin-right: 15px; margin-left: 2px;"&gt;&lt;/i&gt;Users&lt;/a&gt; &lt;ul id="sidebar-users" class="nav collapse"&gt; &lt;li class="sidebar-element"&gt; ... </code></pre>
22,078,275
0
Second prepared statement is not firing <p>thanks for your time.</p> <p>Below I have two prepared statements, query &amp; query2;</p> <p>con is the connection var</p> <p>The first query is running perfectly and updating the database.</p> <p>The second query is not updating anything, although it is not giving any error.</p> <p>When I look at the second query that is logged after a "successful" run, the inserted variable is looking like an empty string. i.e. <code>RESTI</code>=''</p> <p>Why is this happening? Is my code in the right order for the second query to run?</p> <pre><code>$row = 1; $con=mysqli_connect("connect info"); if (mysqli_connect_errno()) { //echo "Failed to connect to MySQL Error 1: " . mysqli_connect_error(); //error reporting done here } else { $con-&gt;autocommit(false); $query = $con-&gt;prepare("UPDATE table where `INDEX`=?"); $query2 = $con-&gt;prepare("UPDATE table2 where (SELECT column from table where`RESTI`=?)"); $query-&gt;bind_param('i', $row); $query2-&gt;bind_param('i', $row); if($query-&gt;execute() == false) { //Failed! /ERROR HANDLING } else { //SUCCESS } if($query2-&gt;execute() == false) { //Failed! /ERROR HANDLING } else { //Success } $con-&gt;commit(); $query-&gt;close(); $query-&gt;close(); } mysqli_close($con); </code></pre>
31,296,857
0
unsorted matrix search algorithm <p>is there a suitable algorithm that allows a program to search through an unsorted matrix in search of the biggest prime number within. The matrix is of size m*n and may be populated with other prime numbers and non-primes. The search must find the biggest prime.</p> <p>I have studied the divide and conquer algorithms, and binary trees, and step-wise searches, but all of these deal with sorted matrices. </p>
1,050,683
0
<p>One possible solution would be to simply hide the <code>SiteMapPath</code> control on the home page:</p> <pre><code>mySiteMapPath.Visible = (SiteMap.CurrentNode != SiteMap.RootNode); </code></pre>
33,399,655
0
<p>Your question seems unclear, but I suppose that you are asking how to load another layout/activity/fragment by clicking on a button.</p> <p>Well, it depends on which of the three actions you want to do:</p> <p>1) in order to load another layout, you need to inflate the new layout in your view; in order to do that you need to clear the actual layout and inflate the new one. Here's some sample code:</p> <pre><code>//you may change it to whichever layout you used LinearLayout ll = (LinearLayout) findViewById(R.id.mainLayout); //remove previous view ll.removeAllViews(); //set the new view setContentView(R.layout.new_layout); </code></pre> <p>2) in case you want to start a new activity, you need to use a Intent and load it. Sample code:</p> <pre><code>//create the new intent; it will refer to the new activity Intent intent = new Intent(this, NewActivity.class); //pass any data to the new activity; cancel this line if you don't need it intent.putExtra(extra_title, extra) //start the new activity startActivity(intent); </code></pre> <p>3) in case you want to change fragment, you need to perform a transaction. Sample code:</p> <pre><code>//create the new fragment Fragment newFragment = new MyFragment(); //start a fragment transaction FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); //replace the old fragment with the new transaction.replace(R.id.frame, newFragment).commit(); </code></pre> <p>Hope this helps; if not, try to edit your question in order to clarify what you mean.</p> <hr> <p><strong>EDIT:</strong></p> <p>You should add a new OnClickListener to each button, but I would do it differently than you are doing right now. I would do something like this sample code:</p> <pre><code>buttonWRGL.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(this, NewActivity1.class); startActivity(intent); } }); </code></pre> <p>For each button. In this code, I directly attach a specific OnClickListener to the button; it will contain the intent that you need. You can copy this in every button, even 10k buttons, you just need to change the activity name inside the intent declaration with the activity that you want to launch.</p>
26,119,309
0
<p>A validation is a check that the value entered is legitimate for the context of its field (from technical perspective), for example: is 5 as a numeric value acceptable for Age(v.s. -5)?, while -5 is acceptable as Temperature for example.</p> <p>The business rule is more of a business perspective. It is a check that the values (that passed the validation) are acceptable by the policies and procedures of the business. E.g. the person who is allowed to register has to be a resident, and 18 years old or more..etc. The business rule might check one (or more) field(s) value(s), and might consult data stored in a database and/or do some calculation(s) to ensure that the value(s) pass the business rules.</p> <p>So, for the example posted above by hanna, the value 15 should pass the field validation (as it is a valid value for Age), but it will not pass the business rule check that the married person's age must be >15.</p>
36,315,968
0
<p>You are using the aws-sdk, good, I'll hit you with the se.file.read equivalent then: <a href="http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Object.html#get-instance_method" rel="nofollow"><code>Aws::S3::Object#get</code></a>.</p> <pre><code># create your bucket first s3_file = bucket.object['myfile.txt'].get({response_target: '/tmp/myfile.txt'}) </code></pre> <p>I think you can then do <code>s3_file.body</code>.</p> <p>Lastly, you are re-inventing the wheel and should check-out <a href="https://github.com/sorentwo/carrierwave-aws" rel="nofollow">carrierwave with aws-sdk</a>.</p>
38,555,411
0
Drag and Drop Custom Control Isn't working <p>I have built a custom <code>ListView</code> to allow me to drag and drop. with some help from other questions and blog post i have gotten this far. </p> <p>I am using <code>MVVM</code> in the implementation of the <code>UserControl</code> but while building the actual Custom <code>ListView</code> i am just using the code behind. as i thought this would be easier.</p> <p>How can I implement code below to get to add to ViewModel ICollection?</p> <p><strong>update:</strong></p> <p>please note that I think that the reason this is happening is because I am trying to add an <code>object</code> to <code>ObservableCollection&lt;person&gt;()</code>;</p> <p>exception:</p> <blockquote> <p>Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.</p> </blockquote> <p>XAML: Implementation:</p> <pre><code>&lt;controls:DragNDropListView x:Name="ListView" ItemsSource="{Binding Persons}" DragDropEffects="Copy" DisplayMemberPath="Name"&gt;&lt;/controls:DragNDropListView&gt; &lt;controls:DragNDropListView x:Name="ListView1" Grid.Column="1" ItemsSource="{Binding Persons1}" DisplayMemberPath="Name" DragDropEffects="Copy"/&gt; </code></pre> <p>ViewModel:</p> <pre><code>public class ViewModel { public ViewModel() { Persons = new ObservableCollection&lt;Person&gt;(); Persons1 = new ObservableCollection&lt;Person&gt;(); Persons.Clear(); Persons1.Clear(); foreach (var person in Data.People().ToList()) { Persons.Add(person); Persons1.Add(person); } } public ObservableCollection&lt;Person&gt; Persons { get; set; } public ObservableCollection&lt;Person&gt; Persons1 { get; set; } } </code></pre> <p>Drag code:</p> <pre><code>private void OnMouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = _startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed &amp;&amp; (Math.Abs(diff.X) &gt; SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) &gt; SystemParameters.MinimumVerticalDragDistance)) { if (ListView != null) { ListViewItem listViewItem = FindAnchestor&lt;ListViewItem&gt;((DependencyObject)e.OriginalSource); if (listViewItem != null) { var item = ListView.ItemContainerGenerator.ItemFromContainer(listViewItem); //NOTE:this is an object not a Person like observeablecollection in ViewModel. DataObject dragData = new DataObject("myFormat", item); DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects); } } } } </code></pre> <p>Drop code that is throwing exception:</p> <pre><code>private void OnDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("myFormat")) { var item = e.Data.GetData("myFormat"); if (item != null) { Items.Add(item);//this is where it throws exception } } } </code></pre>
291,881
0
<p>There are two separate issues to consider.</p> <p>To begin, it is quite common when using an ORM for the table and the object to have quite different "shapes", this is one reason why many ORM tools support quite complex mappings. </p> <p>A good example is when a table is partially denormalised, with columns containing redundant information (often, this is done to improve query or reporting performance). When this occurs, it is more efficient for the ORM to request just the columns it requires, than to have all the extra columns brought back and ignored.</p> <p>The question of why "Select *" is evil is separate, and the answer falls into two halves.</p> <p>When executing "select *" the database server has no obligation to return the columns in any particular order, and in fact could reasonably return the columns in a different order every time, though almost no databases do this. </p> <p>Problem is, when a typical developer observes that the columns returned seem to be in a consistent order, the assumption is made that the columns will <strong>always</strong> be in that order, and then you have code making unwarranted assumptions, just waiting to fail. Worse, that failure may not be fatal, but may simply involve, say, using <em>Year of Birth</em> in place of <em>Account Balance</em>.</p> <p>The other issue with "Select *" revolves around table ownership - in many large companies, the DBA controls the schema, and makes changes as required by major systems. If your tool is executing "select *" then you only get the current columns - if the DBA has removed a redundant column that you need, you get no error, and your code may blunder ahead causing all sorts of damage. By explicitly requesting the fields you require, you ensure that your system will break rather than process the wrong information.</p>
14,778,895
0
<p>There are a set of several templates that control the checkout page. They can be found in the WooCommerce plugin folder in templates/checkout.</p> <p>You can put a woocommerce/templates/checkout folder inside your theme's folder and copy the templates you want to alter into it. Those will override the normal templates without altering the plugin itself. That way your changes won't get overwritten when WooCommerce is updated.</p>
6,878,662
0
Tumblr API - how to upload multiple images to a Photoset <p>I am able to upload one picture but I can't create a photoset with multiple images using API.</p> <p>Documentation says: Paramater: Array (URL-encoded binary contents)</p> <p>One or more image files (submit multiple times to create a slide show)</p> <p>Does anyone know how to do it?</p>
37,273,675
0
<p>I've taken a look at the site and it seems to work fine on my Nexus 6. So I believe it may be an issue with Safari. </p> <p>You do seem to have some errors on the page that may be causing issues with Safari. </p> <p>Follow this link to find and fix them: <a href="https://validator.w3.org/check?uri=http%3A%2F%2Ffkrtestsite.byethost3.com%2Findex.html&amp;charset=%28detect+automatically%29&amp;doctype=Inline&amp;group=0" rel="nofollow">https://validator.w3.org/check?uri=http%3A%2F%2Ffkrtestsite.byethost3.com%2Findex.html&amp;charset=%28detect+automatically%29&amp;doctype=Inline&amp;group=0</a> </p>
31,014,241
0
<p>You can do this with </p> <pre><code>+ (NSArray&lt;ObjectType&gt; * nullable)arrayWithContentsOfFile:(NSString * nonnull)aPath </code></pre> <p>and </p> <pre><code>- (BOOL)writeToFile:(NSString * nonnull)path atomically:(BOOL)flag </code></pre>
17,207,745
0
<p>First, you need to <code>Authenticate</code> your request (Get permission).</p> <p>second, see follow these steps:</p> <p>1.Download <code>FHSTwitterEngine</code> Twitter Library.</p> <p>2.Add the folder <code>FHSTwitterEngine</code>" to your project and <code>#import "FHSTwitterEngine.h".</code></p> <p>3.add <code>SystemConfiguration.framework</code> to your project.</p> <blockquote> <p>Usage : 1.in the <code>[ViewDidLoad]</code> add the following code.</p> </blockquote> <pre><code>UIButton *logIn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; logIn.frame = CGRectMake(100, 100, 100, 100); [logIn setTitle:@"Login" forState:UIControlStateNormal]; [logIn addTarget:self action:@selector(showLoginWindow:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:logIn]; [[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"&lt;consumer_key&gt;" andSecret:@"&lt;consumer_secret&gt;"]; [[FHSTwitterEngine sharedEngine]setDelegate:self]; and don't forget to import the delegate FHSTwitterEngineAccessTokenDelegate. you need to get the permission for your request, with the following method which will present Login window: - (void)showLoginWindow:(id)sender { [[FHSTwitterEngine sharedEngine]showOAuthLoginControllerFromViewController:self withCompletion:^(BOOL success) { NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!"); }]; } </code></pre> <p>when the Login window is presented, enter your <code>Twitter</code> Username and Password to authenticate your request.</p> <p>add the following methods to your code:</p> <pre><code>-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[FHSTwitterEngine sharedEngine]loadAccessToken]; NSString *username = [[FHSTwitterEngine sharedEngine]loggedInUsername];// self.engine.loggedInUsername; if (username.length &gt; 0) { lbl.text = [NSString stringWithFormat:@"Logged in as %@",username]; [self listResults]; } else { lbl.text = @"You are not logged in."; } } - (void)storeAccessToken:(NSString *)accessToken { [[NSUserDefaults standardUserDefaults]setObject:accessToken forKey:@"SavedAccessHTTPBody"]; } - (NSString *)loadAccessToken { return [[NSUserDefaults standardUserDefaults]objectForKey:@"SavedAccessHTTPBody"]; } 4.Now you are ready to get your request, with the following method(in this method I created a `Twitter` search for some `Hashtag`, to get the screen_name for example): - (void)listResults { dispatch_async(GCDBackgroundThread, ^{ @autoreleasepool { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; // the following line contains a FHSTwitterEngine method wich do the search. dict = [[FHSTwitterEngine sharedEngine]searchTweetsWithQuery:@"#iOS" count:100 resultType:FHSTwitterEngineResultTypeRecent unil:nil sinceID:nil maxID:nil]; // NSLog(@"%@",dict); NSArray *results = [dict objectForKey:@"statuses"]; // NSLog(@"array text = %@",results); for (NSDictionary *item in results) { NSLog(@"text == %@",[item objectForKey:@"text"]); NSLog(@"name == %@",[[item objectForKey:@"user"]objectForKey:@"name"]); NSLog(@"screen name == %@",[[item objectForKey:@"user"]objectForKey:@"screen_name"]); NSLog(@"pic == %@",[[item objectForKey:@"user"]objectForKey:@"profile_image_url_https"]); } dispatch_sync(GCDMainThread, ^{ @autoreleasepool { UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"Complete!" message:@"Your list of followers has been fetched" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [av show]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; } }); } }); } </code></pre> <p>That's all. I just got the <code>screen_name</code> from a <code>search Query</code>, you can get a timeline for a user using the following methods:</p> <pre><code>// statuses/user_timeline - (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count; - (id)getTimelineForUser:(NSString *)user isID:(BOOL)isID count:(int)count sinceID:(NSString *)sinceID maxID:(NSString *)maxID; </code></pre> <p>instead of the search method above.</p> <blockquote> <p>Note: see the <code>FHSTwitterEngine.h</code> to know what method you need to use. Note: to get the <code>&lt;consumer_key&gt;</code> and the <code>&lt;consumer_secret&gt;</code> you need to to visit this link to <code>register</code> your app in <code>Twitter</code>.</p> </blockquote>
11,198,518
0
<p>I ran into the same problem in Drupal 6 recently, and your question is valid. </p> <p>When I displayed the $form object (from <em>template.php</em>) using <a href="http://drupal.org/project/devel" rel="nofollow">Devel</a>'s dsm() function, I found that the buttons were somehow showing a weight of 0.0111, a float.</p> <p>The <strong>hook_theme()</strong> and then <strong>hook_form()</strong> in <em>template.php</em> seem to be behaving wrong. Using hook_form I made no changes to the $form object, and returning drupal_render($form) the Save/Preview buttons were at the top.</p> <p>To anyone that needs to use these hooks, you must ALSO create a <strong>form_alter</strong> where you set the weight of the buttons. This counteracts the bug and gets your buttons to the bottom again.</p> <pre><code> $form['buttons']['#weight'] = 100; </code></pre> <p>Note: I could not set the weight in my <strong>hook_form()</strong> code, it had to be in a <strong>form_alter</strong></p>
9,062,660
0
<p>Used <a href="http://valums.com/ajax-upload/" rel="nofollow">Ajax upload</a> it worked. But it calls the controller as soon as file is selected. </p>
34,525,971
0
<p>The first seed node is special, as documented in the Cluster documentation: <a href="http://doc.akka.io/docs/akka/snapshot/java/cluster-usage.html" rel="nofollow">http://doc.akka.io/docs/akka/snapshot/java/cluster-usage.html</a></p> <p>It must be the same 1st configured node on all nodes, in order for all of them to be really sure that they join the same cluster.</p> <p>Quote:</p> <p>The seed nodes can be started in any order and it is not necessary to have all seed nodes running, but the node configured as the first element in the seed-nodes configuration list must be started when initially starting a cluster, otherwise the other seed-nodes will not become initialized and no other node can join the cluster. <strong>The reason for the special first seed node is to avoid forming separated islands when starting from an empty cluster.</strong> It is quickest to start all configured seed nodes at the same time (order doesn't matter), otherwise it can take up to the configured seed-node-timeout until the nodes can join.</p> <p>Once more than two seed nodes have been started it is no problem to shut down the first seed node. If the first seed node is restarted, it will first try to join the other seed nodes in the existing cluster.</p>
28,151,627
0
<p>You could convert to a <a href="http://www.mathworks.com/help/matlab/ref/datenum.html?refresh=true" rel="nofollow"><code>datenum</code></a>:</p> <pre><code>tdiff = datenum(sample.tend) - datenum(sample.tstart) </code></pre> <p>remebering that as <a href="http://www.mathworks.com/help/matlab/ref/datenum.html?refresh=true" rel="nofollow">the docs</a> say:</p> <blockquote> <p>A serial date number represents the whole and fractional number of days from a fixed, preset date (January 0, 0000).</p> </blockquote> <p>so <code>tdiff</code> will be in units of days which is then simple to covert to hours or seconds or whatever you're after. For example to covert to seconds:</p> <pre><code>SecondsPerDay = 24*60*60; tdiffs = tdiff*SecondsPerDay; </code></pre>
32,132,281
0
<pre><code>tableView.addPullToRefreshWithActionHandler { } </code></pre>
26,739,299
0
Rails - How can I display one nested attributes (Solved) <p>I have a new problem, I Create a web where I upload many images, using nested attributes and polymorphic table, in my index.html I want to show only one image, but I can't find how. But I'm new in rails. </p> <p>photography.rb</p> <pre><code>class Photography &lt; ActiveRecord::Base validates :title, :description, presence: true belongs_to :user has_many :images, as: :imageable, dependent: :destroy accepts_nested_attributes_for :images, :reject_if =&gt; lambda { |a| a[:img_str].blank? }, :allow_destroy =&gt; true end </code></pre> <p>image.rb</p> <pre><code>class Image &lt; ActiveRecord::Base belongs_to :imageable, polymorphic: true mount_uploader :img_str, AssetUploader end </code></pre> <p>index.html.erb</p> <pre><code>&lt;% for photo in @photo %&gt; &lt;%= link_to photo.title, photography_path(photo) %&gt; &lt;% photo.images.each do |images| %&gt; &lt;%= images.img_str %&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p>With the for method I show all the image, try add .first, but says <code>undefined method first for 5:Fixnum.</code> I think that I have to create a helper method, but I not sure. Can anyone help me?. Thanks</p>
5,713,435
0
<p><a href="http://cslibrary.stanford.edu/" rel="nofollow">http://cslibrary.stanford.edu/</a> is the best resource that I have come across to learn about pointers in C . Read all the pointer related pdfs and also watch the binky pointer video.</p>
26,860,019
0
Assigning Value to Two Dimension Array <p>I am trying to assign values to a 2D array in VBA but its not working. Here is what I have tried: </p> <pre><code>Sub UpdateCustomName() Dim CellTags() As String Dim temp() As String Dim ControlName As String Dim CellValue As String Dim CustomName(1 To 2, 1 To 2) As String For Each Cell In ActiveSheet.UsedRange.Cells If Not Cell.Value = "" Then CellTags() = Split(Cell.Value, "*") ' here in CellTags(2) value is like ABC_E34 CustomName() = Split(CellTags(2), "_") MsgBox CustomName(1, 2) End If Next End Sub </code></pre>
3,805,369
0
<p>The <code>Array.Clear</code> method will let you clear (set to default value) all elements in a multi-dimensional array (i.e., <code>int[,]</code>). So if you just want to clear the array, you can write <code>Array.Clear(myArray, 0, myArray.Length);</code></p> <p>There doesn't appear to be any method that will set all of the elements of an array to an arbitrary value.</p> <p>Note that if you used that for a jagged array (i.e. <code>int[][]</code>), you'd end up with an array of null references to arrays. That is, if you wrote:</p> <pre><code>int[][] myArray; // do some stuff to initialize the array // now clear the array Array.Clear(myArray, 0, myArray.Length); </code></pre> <p>Then <code>myArray[0]</code> would be <code>null</code>.</p>
5,664,984
0
<p><strong>Not call reloadData from <code>shouldAutorotateToInterfaceOrientation</code>:</strong></p> <p>Use the UIView <code>autoresizingMask</code> property for both <code>UITableView</code> and <code>UITableViewCell</code> when you create the object for both . because <code>UITableView and</code>UITableViewCell<code>are the subclass of</code>UIView`.</p> <pre><code>@property(nonatomic) UIViewAutoresizing autoresizingMask </code></pre>
2,675,350
0
Searchengine bots and meta refresh for disabled Javascript <p>I have a website that must have javascript turned on so it can work</p> <p>there is a &lt; noscript> tag that have a meta to redirect the user to a page that alerts him about the disabled javascript... </p> <p>I am wondering, is this a bad thing for search engine crawlers?<br> Because I send an e-mail to myself when someone doesn't have js so I can analyze if its necessary to rebuild the website for these people, but its 100% js activated and the only ones that doesn't have JS are searchengines crawlers... I guess google, yahoo etc doesn't take the meta refresh seriously when inside a &lt; noscript> ?</p> <p>Should I do something to check if they are bots and do not redirect them with meta?</p> <p>Thanks,<br> Joe</p>
2,264,261
0
<p>Depends on your requirements and the design for such a site. Either come up with a design and then see if it would fit on GAE. Else, design it such that it fits into GAE. If one of your requirement is scalability then GAE promises that</p>
13,083,638
0
how to assign null to a field in sqlite <p>I would like to assign <code>null</code> to a field in SQLite but am not getting anywhere with this:</p> <pre><code>update t set n=null where n=0; </code></pre>
29,452,795
0
<pre><code>setlocal enabledelayedexpansion for /l %%b in (1,1,%num%) do echo !line%%b!&gt;&gt;file.txt </code></pre> <p>Or if you don't want to use delayed expansion:</p> <pre><code>for /l %%b in (1,1,%num%) do echo %%line%%b%%&gt;&gt;file.txt </code></pre>
10,442,455
0
<p>I have a <a href="https://github.com/ehrmann/vcdiff-java" rel="nofollow" title="vcdiff-java">Java port of open-vcdiff</a> on Github. It's tested against open-vcdiff, but it's not used in production anywhere.</p>
25,607,078
0
<p>After updating point, format is changed from <code>[x_value, y_value]</code> to: <code>{x: x_value, y: y_value}</code>. So instead of <code>c[1]</code>, use <code>c.y</code> for updated points. Since both formats are used you need to check which one is use.</p>
15,793,680
0
ObjectContext not adding an entity <p>I'm adding an entity to the object context like this</p> <pre><code>public partial class MyEntities : ObjectContext . . . </code></pre> <p>In a different class I've the following code</p> <pre><code>using (MyEntities dbContext = new MyEntities()) { Info x = new Info(); dbContext.AddToInfo(x); } </code></pre> <p>However when I check the entities in Info in 'dbContext' after adding 'x' to it the watch say that dbContext.Info 'Enumeration yielded no results'.</p> <p>Here's a screenshot of the Watch window</p> <p><img src="https://i.stack.imgur.com/iS8Kv.png" alt="VS Watch Window"></p> <p>Why is this happening?</p>
28,058,285
0
<p>I'm not sure why you are trying to get that string since to my knowledge most ssl functions will take the whole cert to verify. </p> <p>Have you seen <a href="http://stackoverflow.com/a/27251088/4474526">this post</a>? It looks like what you want.</p> <p>Hope that helps.</p> <p>EDIT:</p> <p>I <a href="https://www.v13.gr/blog/?p=303" rel="nofollow">think</a> this example will help you understand what's every argument and in what format should it be. </p>
1,441,116
0
<p>Connecting to FTP really causes some headache for me. I do not know if the following link is useful. I happen to see it.</p> <p><a href="http://attractivechaos.wordpress.com/2009/08/02/read-files-on-ftphttp/" rel="nofollow noreferrer">http://attractivechaos.wordpress.com/2009/08/02/read-files-on-ftphttp/</a></p> <p>The program does not seem too long. Hope helpful to you.</p>
32,775,480
0
Get commits that have been *created* on a specific branch <p>Is there a (relatively simple) way to <em>only</em> get the commits corresponding to asterisks (*) on the <code>release</code> (left-most, marked by red frame) branch in this real-world example of a commit history?</p> <p><a href="https://i.stack.imgur.com/bwaLB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bwaLB.png" alt="enter image description here"></a></p> <p>The given set of commits are all high-risk commits (i.e. commits that are exposed to the public). There can only be two kinds of commits on the <code>release</code> (and/or <code>master</code>) branch(es):</p> <ol> <li>Actual releases (usually tagged, big merges)</li> <li>Hotfixes (usually un-tagged, small merges)</li> </ol> <p>My goal: I want to create statistics and small analytical tools that use these commits to help us (and especially our developers) to better understand high-risk code regions and possible bug patterns. I am also convinced that this can eventually be used to help us better estimate risk for the company and evaluate QA efficiency.</p> <p>Any suggestions?</p> <p>PS: This graph has been created with <code>git log --oneline --decorate --graph</code>, but I cut all sensitive information from it.</p>
4,300,134
0
<p>Looking away from the details of specific implementations of functional programming, I see two key issues:</p> <ol> <li><p>It seems comparatively rare that it is practical to choose a functional model of some real-world problem over an imperative one. When the problem domain is imperative, using a language with that characteristic is a natural and reasonable choice (since it is in general advisable to minimize the distance between the specification and implementation as part of reducing the number of subtle bugs). Yes, this can be overcome by a smart-enough coder, but if you need Rock Star Coders for the task, it's because it's too bloody hard.</p></li> <li><p>For some reason that I never really understood, functional programming languages (or perhaps their implementations or communities?) are much more likely to want to have everything in their language. There's much less use of libraries written in other languages. If someone else has a particularly good implementation of some complex operation, it makes much more sense to use that instead of making your own. I suspect that this is in part a consequence of the use of complex runtimes which make handling foreign code (and especially doing it efficiently) rather difficult. I'd love to be proved wrong on this point.</p></li> </ol> <p>I suppose these both come back to a general lack of pragmatism caused by functional programming being much more strongly used by programming researchers than common coders. A good tool can enable an expert to great things, but a great tool is one that enables the common man to approach what an expert can do normally, because that's by far the more difficult task.</p>
997,146
0
<p>Web aps follow a request-response architecture so you can't really (well, easily) have server initiated messages from client to server.</p> <p>You can use a polling architecture. At its very simplest, you could simply have the page refresh every X seconds/minutes to check for changes. This may be a bit ugly.</p> <p>A more user friendly approach might be to use the XMLHTTP object to poll for changes every few seconds and refresh the page when a change is detected. You could create an HTTP Handler on the server side that simply have the date/time of last change and have a javascript check this every few seconds and when a change occurrs, refresh the page.</p>