pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
32,670,160
0
<p>The symbol <code>&amp;</code> is the <code>and</code> logical operator. You can use it for multiple conditions in your <code>while</code> loop.</p> <pre><code>while (user_input ~= 256 &amp; user_input ~= 128 &amp; user_input ~= 64) prompt = 'Please enter one of the listed gray levels (256, 128, 64, 32, 16, 8, 4, 2). '; user_input = input(prompt); end </code></pre> <p>As beaker pointed out, what you ask is to ask for input as long as it is not one of the following values : 256, 128 or 64. Using the <code>or</code> logical operator would mean that <code>user_input</code> should be 256, 128 and 64 at the same time to break the loop.</p> <hr> <p>You can also use <a href="http://fr.mathworks.com/help/matlab/ref/ismember.html" rel="nofollow"><code>ismember</code></a>.</p> <pre><code>conditionnal_values = [256, 128 , 64] while ~ismember(user_input, conditionnal_values) prompt = 'Please enter one of the listed gray levels (256, 128, 64, 32, 16, 8, 4, 2). '; user_input = input(prompt); end </code></pre> <hr> <p>An other way to go, proposed by Luis Mendo, is to use <a href="http://fr.mathworks.com/help/matlab/ref/any.html" rel="nofollow"><code>any</code></a></p> <pre><code>conditionnal_values = [256, 128 , 64] while ~any(user_input==conditionnal values) prompt = 'Please enter one of the listed gray levels (256, 128, 64, 32, 16, 8, 4, 2). '; user_input = input(prompt); end </code></pre> <p><code>user_input == conditionnal_value</code> returns an array composed of 1s and 0s depending on if values of <code>conditionnal_values</code> match with <code>user_input</code>. Then any finds if there is at least one <code>1</code> on this array. Then we apply <code>~</code> which is the <code>not</code> operator.</p>
23,837,949
0
<p>You must create a new method in Product something like <code>update_or_create_colors</code> that updates or creates new ProductColor, and in your controller just call that method, I don't thing there is a method in rails for your especific case.</p>
40,868,428
0
Tree Network in D3 with custom HTML <p>I am trying to draw a tree like a path in d3 but I haven't been able to make it work. The idea is to have nodes with custom HTML in them. The paths start at the same node and end in the same node. How can I draw this with d3?</p> <p><a href="https://i.stack.imgur.com/ttriI.jpg" rel="nofollow noreferrer">This is the desired output</a></p> <p>Some nodes repeat themselves in different places. For example D happens after C and it also happens after A. Also C happens after A and after D. The start and end is always the same but everything in between is not.</p> <p>I tried using treant JS and D3 but so far nothing I have done has worked.</p> <p>Thanks</p>
19,979,247
0
<p>Thank you so much for asking this. It finally helped me solve my related problem.</p> <p>For me, \alpha and \beta both fail. They both fail even without the subscript part coming into play. But if I use the curly braces it works:</p> <pre><code>:math:`\alpha` </code></pre> <p>does not compile</p> <pre><code>:math:`{\alpha}` </code></pre> <p>gives me the symbol I want</p> <pre><code>:math:`{\\alpha}` </code></pre> <p>gives me the word 'alpha' written as adjacent math variables a, l, p, h, a.</p>
5,595,553
0
<p>You have to check if it was clean request or not. Otherwise you will fall into infinite loop</p> <p>Here is an <em>example</em> from one of my projects:</p> <p>.htaccess</p> <pre><code>RewriteEngine On RewriteRule ^game/([0-9]+)/ /game.php?newid=$1 </code></pre> <p>game.php</p> <pre><code>if (isset($_GET['id'])) { $row = dbgetrow("SELECT * FROM games WHERE id = %s",$_GET['id']); if ($row) { Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: /game/".$row['id']."/".seo_title($row['name'])); } else { Header( "HTTP/1.1 404 Not found" ); } exit; } if (isset($_GET['newid'])) $_GET['id'] = $_GET['newid']; </code></pre> <p>So, you have to verify, if it was direct "dirty" call or rewritten one.<br> And then redirect only if former one.<br> You need some code to build clean url too. </p> <p>And it is also very important to show 404 instead of redirect in case url is wrong.</p>
22,069,014
0
<p>The <a href="http://stackoverflow.com/a/21954767/1728537">first answer</a> is not completely correct. In the context of <code>git-add</code>, the <code>:/</code> cannot be a revision. It is a <em>pathspec</em>. See <a href="http://stackoverflow.com/a/22049939/1728537">my answer</a> to the related question "<a href="http://stackoverflow.com/questions/22047909/what-does-git-add-a-do">What does &quot;git add -A :/&quot; do?</a>".</p> <p><em>pathspec</em> is defined in <a href="https://www.kernel.org/pub/software/scm/git/docs/gitglossary.html" rel="nofollow">gitglossary(7)</a>.</p>
20,169,055
0
UITableviewcell set property <p>I need to set the properties in uitableviewcell. The following code is written as I do.</p> <p>myTableViewCell.h</p> <pre><code>@interface myTableViewCell : UITableViewCell @property (nonatomic, weak) NSString *row; @property (nonatomic, weak) NSString *section; </code></pre> <p>myTableViewCell.m</p> <pre><code>- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { NSLog(@"%@",_row); } return self; </code></pre> <p>}</p> <p>myTableViewController.m</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; myTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[myTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.row = [NSString stringWithFormat:@"%i",indexPath.row]; </code></pre> <p>Result row = nill. What is wrong?</p>
32,538,782
0
Bind value with PDO, problems inserting IS NULL <p>I have this function: </p> <pre><code> function fetch_article_comments($article_id, $parent_id) { $app = new Connection(); if ($parent_id &gt; 0) { $parent_id = '= '. $parent_id; } else { $parent_id = "IS NULL"; } $sql = "SELECT * FROM recursive WHERE article_id = :article_id AND comment_parent :parent_id ORDER BY comment_timestamp DESC"; $query = $app-&gt;getConnection()-&gt;prepare($sql); try{ $query-&gt;execute(array(':article_id' =&gt; $article_id, ':parent_id' =&gt; $parent_id)); $comments = $query-&gt;fetchAll(); //returns an stdClass $query-&gt;closeCursor(); return $comments; } catch(PDOException $e){ die($e-&gt;getMessage()); } } </code></pre> <p>And i want <code>$parent_id</code> to be <code>IS NULL</code>. But i get this error message:</p> <blockquote> <p>PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''IS NULL' ORDER BY comment_timestamp DESC'</p> </blockquote> <p>And for the sake of nice clean code, i don't want the whole query inside the if statement.</p> <p>But how can <code>$parent_id</code> be set to <code>IS NULL</code> and not <code>'IS NULL'</code>?</p>
37,610,950
0
Firebase dynamic link not opening the app <p>I have developed installed an android app locally on my device. (app not yet on android play store). I have the logic to get deep link in MainActivity.</p> <pre><code>GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, null) .addApi(AppInvite.API) .build(); // Check if this app was launched from a deep link. Setting autoLaunchDeepLink to true // would automatically launch the deep link if one is found. boolean autoLaunchDeepLink = false; AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, autoLaunchDeepLink) .setResultCallback( new ResultCallback&lt;AppInviteInvitationResult&gt;() { @Override public void onResult(@NonNull AppInviteInvitationResult result) { if (result.getStatus().isSuccess()) { // Extract deep link from Intent Intent intent = result.getInvitationIntent(); String deepLink = AppInviteReferral.getDeepLink(intent); Toast.makeText(getApplicationContext(), deepLink, Toast.LENGTH_LONG).show(); // Handle the deep link. For example, open the linked // content, or apply promotional credit to the user's // account. // ... } else { Log.d(TAG, "getInvitation: no deep link found."); } } }); </code></pre> <p>I built some dynamic links using Firebase console and open in mobile browser. But it is not opening my app and reaching to line String deepLink = AppInviteReferral.getDeepLink(intent);</p> <p>Instead it is opening the URL in mobile browser itself.</p> <p>How to open the app and handle deep link in activity while using firebase dynamic link??</p> <p>Edit:</p> <p>I habe intent filter also in manifest file.</p> <pre><code>&lt;activity android:name="MainActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:host="example.com" android:scheme="http"/&gt; &lt;data android:host="example.com" android:scheme="https"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre>
1,037,865
0
<p>a short notice on the installation. .NET is as default xcopy-able so you wouldn't need an installer for the exe to be usable. Mail it around (or with the next release of the .NET framework optionaly leave it on a network share)</p>
10,920,051
0
<p>You can always write some java code with the apache httpcompenents library. see <a href="http://hc.apache.org/" rel="nofollow">http://hc.apache.org/</a></p> <p>It is not difficult to use</p>
18,916,160
0
AutoGenerateColumns="False" Causes Empty RadGrid on Databind <p>If <code>AutoGenerateColumns="True"</code> then the grid will bind with the dataset and shows the data, but if set to false will not bind and will show the NoRecords value, even though the datatable has rows. </p> <p>What causes this, and how can I fix it?</p> <pre><code>pas.MasterTableView.AutoGenerateColumns =false; DataTable dt = new DataTable(); dt.Columns.Add("SNo"); dt.Columns.Add("Name"); dt.Columns.Add("Add"); DataRow dsa = dt.NewRow(); dsa["SNo"] = "1"; dsa["Name"] = "Karthik"; dsa["Add"] = "Hyd"; dt.Rows.Add(dsa); dsa = dt.NewRow(); dsa["SNo"] = "2"; dsa["Name"] = "krishna"; dsa["Add"] = "Hyd"; dt.Rows.Add(dsa); dsa = dt.NewRow(); dsa["SNo"] = "3"; dsa["Name"] = "kailas"; dsa["Add"] = "Hyd"; dt.Rows.Add(dsa); dsa = dt.NewRow(); dsa["Sno"] = "4"; dsa["Name"] = "Billa"; dsa["Add"] = "Hyd"; dt.Rows.Add(dsa); dsa = dt.NewRow(); dsa["Sno"] = "5"; dsa["Name"] = "asdf"; dsa["Add"] = "qwer"; dt.Rows.Add(dsa); pas.DataSource = dt; pas.DataBind(); </code></pre>
30,761,824
0
<p>What you have done is almost correct. Just change <code>.currentmember</code> to an actual measure in your cube. Currently when you have the following it is referring to itself i.e. <code>currentmember</code> by the black arrow it referring to the measure <code>count</code> by the black arrow... </p> <p><img src="https://i.stack.imgur.com/4LJJU.png" alt="enter image description here"></p> <p>This is in <code>AdvWrks</code>:</p> <pre><code>SELECT {[Measures].[Internet Sales Amount]} ON 0 ,{[Product].[Product Categories].[Category]} ON 1 FROM [Adventure Works]; </code></pre> <p>It returns this:</p> <p><img src="https://i.stack.imgur.com/VBt1V.png" alt="enter image description here"></p> <p>If I want to replace the empty cell for Components the we can use <code>CASE</code>:</p> <pre><code>WITH MEMBER [Measures].[count] AS CASE [Measures].[Internet Sales Amount] WHEN 0 THEN "XXX" ELSE [Measures].[Internet Sales Amount] END ,format_string = "#,###,##0" SELECT { [Measures].[count] } ON 0 ,{[Product].[Product Categories].[Category]} ON 1 FROM [Adventure Works]; </code></pre> <p>This now returns this:</p> <p><img src="https://i.stack.imgur.com/NIl2Z.png" alt="enter image description here"></p> <p><code>IIF</code> is used a lot more in <code>MDX</code> than <code>CASE</code> - <code>IIF</code> is nearly always faster. So the above equivalent using <code>IIF</code> is the following:</p> <pre><code>WITH MEMBER [Measures].[count] AS IIF ( [Measures].[Internet Sales Amount] = 0 ,"XXX" ,[Measures].[Internet Sales Amount] ) ,format_string = "#,###,##0" SELECT {[Measures].[count]} ON 0 ,{[Product].[Product Categories].[Category]} ON 1 FROM [Adventure Works]; </code></pre>
24,063,915
0
Intermittent Swift Framework Compiler Error <p>I am trying out Swift in the XCode beta. In particular using an @IBDesignable and @IBInspectable. I am building a framework containing an (@IBDesignable) UIView subclass and a Simple iOS App in order to test it out (Both contained in and linked via a workspace). After a few successful builds I get the following error in the framework build output:</p> <p>:0: error: /Users/richardpj/Projects/Swift2/Swift2FW/build/Swift2FW.build/Debug-iphonesimulator/Swift2FW.build/unextended-module.modulemap:2: umbrella header 'Swift2FW.h' not found :0: error: could not build Objective-C module 'Swift2FW'</p> <p>Before you ask I've done a clean and deleted my derived data but nothing seems to resolve it except deleting and recreating the workspace and project files.</p> <p>Any ideas on the source of the error, how to replicate (for a bug report) OR am I being dumb.</p> <p><strong>EDIT:</strong> I've gotten 50 views since this was posted. Sounds like it's a bug I should report. Any ideas on how to do that?</p>
8,640,862
0
<p>this will usually do it:</p> <p><code>android:numeric="integer"</code></p>
15,952,531
0
<p>It is not included in core of <a href="http://jquery.com" rel="nofollow">jQuery</a>, it come with a plugin called <a href="http://www.bvbcode.com/code/82iamsqt-867838" rel="nofollow">ajaxQueue</a>. mode:abort, abort all current ajax request, optional you can use a port to limit which group you are aborting. Code example with <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" rel="nofollow">jQuery autocomplete</a> plugin:</p> <pre><code>$.ajax({ // try to leverage ajaxQueue plugin to abort previous requests mode: "abort", // limit abortion to this input port: "autocomplete" + input.name, .... </code></pre>
37,077,763
0
<p>Use <code>setInterval</code> function to do your checking</p> <pre><code> setInterval(function(){ var value=$("#your_id").val();//textbox value $.ajax({ url: "ajax.php", type: "get", //send it through get method data:{value: value }, success: function(response) { //Do Something //alert(response); }, error: function(xhr) { //Do Something to handle error } }); }, 5000); </code></pre> <p>In ajax.php you check that value</p> <pre><code>if(isset($_GET['value'])){ $value=$_GET['value']; //select your old value from database suppose it as $old_value if($value!=$old_value){ //update your table using $value } } </code></pre>
29,620,852
0
<p>Thank you so much everyone, the answer was easier than i though:</p> <p>The file test.json:</p> <pre><code>{ "test": "Hello World!" } </code></pre> <p>And the code:</p> <pre><code>var a = OwNet.get( 'core/config/test.json', function( Res ) { // Res is the response from an AJAX request (where i requested the test.json file) if( Res !== "" &amp;&amp; Res !== undefined &amp;&amp; Res !== null ) { // Replacing the line breaks, carriage returns and spaces Res = Res.replace( /\r\n|\r|\n|\s*/gm, "" ); // Erased the JSON.stringify and replaced tmp by Res return JSON.parse( Res ); } else return null; }); </code></pre>
28,388,084
0
How can I get preventDefault to work for all browsers? <p>I have weird problem with event.preventDefault. This works fine on Chrome but doesn't work on Firefox. I know many people fix it by adding event arg like this: myFunction(event) but doing this makes it stop working on both Chrome and Firefox. Can someone help me get this code working on all browsers?</p> <pre><code> &lt;script type="text/javascript"&gt; function myFunction() { var asdf = $('input[name=payment_type]:checked', '#buy').val() if (asdf == 'theRightOne') { event.preventDefault() alert("stuff") } } &lt;/script&gt; </code></pre>
14,595,845
0
Gtkmm getting label color <p>I do not have a code error, I have just looked everywhere and cannot figure out how to do this. I want to get the color of a Gtk::widget, the Gtk::label. I can override the color of a label like this: l.override_color( c, l.get_state_flags() ); , but I have no idea how to get that color back from the label, thanks!</p>
8,703,676
0
<p>My way of doing this is simple:</p> <ul> <li>When a user loads a page, their "last page load time" is updated in the database.</li> <li>A cron script runs every minute. It looks for users whose "last page load time" was in the last minute.</li> <li>Increment the "time spent on site" for each user found.</li> </ul> <p>In this way, I can keep track of users accurately to the minute. Just divide by 60 to get the hours.</p>
34,884,282
0
MarkLogic Content Pump is an open-source, Java-based command-line tool (mlcp). mlcp provides the fastest way to import, export, and copy data to or from MarkLogic databases. It is designed for integration and automation in existing workflows and scripts.
5,280,646
0
<p>Add 3 to your allocation amount. Allocate the memory. If the returned address isn't already a multiple of 4, round it up until it is. (The most you'd have to round up is 3, which is why you pad your allocation by that much in advance.)</p> <p>When you free the memory, remember to free the original address, not the rounded-up value.</p>
20,091,695
0
<p>Try this:</p> <pre><code>string myscript = "$('a.fancybox-messageboard').fancybox({ width: 600, height: 440,closeClick: true, hideOnOverlayClick: true, href: 'http://upload.wikimedia.org/wikipedia/commons/1/1a/Bachalpseeflowers.jpg' }).trigger('click');" ScriptManager.RegisterClientScriptBlock(this, this.GetType(), Guid.NewGuid().ToString(), "&lt;script&gt;" + myscript + "&lt;/script&gt;", false); </code></pre>
22,299,497
0
<p>To understand the difference it will be helpful to consider a more simple example. Let;s assume that there are two stand-alone functions</p> <pre><code>int f() { static int x; return x; } int &amp; g() { static int x; return x; } </code></pre> <p>As you see the both functions have the same body and return statements.</p> <p>The difference between them is that in the first case a copy of static variable x is returned while in the second case a reference to static variable x is returned.</p> <p>So in the second case you can do for example the following</p> <pre><code>g() = 10; </code></pre> <p>and variable x defined in the body of the function will be changed.</p> <p>In the first case you may not and can not do the same. In this case a temporary int object is created that is a copy of variable x.</p>
26,853,465
0
<p><code>\</code> is an escape charecter in most languages, so the compiler expects an escaped char after it, in this case its also <code>\</code>, so you just need to use 2 of them</p> <pre><code>File.open("C:\\Users\\C*****\\Documents\\RubyProjects\\text.txt </code></pre>
22,665,378
0
<p>Have you tried <code>keyCode == 82</code>, not <code>114</code>? <a href="http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes" rel="nofollow">Key codes</a> are not the same as ASCII/charCodes, so there's no upper/lower case consideration.</p> <p>This worked for me (well, technically I used it with a JQuery keydown handler, not <code>document.onkeypress</code>):</p> <pre><code>document.onkeypress = function(e){ if ((e.ctrlKey || e.metaKey) &amp;&amp; e.keyCode == 82) // Ctrl-R e.preventDefault(); } </code></pre> <p>And for all those crying "bad design" - I'm building a terminal emulator and want CTRL-R to match the Bash CTRL-R to search history, not refresh the page. There are always use cases.</p>
25,640,265
0
<p>The problem seems to be because of improperly formatted code. The quotes are a little mixed up.</p> <pre><code>$("&lt;div class='child' id='cross" + counter + "'&gt;&lt;/div&gt;") </code></pre> <p>This should work. To insert it into the DOM, you could do something like:</p> <pre><code>$('body').append("&lt;div class='child' id='cross" + counter + "'&gt;&lt;/div&gt;") </code></pre> <p><a href="http://jsfiddle.net/1ok6b2ro/" rel="nofollow">Here's an example</a>.</p>
40,629,951
0
Can i use 4 Action button in Notification manager ? like B1, B2, B3, B4 <p>I am using Notification Manager and have added 4 action button like YES, NO, MAYBE, LATER. But, 4th button is not showing.</p> <p>What could be the possible reason...? Kindly guide.</p> <p>Regards, Sanjay</p>
15,248,110
0
<p>The Exception <code>DOMException</code> with the message </p> <blockquote> <p>Invalid Character Error</p> </blockquote> <p>means that you have tried to create an element (<a href="http://php.net/DOMDocument.createElement" rel="nofollow"><code>DOMDocument::createElement()</code></a>) containing invalid characters in the element name:</p> <pre><code>$mydom-&gt;createElement($name, $link) ^ | first parameter is the element name </code></pre> <p>In XML not every name is valid, some even contain invalid characters (for example a space <code>" "</code> or the backslash <code>/</code>) or invalid byte-sequences that aren't anything from the Unicode UTF-8 range. DOMDocument in PHP accepts UTF-8 as input only. So for for general. If you want to learn in depth which characters are valid in XML element names you can find more information that you will likely ever need in your live in <a href="http://stackoverflow.com/questions/2519845/how-to-check-if-string-is-a-valid-xml-element-name"><em>How to check if string is a valid XML element name?</em></a>.</p> <p>So for now if you look closely to the stacktrace of the error message you can probably even spot the problem:</p> <blockquote> <pre><code>DOMDocument-&gt;createElement('/joomla/compone...', 'Arduino') ^ ^ </code></pre> </blockquote> <p>The <code>/</code> character is not valid inside an XML element name. Fix the issue and you should be able to just add your stuff. Just use an element name that is valid in the end.</p>
7,406,826
0
<p>Generally speaking, you don't want to divorce your URL from any semblance of meaning for the user unless you are significantly shortening it for use in character-limited settings like a Twitter post.</p> <p>That said, there are a few ways to implement this. You can:</p> <ul> <li>Pre-generate these URLs and store the cross-referenced query string in the database (use "f4cdret4" as a unique index, "a=10&amp;b=20&amp;c=30" as a second column)</li> <li>Mash them together with some kind of separator (a=10&amp;b=20&amp;c=30 becomes "a10-b20-c30")</li> <li><p>Use htaccess to make pseudo-directories (a=10&amp;b=20&amp;c=30 becomes "mydomain.com/q/10/20/30")</p> <p><code>RewriteEngine On</code></p> <p><code>RewriteRule /q/(.*)/(.*)/(.*)$ /page/play.php?a=$1&amp;b=$2&amp;c=$3</code></p></li> </ul>
23,511,872
0
<p><strong>Update</strong></p> <p>You could build a separate directive which dynamically compiles the required directive:</p> <pre><code>app.directive('dynamicDirective', function($compile) { return { restrict: 'A', replace: true, scope: { dynamicDirective: '=' }, link: function(scope, elem, attrs) { var e = $compile("&lt;div " + scope.dynamicDirective + "&gt;&lt;/div&gt;")(scope); elem.append(e); } }; }); </code></pre> <p>It can be used as follows (in this sample <code>someDirective</code> is defined on the scope and has the name of the required directive):</p> <pre><code>&lt;div dynamic-directive="someDirective"&gt;&lt;/div&gt; </code></pre> <p><a href="http://plnkr.co/edit/u5moX3RkRavX8gqFlc7J?p=preview" rel="nofollow">Here is a sample</a></p>
38,411,509
0
<p>That’s a runtime exception so the compiler can’t help you with catching it at a compile time. And the <code>try-catch</code> block helps you to <strong>handle</strong> this exception, not to prevent it from being thrown at the runtime. If you don’t make a try-catch block it will be handled at a general application level.</p> <p>A quote from MSDN:</p> <blockquote> <p>When an exception is thrown, the common language runtime (CLR) looks for the catch statement that handles this exception. If the currently executing method does not contain such a catch block, the CLR looks at the method that called the current method, and so on up the call stack. If no catch block is found, then the CLR displays an unhandled exception message to the user and stops execution of the program.</p> </blockquote> <p>Please refer to the <a href="https://msdn.microsoft.com/en-us/library/0yd65esw.aspx" rel="nofollow">MSDN try-catch</a> for more information.</p>
21,804,382
0
Completely stuck on where to start on programing <p>I've been given a task to produce a webpage which solves the quadratic formula. Talking to friends they have said the simplised way is to learn java script and build the webpage. I have been learning the language on code academy and that's fine but where and how do I i write in my own code and execute it for java script? All I have been using so far is the editor page on code academy. Im completely lost in where to go next</p>
23,977,832
0
Move Content Down on Mobile Phones <p>I'm trying to move a column of content down on mobile phones (no tablets), but can't figure it out. The end goal is to move the custom field data below the body text.</p> <p>Via:<a href="http://beta.johnslanding.org/portland/canyon-hoops/" rel="nofollow noreferrer">http://beta.johnslanding.org/portland/canyon-hoops/</a></p> <pre><code>.one-fourth.last.right </code></pre> <p><strong>Tried this:</strong></p> <pre><code>@media only screen and (min-device-width : 400px) { -webkit-column-break-inside:avoid; -moz-column-break-inside:avoid; -o-column-break-inside:avoid; -ms-column-break-inside:avoid; column-break-inside:avoid; } </code></pre> <p>You'll see on my iPhone the theme keeps these two columns together:</p> <p><img src="https://i.stack.imgur.com/I5LMv.png" alt="enter image description here"></p>
26,318,272
0
Google map API v3 plot with Radar loop overlay with automatic update to radar <p>So im trying to create a dynamic loading to a radar loop site mixed with Google Map API v3</p> <p>Currently i have this to just plot a line from 1 to another and looking to get weather center at zoom 12</p> <pre><code>function initialize() { var myLatlng = new google.maps.LatLng(34.01115000,-84.27939000); var mapOptions = { zoom: 12, center: new google.maps.LatLng(34.01115000,-84.27939000), }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var flightPlanCoordinates = [ new google.maps.LatLng(34.01115000,-84.27939000), new google.maps.LatLng(34.03050000,-84.35833000), ]; var flightPath = new google.maps.Polyline({ path: flightPlanCoordinates, geodesic: true, strokeColor: '#0000FF', strokeOpacity: 5.8, strokeWeight: 10, fillOpacity: 0.35 }); flightPath.setMap(map); } google.maps.event.addDomListener(window, 'load', initialize); </code></pre> <p>But here i wanna load in a radar loop and update the lat/long somehow but still automatically move the map and adjust the radar.</p> <p><a href="http://radblast.wunderground.com/cgi-bin/radar/WUNIDS_composite?maxlat=34.96496076302826&amp;maxlon=-89.51954101562501&amp;minlat=29.38958076527275&amp;minlon=-98.30860351562501&amp;type=00Q&amp;frame=0&amp;num=7&amp;delay=25&amp;width=800&amp;height=600&amp;png=0&amp;smooth=1&amp;min=0&amp;noclutter=1&amp;rainsnow=1&amp;nodebug=0&amp;theext=.gif&amp;merge=elev&amp;reproj.automerc=1&amp;timelabel=1&amp;timelabel.x=200&amp;timelabel.y=12&amp;brand=wundermap&amp;rand=4564" rel="nofollow">http://radblast.wunderground.com/cgi-bin/radar/WUNIDS_composite?maxlat=34.96496076302826&amp;maxlon=-89.51954101562501&amp;minlat=29.38958076527275&amp;minlon=-98.30860351562501&amp;type=00Q&amp;frame=0&amp;num=7&amp;delay=25&amp;width=800&amp;height=600&amp;png=0&amp;smooth=1&amp;min=0&amp;noclutter=1&amp;rainsnow=1&amp;nodebug=0&amp;theext=.gif&amp;merge=elev&amp;reproj.automerc=1&amp;timelabel=1&amp;timelabel.x=200&amp;timelabel.y=12&amp;brand=wundermap&amp;rand=4564</a></p>
4,730,448
0
<p>I'm not sure php is the right tool here. Why not use something that is closer to the shell environment, like a bash script?</p> <p>The only reason I can imagine you want to use PHP is so you can start the process by clicking a link on a page somewhere, and thereby punch a large hole in whatever security your system supposedly has. But if you really must, then it is still easier to write a script in a more shell friendly language and simply use php as a gateway to invoke the script.</p>
7,819,402
0
How to open a config file app settings using ConfigurationManager? <p>My config file is located here:</p> <pre><code>"~/Admin/Web.config" </code></pre> <p>I tried opening it via the below code but it didn't work:</p> <pre><code>var physicalFilePath = HttpContext.Current.Server.MapPath("~/Admin/Web.config"); var configMap = new ConfigurationFileMap(physicalFilePath); var configuration = ConfigurationManager.OpenMappedMachineConfiguration(configMap); var appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings"); </code></pre> <p>when appsettings line runs, it throws the below error message:</p> <pre><code>Unable to cast object of type 'System.Configuration.DefaultSection' to type 'System.Configuration.AppSettingsSection'. </code></pre> <p>My Web.Config looks like below:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"&gt; &lt;appSettings&gt; &lt;add key="AdminUsername" value="Test1"/&gt; &lt;add key="AdminPassword" value="Test2"/&gt; &lt;/appSettings&gt; &lt;connectionStrings&gt;&lt;/connectionStrings&gt; &lt;/configuration&gt; </code></pre> <p>How could I get the appsettings?</p>
39,507,229
0
Forms authentication for Web API invalidated by external assembly? <p>We have a site that uses Forms-authentication through a custom MembershipProvider and Web API that we're now having an unexpected problem with. </p> <p>The site uses EPiServer CMS, but I think the problem is general enough that the question can probably be answered without any knowledge of EPiServer. </p> <p>The problem started when we upgraded EPiServer to the latest version - this also gave us a new assembly for their Service API which basically is a REST API for integrating with their CMS that is setup on a specific route on the site automatically - just by including the assembly in the bin-folder. </p> <p>This new version of their Service API uses OWIN and configures their API to use Bearer-authentication and as far as I can understand also ClaimsIdentity, which would be fine except this suddenly also applies to <em>our</em> implementation of Web API, causing the HttpContext.Current.User to be a ClaimsIdentiy that's not authenticated. Removing the Service API-assembly makes it a FormsIdentity again. </p> <p>The Forms-authentication continues to work fine on the website itself, it is just the WebAPI that is affected by this. </p> <p>So we're looking for a way to fix this, any ideas would be greatly appreciated!</p>
12,091,584
0
<p>I think a good start is to check the TTS engine on Android: <a href="http://developer.android.com/reference/android/speech/tts/TextToSpeech.html" rel="nofollow">http://developer.android.com/reference/android/speech/tts/TextToSpeech.html</a></p> <p>From my point of view, Android is one of the most open mobile platform. So I'm pretty sure your idea is possible to realise on this system !</p> <p>Good luck for your project.</p>
21,370,509
0
<p>As @user3237539 pointed out, your jQuery selectors must begin with '#'. Your code should look like this:</p> <pre><code>&lt;script type="text/javascript"&gt; function opt_onchange() { if (document.getElementById("opt").value == "") { document.getElementById("submit").style.visibility = "hidden"; } else { document.getElementById("submit").style.visibility = "visible"; } if (document.getElementById("opt").value == "banscan") { $("#form_username").fadeOut(); $("#form_password").fadeOut(); } else { $("#form_username").fadeIn(); $("#form_password").fadeIn(); } } &lt;/script&gt; </code></pre> <p>Hope that helps!</p> <p>PS: Whenever you use <code>document.getElementById()</code> you could instead use <code>$("#id")</code> to be able to use more of jQuery's helpful functions. You could replace <code>document.getElementById("submit").style.visibility = "hidden";</code> with <code>$("#submit).hide();</code></p>
7,051,243
0
<p>This will work in quirks mode, but the browser which is compatible with standard mode will not work depend upon your doctype. Avoiding quirks mode is one of the keys to successfully producing cross-browser compatible web content</p> <p>Some modern browsers have two rendering modes. Quirk mode renders an HTML document like older browsers used to do it, e.g. Netscape 4, Internet Explorer 4 and 5. Standard mode renders a page according to W3C recommendations. Depending on the document type declaration present in the HTML document, the browser will switch into either quirk mode or standard mode. If there is no document type declaration present, the browser will switch into quirk mode.</p> <p><a href="http://www.w3.org/TR/REC-html32#dtd" rel="nofollow">http://www.w3.org/TR/REC-html32#dtd</a></p> <p>JavaScript should not behave differently; however, the DOM objects that JavaScript operates on may have different behaviors.</p>
22,508,449
0
<p>I think you are trying to assign the various objects to the top level environment. Functions have their own environments, so assignments there exist only during the evaluation of the functions (which is why you can see the objects when <code>debug</code>ging). As soon as you your function returns, the objects in the body of the function cease to exist.</p> <p>In order to work around that, you can use <code>&lt;&lt;-</code> (i.e. <code>Butterfly_data &lt;&lt;- read.csv(...)</code>), as well as anytime you modify those objects within the function.</p> <p>Please keep in mind that <code>&lt;&lt;-</code> use is generally discouraged, and there is almost always a better way to do something than using <code>&lt;&lt;-</code>.</p> <p>For example, in this case, you could have returned a list with all your objects, and written a separate function that runs through the lists and produces the heads:</p> <pre><code>Extremes &lt;- function(siteno) { # bunch of stuff return(list(Precip=Precip, Tmax=Tmax, Tmin=Tmin)) } data.list &lt;- Extremes("mysiteno") lapply(data.list, head) # view the heads list2env(data.list) # if you really want objects available at top level directly </code></pre>
37,803,892
0
<pre><code>The API is // Hopefully your alarm will have a lower frequency than this! alarmMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_HALF_HOUR, AlarmManager.INTERVAL_HALF_HOUR, alarmIntent); Details : https://developer.android.com/training/scheduling/alarms.html </code></pre>
24,093,379
0
<p>Specific different folders for all paths in all installations and it should work.</p> <p>For example \Delphi XE1 \Delphi XE2</p> <p>or simply use Rad Studio 14.0\ and so forth.</p> <p>Just make sure common files and documents and stuff like that goes into Rad Studio 14.0 as well.</p> <p>So have one main folder for each delphi version and make sure the installer installs everything into that main version folder.</p>
38,173,394
0
<p>For c++98:</p> <p>One way to achieve what you want of requiring an exact match is to have a template method which accepts any type but always fails due to SFINAE:</p> <pre><code> template&lt;typename U&gt; U isFoo(U variable) { typename CheckValidity::InvalidType x; } </code></pre> <p>For c++11:</p> <p>You can use a deleted method to achieve the same effect more cleanly:</p> <pre><code> template&lt;typename U&gt; U isFoo(U variable) = delete; </code></pre>
28,582,879
0
<p>instead of </p> <pre><code>statement.executeQuery(stmtSelectObjKey); </code></pre> <p>use</p> <pre><code>statement.executeQuery(); </code></pre> <p>it will work !!</p>
7,177,618
0
<p>You can use <code>remove_instance_variable</code>. However, since it's a private method, you'll need to reopen your class and add a new method to do this:</p> <pre><code>class World def remove_country remove_instance_variable(:@country) end end </code></pre> <p>Then you can do this:</p> <pre><code>country_array.each { |item| item.remove_country } # =&gt; [#&lt;World:0x7f5e41e07d00 @country="Spain"&gt;, #&lt;World:0x7f5e41e01450 @country="India"&gt;, #&lt;World:0x7f5e41df5100 @country="Argentina"&gt;, #&lt;World:0x7f5e41dedd10 @country="Japan"&gt;] </code></pre>
16,874,029
0
<p>For Python 3</p> <pre><code>positionNewD = {k: (x, -y) for k, (x, y) in positionD.items()} </code></pre> <p>... as iteritems() has been renamed items()</p> <p><a href="http://docs.python.org/3.1/whatsnew/3.0.html#views-and-iterators-instead-of-lists" rel="nofollow">http://docs.python.org/3.1/whatsnew/3.0.html#views-and-iterators-instead-of-lists</a></p>
32,257,910
0
<p>You are actually just in luck. Android just released a new percent support library. They don't have documentation yet, but here is a good sample project that you can use to see how to go about using the library. It basically allows you to size view widgets by percentage of the screen.</p> <p><a href="https://github.com/JulienGenoud/android-percent-support-lib-sample" rel="nofollow">https://github.com/JulienGenoud/android-percent-support-lib-sample</a></p> <p>And here are two articles talking about it as well:</p> <p><a href="http://www.androidauthority.com/using-the-android-percent-support-library-630715/" rel="nofollow">http://www.androidauthority.com/using-the-android-percent-support-library-630715/</a></p> <p><a href="http://inthecheesefactory.com/blog/know-percent-support-library/en" rel="nofollow">http://inthecheesefactory.com/blog/know-percent-support-library/en</a></p>
33,757,717
0
<p>It's just wrong call parametters.</p> <p>If you want to change your code, this solution can help you.</p> <p>Class GUI just inherits from Canvas and doesn't implement anything.</p> <pre><code>from Tkinter import* root = Tk() class GUI(Canvas): '''inherits Canvas class (all Canvas methodes, attributes will be accessible) You can add your customized methods here. ''' def __init__(self,master,*args,**kwargs): Canvas.__init__(self, master=master, *args, **kwargs) polygon = GUI(root) polygon.create_polygon([150,75,225,0,300,75,225,150], outline='gray', fill='gray', width=2) polygon.pack() root.mainloop() </code></pre> <p>For more help add comments.</p>
10,247,524
0
<p>By count each color pixels you get the area, if you already label your data as following:</p> <pre><code>data = np.array([[0,0,1,1,1], [2,2,1,1,1], [2,3,3,3,3], [2,4,4,3,3]]) </code></pre> <p>than you can use numpy.bincount() to count each label:</p> <pre><code>print numpy.bincount(data.ravel()) </code></pre> <p>the output is :</p> <pre><code>array([2, 6, 4, 6, 2]) </code></pre> <p>which means there are two 0, six 1, four 2, six 3, and two 4.</p>
24,390,135
0
<p>EDIT: I resolved following the Google Note. LOL</p> <blockquote> <p>Note: If you are debugging your game using your debug certificate but have configured game services using your release certificate, you should add a second linked app using the same package name and your debug certificate's SHA1 fingerprint. This will allow you to sign in to the application whether it's signed with the debug or release certificates.</p> </blockquote> <p><a href="https://developers.google.com/games/services/android/troubleshooting#check_the_certificate_fingerprint">Google Services Developers Link</a></p> <p>"a second linked app" is the key point, not two game, but two linked app in the same game</p> <p>So, the right method is to link two time the same app in the Google Play Developer Console:</p> <ul> <li><p>First app with bundle com.name.appname and release fingerprint</p></li> <li><p>And a second app, with the same bundle and another name (es. AppName Test User1) and with debug fingerprint</p></li> </ul> <p>In this way, in the Api Developer Console, it creates two OAuth2 client ID for the same project and both work well.</p> <p>NOTE: If you have done many tests, remember to delete all app in the play games section of Google Play Developer Console, and all projects in the Api Developer Console.</p>
31,761,192
0
<p>You could use programmatic transaction manager <a href="http://www.mkyong.com/hibernate/hibernate-transaction-handle-example/" rel="nofollow">see here</a></p>
32,404,679
0
<p>To: Mr. leigero and Mr. moskito-x</p> <p>From: Mary T.</p> <p>Date: Sept. 4, 2015</p> <p>Re: My question appears to have been answered...</p> <ul> <li><p>Your suggestions that I 'clear out the browser' cache appears to have worked (actually, it has in fact worked when I subsequently had the problem described, 'clearing the cache' rectified the problem). I've had to use this 'cache clearing' solution two (2) or three (3) times already and it in fact 'worked'!</p></li> <li><p>To be absolutely thorough, I say 'appears' immediately above because this problem, as stated, has been and is intermittent. I'm just covering my bases. Albeit, I do believe 'clearing the cache' is the answer to this problem. </p></li> <li><p>Enough said... I thank you very much for your help to me. Very truly much appreciated!!!</p></li> <li><p>For others in the world, I note this web site: </p></li> </ul> <p><a href="https://kb.iu.edu/d/ahic#firefox" rel="nofollow">https://kb.iu.edu/d/ahic#firefox</a></p> <p>(Web page stated as: Indiana University Knowledge Base) on 'How do I clear my web browser's cache, cookies, and history?'</p> <ul> <li>Peace!!!...</li> </ul>
3,967,400
0
Create or manipulate EPS files using .NET <p>I have to create thousands of individual EPS (Encapsulated PostScript) files. These files will be printed by a company that uses a Roland printer and software. The printer software only accepts eps files.</p> <p>So this is the procedure I've implemented using a custom vector graphics library:</p> <ol> <li>Create an individual bitmap (this works)</li> <li>Draw a rectangle around the bitmap in a certain named color (the color must be named "CutContour" YMCK (0, 0.9, 0, 0). The color itself isn't important, but the name must be set to "CutContour".</li> <li>Save the graphics in the EPS format</li> </ol> <p>Now, using some custom library I was able to do all the steps I've described, but the library apparently doesn't support color names (spot colors?).</p> <p>Another strategy I tried in my desperation: I've created a working example file in EPS using CorelDraw (I even did it with Adobe Illustrator).</p> <p>Using a hex editor I extracted the first part of the file until the bitmap information and the bottom part after the bitmap. Using both parts I was able to "inject" the individual bitmap and created new "Frankenstein" eps files just by concatenating the parts.</p> <p>I could open these files in CorelDraw, but they must be somehow corrupt, because the company that prints the images can't open them on their machines. Also, I have some other issues with that files. I guess there is some binary information at the end of the file that's somehow related to the bitmap.</p> <ol> <li>Does anybody know some other library or clever way to get the desired result?</li> <li>Does anybody know who I could manipulate the created eps file in order to draw the rectangle using the "CutContour" color name? (It's not obvous looking at the file I've created using CorelDraw and AI)</li> </ol> <p><em>Thanks for reading!</em></p>
4,794,785
0
<p>Take a look at <a href="http://www.eclipse.org/Xtext/" rel="nofollow">Xtext</a>. It's a framework on top of the eclipse platform that autogenerates much of the infrastructure (like syntax highlighting and autocomplete) from the language grammar - basically you get a pretty powerful editor in minutes rather than months of work.</p>
28,022,998
1
Finding sublists inside lists <p>I have a list that may or may not contain sublists as elements, and I need to check whether an element is or is not a sublist.</p> <p>For example consider</p> <pre><code>&gt;&gt;&gt; list = ['a', 'b', 'c', ['d', 'e'] ] </code></pre> <p>As I would expect, I get</p> <pre><code>&gt;&gt;&gt; list[2] 'c' &gt;&gt;&gt; list[3] ['d', 'e'] &gt;&gt;&gt; list[3][1] 'e' </code></pre> <p>and</p> <pre><code>&gt;&gt;&gt; len(list[1]) 1 &gt;&gt;&gt; len(list[3]) 2 </code></pre> <p>and also</p> <pre><code>&gt;&gt;&gt; type(list[1]) &lt;type 'str'&gt; &gt;&gt;&gt; type(list[3]) &lt;type 'list'&gt; </code></pre> <p>So far so good. However, quite surprisingly (at least for a python novice as I am)</p> <pre><code>&gt;&gt;&gt; type(list[1]) is list False &gt;&gt;&gt; type(list[3]) is list False </code></pre> <p>Could somebody explain this? Clearly I can just use <code>len()</code> to determine whether an element is a sublist, but I think the explicit type checking should be more appropriate, as it is a more precise statement of what I want to do. Thanks. </p>
2,033,822
0
<p>You have to check everything is the same...</p> <ul> <li>Correct DB?</li> <li>Correct schema? (eg foo.MyTable and dbo.MyTable)</li> <li>Correct column order?</li> <li>Trigger?</li> <li>Concatenation or some processing?</li> <li>Same data being inserted?</li> </ul> <p>Edit: What was it of my list, out of interest please?</p>
15,200,384
0
Is it possible to backup with rsync, follow root symlink, but preserve the rest of the symlinks? <p>I'm setting up a backup using rsync. I'd like to specify the root source directory using a symlink that points to it, but for the rest of the archived tree, I'd like to preserve the symlinks. </p> <p>Further, I'd like to preserve the symlink name as the root in the backup archive.</p> <p>The reason for this setup (which may, or may not, be very smart) is that the source is a versioned app, where the version numbers will increase over time. I only want to backup the latest version and I want rsync to remove older files from the backup archive.</p> <p>Example source: </p> <pre><code>source_symlink -&gt; source-1.2.3 source-1.2.3/ file1.txt dirA/ fileA.txt symlink_fileA -&gt; dirA/fileA.txt </code></pre> <p>If I attempt to backup this with</p> <pre><code>rsync -av --delete source_symlink destination_dir </code></pre> <p>I simply get a copy of the symlink inside my destination; like this:</p> <pre><code>destination_dir/ source_symlink -&gt; source-1.2.3 </code></pre> <p>I.e. a symlink pointing to a non-existing directory. </p> <p>If I resolve the symlink myself, e.g. like this:</p> <pre><code>rsync -av --delete $(readlink -f source_symlink) destination_dir </code></pre> <p>I get the following:</p> <pre><code>destination_dir/ source-1.2.3/ file1.txt dirA/ fileA.txt symlink_fileA -&gt; dirA/fileA.txt </code></pre> <p>This is ok until I change the symlink to, for example the next version; e.g. <code>source_symlink -&gt; source-2.0.0</code>. In that case, I end up with duplicates in the archive:</p> <pre><code>destination_dir/ source-1.2.3/ source-2.0.0/ </code></pre> <p>What I'd like is that the root symlink is followed, but the rest of the symlinks are preserved. Further, I'd like to have the symlink name in destination directory. Like this:</p> <pre><code>destination_dir/ source/ file1.txt dirA/ fileA.txt symlink_fileA -&gt; dirA/fileA.txt </code></pre> <p>Is this possible to achieve?</p>
38,744,251
0
Openssl is not working, and directory /etc/ssl is missing <p>We are working on a red hat linux server, and we can apply <code>openssl version</code> and <code>openssl</code> will get you inside openssl shell-like <code>Openssl&gt;</code></p> <p>But there is no directory <code>/etc/ssl/</code> and we are getting the following failure when we try to connect:</p> <pre><code>[&lt;username&gt;@&lt;pc name&gt; etc]$ openssl s_client -port 31114 -host &lt;ipaddress&gt; -ssl3 -quiet -crlf 904:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:530: </code></pre> <p>It is not working, nothing is working in openssl on the server? what shall we do?</p> <p>we are sure that openssl is installed:</p> <pre><code>[root@&lt;pc name&gt; ~]# yum list |grep openssl This system is not registered with RHN. RHN support will be disabled. openssl.i686 0.9.8e-12.el5 installed openssl.x86_64 0.9.8e-12.el5 installed openssl-devel.i386 0.9.8e-12.el5 installed openssl-devel.x86_64 0.9.8e-12.el5 installed openssl097a.i386 0.9.7a-9.el5_2.1 installed openssl097a.x86_64 0.9.7a-9.el5_2.1 installed </code></pre> <p>Thank you in advance.</p>
15,566,748
0
<p>You shouldn't use the <code>sf_upload_dir</code> key because it returns the full path to the image inside the webserver. Like: <code>c:\website\project\web\uploads</code>.</p> <p>You should use <code>sf_upload_dir_name</code> instead, which returns the path to the uploads folder <strong>inside</strong> the web folder.</p> <p>Try:</p> <pre><code>&lt;img src="/&lt;?php echo sfConfig::get('sf_upload_dir_name').'/'.$post-&gt;getImagename() ?&gt;" /&gt; </code></pre>
13,118,199
0
<p>There are no direct way to get this. However there is a work around like this which will work in most of the cases. All you have to do is to add all the possible date formatter to the below <code>dateFormatterList</code>. </p> <pre><code>- (NSString *)dateStringFromString:(NSString *)sourceString destinationFormat:(NSString *)destinationFormat { NSString *convertedDateString = nil; NSArray *dateFormatterList = [NSArray arrayWithObjects:@"yyyy-MM-dd'T'HH:mm:ss'Z'", @"yyyy-MM-dd'T'HH:mm:ssZ", @"yyyy-MM-dd'T'HH:mm:ss", @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", @"yyyy-MM-dd'T'HH:mm:ss.SSSZ", @"yyyy-MM-dd HH:mm:ss", @"MM/dd/yyyy HH:mm:ss", @"MM/dd/yyyy'T'HH:mm:ss.SSS'Z'", @"MM/dd/yyyy'T'HH:mm:ss.SSSZ", @"MM/dd/yyyy'T'HH:mm:ss.SSS", @"MM/dd/yyyy'T'HH:mm:ssZ", @"MM/dd/yyyy'T'HH:mm:ss", @"yyyy:MM:dd HH:mm:ss", @"yyyyMMdd", @"dd-MM-yyyy", @"dd/MM/yyyy", @"yyyy-MM-dd", @"yyyy/MM/dd", @"dd MMMM yyyy", @"MMddyyyy", @"MM/dd/yyyy", @"MM-dd-yyyy", @"d'st' MMMM yyyy", @"d'nd' MMMM yyyy", @"d'rd' MMMM yyyy", @"d'th' MMMM yyyy", @"d'st' MMM yyyy", @"d'nd' MMM yyyy", @"d'rd' MMM yyyy", @"d'th' MMM yyyy", @"d'st' MMMM", @"d'nd' MMMM", @"d'rd' MMMM", @"d'th' MMMM", @"d'st' MMM", @"d'nd' MMM", @"d'rd' MMM", @"d'th' MMM", @"MMMM, yyyy", @"MMMM yyyy", nil]; //sourceString = @"20/11/2012"; //destinationFormat = @"dd MMMM yyyy"; if (sourceString) { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; for (NSString *dateFormatterString in dateFormatterList) { [dateFormatter setDateFormat:dateFormatterString]; NSDate *originalDate = [dateFormatter dateFromString:sourceString]; if (originalDate) { [dateFormatter setDateFormat:destinationFormat]; convertedDateString = [dateFormatter stringFromDate:originalDate]; NSLog(@"Converted date String is %@", convertedDateString); break; } } [dateFormatter release]; } return convertedDateString; } </code></pre> <p>Add this to your class and use it as,</p> <pre><code>NSLog(@"%@", [self dateStringFromString:@"2nd August 2012" destinationFormat:@"dd-MM-yyyy"]); </code></pre> <p>Output: <code>02-08-2012</code></p>
21,972,382
0
<p>Obviously the answer is in your error. You didn't select any database. When using this function mysqli_connect specify the database you want to connect to.</p> <p>Here is the syntax of the function: <a href="http://www.w3schools.com/Php/func_mysqli_connect.asp" rel="nofollow">http://www.w3schools.com/Php/func_mysqli_connect.asp</a> .</p> <p>1) Create your database outside of your application</p> <p>2) Specify mysqli_connect with the database you want to select.</p> <p>You can also use another function called mysqli_select_db . You can find the sytanx here : <a href="http://www.w3schools.com/php/func_mysqli_select_db.asp" rel="nofollow">http://www.w3schools.com/php/func_mysqli_select_db.asp</a> .</p> <p>As already stated in the comment, you will also have to replace : "example.com" with your ip address, if you are running locally replace it with 127.0.0.1:3306 , if you didn't change the port when you installed your mysql database / "johndoe" with your database account, you can change that to "root" / "abc123" with your root account password DEFAULT : "" . </p> <p>Good luck !</p>
20,674,447
0
<p>Calculating your angle using just x value seem strange, try this: </p> <pre><code>angle = Math.atan( (startY - endY) / (startX - endX) ); // in rad </code></pre> <p>This will give you the angle in radian.</p> <p>For calculating the velocity you must have a timing variable between the start and the end touch. You can use <code>getTimer()</code> to get <code>beginTime</code> and <code>endTime</code> in your functions <code>onTouchBegin</code> and <code>onTouchEnd</code> respectively. </p> <p>After that you just have to calculate velocity with distance and time.</p> <pre><code>distance = Math.sqrt( ((startX - endX)*(startX - endX)) / ((startY - endY)*(startY - endY)) ); velocity = distance / (endTime-beginTime); // in pixel/ms </code></pre> <p>Hope that helps ;)</p>
16,733,927
0
How to get the path to the skydrive folder in C# <p>I'm actually making a little application that can find on any computer the list of the different cloud storage installed and i wonder how i can get the path to the Skydrive folder in C#.</p> <p>I managed to get the path of dropbox and google drive with information stored in appdata/roaming folder but i don't manage to do the same thing with Skydrive.</p> <p>For dropbox:</p> <pre><code>string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string dbPath = System.IO.Path.Combine(appDataPath, "Dropbox\\host.db"); string[] lines = System.IO.File.ReadAllLines(dbPath); byte[] dbBase64Text = Convert.FromBase64String(lines[1]); string folderPath = System.Text.ASCIIEncoding.ASCII.GetString(dbBase64Text); </code></pre> <p>For google drive :</p> <pre><code>String dbFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google\\Drive\\sync_config.db"); File.Copy(dbFilePath, "temp.db", true); String text = File.ReadAllText("temp.db", Encoding.ASCII); // The "29" refers to the end position of the keyword plus a few extra chars String trim = text.Substring(text.IndexOf("local_sync_root_pathvalue") + 29); // The "30" is the ASCII code for the record separator String drivePath = trim.Substring(0, trim.IndexOf(char.ConvertFromUtf32(30))); </code></pre> <p>If you want to get the path to the skydrive folder you need to use the Registery value at HKEY_CURRENT_USER\Software\Microsoft\SkyDrive, with the name UserFolder. Here is the code :</p> <pre><code>String SkyDriveFolder = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\SkyDrive", "UserFolder",null).ToString(); </code></pre>
2,705,938
0
<p>The bracket <code>[</code> is a <code>test</code> operator, which you can think of as an if statement. This is checking to see if the shell variable RABBITMQ_NODE_IP_ADDRESS is empty. Unfortunately, if you try to compare to an empty string <code>""</code>, the shell eliminates it before it does the test and your binary comparison operator only gets one (or maybe zero) operands. To prevent that error, it is a common practice to concatenate an "x" on each side of the <code>=</code>. Thus, instead of</p> <pre><code>[ "" = "&lt;variable&gt;" ] </code></pre> <p>becoming [ = value ] and yielding an error,</p> <pre><code>[ "X" = "X&lt;variable&gt;" ] </code></pre> <p>becomes [ X = Xvalue ]</p> <p>and the comparison may continue</p>
18,286,663
0
<p>This is the string you are printing:</p> <pre><code>"&lt;td&gt; £ $first_number = {$row['bcosts']}; $second_number = {$row['rcosts']}; $third_number = {$row['value']}; $sum_total = $third_number - $second_number - $first_number; print ($sum_total); &lt;/td&gt; "; </code></pre> <p>The variables get replaced with their values:</p> <pre><code>"&lt;td&gt; £ = 100; = 25; = 300; = - - ; print (); &lt;/td&gt; "; </code></pre> <p>And the browser converts multiple whitespace characters into one space when displaying.</p> <p>You cannot calculate stuff during inside the string. This should fix it:</p> <pre><code>"&lt;td&gt; £"; $first_number = $row['bcosts']; $second_number = $row['rcosts']; $third_number = $row['value']; $sum_total = $third_number - $second_number - $first_number; print ($sum_total); echo "&lt;/td&gt; "; </code></pre>
1,907,218
0
<p>You could do something like this:</p> <pre><code>public class MyString { public static implicit operator string(MyString ms) { return "ploeh"; } } </code></pre> <p>The following unit test succeeds:</p> <pre><code>[TestMethod] public void Test5() { MyString myString = new MyString(); string s = myString; Assert.AreEqual("ploeh", s); } </code></pre> <p>In general however, I don't think this is a sign of good API design, because I <strong>prefer explicitness instead of surprises</strong>... but then again, I don't know the context of the question...</p>
2,401,154
0
<p>If you want the text of each cell to be captured as a singe space-separated string to populate your input, you can do this:</p> <pre><code>$(document).ready(function() { $('#table tr').click(function() { var $test = $(this).find('td').map(function() { return $(this).text(); }).get().join(" "); $('#input').val($test); }); }); </code></pre> <p>EDIT just call <a href="http://api.jquery.com/text/" rel="nofollow noreferrer"><code>text()</code></a>, e.g.:</p> <pre><code>var $field1 = $(this).find('td.field1').text(); </code></pre>
31,652,057
0
How to set true or false if there is no record in table using hibernate <p>I am using Spring REST with Hibernate and i am fetching a particular record from database table passing id into my method. The method is working properly but if there is no record in table then i want false in a variable and if record exist then i want true in the variable in my json object.</p> <p>Here is my Entity class <strong>Subscribe.java</strong></p> <pre><code>@Entity @Table(name="subscribe") @JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) public class Subscribe implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue @Column(name="id") private long id; @Column(name="subscribed_id") private String subID; @Column(name="subscriber_id") private long subrID; public long getSubrID() { return subrID; } public void setSubrID(long subrID) { this.subrID = subrID; } public String getSubID() { return subID; } public void setSubID(String subID) { this.subID = subID; } public long getId() { return id; } public void setId(long id) { this.id = id; } } </code></pre> <p>Here is my <strong>DAO</strong> class</p> <pre><code>@SuppressWarnings({ "unchecked", "rawtypes" }) public List&lt;Subscribe&gt; getSubscribeById(long id) throws Exception { session = sessionFactory.openSession(); Criteria cr = session.createCriteria(Subscribe.class); cr.add(Restrictions.eq("subrID", id)); List results = cr.list(); tx = session.getTransaction(); session.beginTransaction(); tx.commit(); return results; } </code></pre> <p>And here is my <strong>Controller</strong></p> <pre><code> @RequestMapping(value = "/subscribe/{id}", method = RequestMethod.GET) public @ResponseBody List&lt;Subscribe&gt; getSubscriber(@PathVariable("id") long id) { List&lt;Subscribe&gt; sub = null; try { sub = profileService.getSubscribeById(id); } catch (Exception e) { e.printStackTrace(); } return sub; } </code></pre> <p>Please suggest me how can can i do this</p>
39,397,504
0
Angular2 replace attribute when value contains curly brackets <p>I'm checking the value of this attribute <code>dummy-data</code> but when the value contains curly brackets Angular2 is renaming the attribute </p> <p><a href="https://monosnap.com/file/qHi9G2XFS87J8qlmNNIG3HNP6AGaG8" rel="nofollow">In Editor</a></p> <p><code>&lt;c-heading-image dummy-data="images.{{content.image}}"&gt;&lt;/c-heading-image&gt;</code></p> <p><a href="https://monosnap.com/file/jUG63JLY0CLlvwmaVUEvE11iwCBuJH" rel="nofollow">In Browser</a></p> <p><code>&lt;c-heading-image ng-reflect-dummy-data="images.regular"&gt;&lt;/c-heading-image&gt;</code></p> <p>How can I prevent Angular2 from renaming the Attribute</p> <p>I'm using Ionic framework 2</p>
32,688,718
0
export yajra datatable all data to csv <p>I'm not able to find any solution for saving all the records to CSV using yajra datatables.</p> <p>Currently i'm getting paginated records that are displaying on current screen (10 records), what i need is all the records</p> <p>I'm using yajra datatables buttons extension.</p> <p>My current code is :</p> <pre><code> $('#export-table').DataTable({ dom: 'Bfrtip', processing: true, serverSide: true, responsive: true, autoWidth:false, aaSorting: [[6, 'desc']], ajax: '{!! route('export.data') !!}', aoColumns: [ {mData:'name', name: 'name'}, {mData:'address', name: 'address'}, {mData:'phone', name: 'phone'}, {mData:'cell_phone', name: 'cell_phone'}, {mData:'email', name: 'm.email'}, {mData:'company', name: 'company'}, {mData:'date_taken', name: 'date_taken'} ], buttons: ['csv'] }); </code></pre> <p>Need help to save all records to csv</p> <p><strong>UPDATE</strong></p> <p>I'm using yajra datatables plugin with laravel 5.0</p>
32,388,830
0
Assigning different weights to different users' sentiment and displaying in geospatial analysis in Python and ArcGIS <p>I have the following data:</p> <pre><code>PERSON POWER_USER DATE TIME SENTIMENT LOCATION WEIGHT Person A Yes 3/5/2015 12:00 0.8 LA 1.5 Person A Yes 3/5/2015 12:01 0.7 LA 1.5 Person B No 3/5/2015 14:00 -0.5 LA 1 Person B No 3/5/2015 15:00 0.1 LA 1 Person A Yes 3/5/2015 16:00 0.4 LA 1.5 Person D Yes 3/5/2015 17:00 -0.1 WA 1.5 </code></pre> <p>I would like to compute an "average" sentiment score by location. But for power-user I would like to assign, say, 1.5x the weight for their sentiment since they are more influential. How can I do that with ArcGIS, Arcpy, or any geospatial analysis tool?</p> <p>NOTE: I do know how to do this without the weight consideration in Arcgis.</p>
26,989,491
0
<p>You have some bugs in your getMessages function in the while loop:<br/> 1. use <code>count += len(rs)</code><br/> 2. The major bug: you don't need the </p> <pre><code>or len(rs) &lt; 10 </code></pre> <p>condition because SQS can get up to 10 messages and if your queue is full and each time you get 10 messages you'll have an infinite loop.</p> <p>Also I think you should consider using <code>yield</code> statement to return the messages, process them and after they are processed, only then , remove them from Queue.</p> <p>One more thing, the pythonic way to check <code>if len(rs) &lt; 1:</code> is <code>if not rs:</code></p>
9,327,995
0
<p><a href="http://stackoverflow.com/questions/6682031/net-moles-stub-fallthrough-behaviour">This post</a> gives the answer:</p> <pre><code>MolesContext.ExecuteWithoutMoles(() =&gt; instance.Country_Id = id); </code></pre>
3,216,285
0
Ruby on Rails: How do I specify which method a form_tag points to? <p>I have this:</p> <pre><code>&lt;% form_tag :controller =&gt; :proposals, :method =&gt; :bulk_action do %&gt; </code></pre> <p>but it errors in the create method... which is weird because I'm trying to tell stuff to delete.</p>
31,237,587
0
<p>This is because you're using a <code>DISTINCT</code> in your <code>SELECT</code> query. If you look at the execution plan, you can see <code>DISTINCT SORT</code> operation. This sorts your result based on the <code>DISTINCT</code> columns you specify, in this case it's <code>Name</code>:</p> <p><img src="https://i.stack.imgur.com/0zHNV.png" alt="enter image description here"></p> <p>To retain the order, you can try this:</p> <pre><code>set @var = stuff(( select ',' + name from( select name, drn, rn = row_number() over(partition by name order by drn) from temp )t where rn = 1 order by drn for xml path('')), 1,1,'') </code></pre>
5,239,230
0
<p>You could try setting a repeat count on your Animation to imagecount-1, then adding an AnimationListener to your animation that changes the background image of the ImageView on every repeat and on start.</p> <p>Here's a simple example that uses RoboGuice (which makes the code cleaner but doesn't make any difference for the purposes of your question): <a href="https://github.com/bostonandroid/batgirl/blob/master/src/org/roboguice/batgirl/Batgirl.java" rel="nofollow">https://github.com/bostonandroid/batgirl/blob/master/src/org/roboguice/batgirl/Batgirl.java</a></p> <pre><code>public class Batgirl extends RoboActivity { // Views @InjectView(R.id.content) LinearLayout linearLayout; // Resources @InjectResource(R.anim.spin) Animation spin; @InjectResource(R.integer.max_punches) int MAX_PUNCHES; // Other Injections @Inject ChangeTextAnimationListener changeTextAnimationListener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Set up the animation linearLayout.setAnimation(spin); spin.setAnimationListener(changeTextAnimationListener); spin.setRepeatCount(MAX_PUNCHES - 1); spin.start(); } } /** * A simple animation listener that swaps out the text between repeats. */ class ChangeTextAnimationListener implements AnimationListener { @InjectView(R.id.hello) TextView helloView; @Inject Fist fist; @Inject PackageInfo info; public void onAnimationRepeat(Animation animation) { onAnimationStart(animation); } public void onAnimationStart(Animation animation) { helloView.setText( getNextTextString() ); // getNextTextString() not shown in this example } public void onAnimationEnd(Animation animation) { } } </code></pre>
18,603,273
0
NodeJS Code Coverage of Automated Tests <p>As part of a custom testing framework for a NodeJS REST API, I'd like to automatically detect when my tests are no longer providing proper coverage by comparing all <em>possible</em> outcomes with what the test suite received. </p> <p>What methods exist for doing this? We can assume that it's being used for a REST API with a list of entry functions (API endpoints) that need coverage analysis, and each entry function will end with a known 'exit function' that responds to the requester in a standard way. </p> <p>Here's what I've found so far:</p> <p><strong>1: Basic solution (Currently implemented)</strong></p> <ul> <li>When writing each REST endpoint, manually create a list of all the possible outcome 'codes' [Success, FailureDueToX, FailureDueToY] for example</li> <li>After the tests have run, ensure every code in the list has been seen by the test suite for each endpoint. </li> </ul> <p><em><strong>Pros:</strong></em> Very basic and easy to use; Doesn't change performance testing times</p> <p><em><strong>Cons:</strong></em> Highly prone to error with lots of manual checking; Doesn't flag any issues if there are 5 ways to 'FailDueToX' and you only test 1 of them. Very basic definition of 'coverage'</p> <p><strong>2: Static analysis</strong></p> <ul> <li>Parse the code into some sort of parse tree and look for all the instances of the 'exit function'</li> <li>Traverse up the tree until an API Endpoint is reached, and add that exit instance to the endpoint as an expected output (needs to keep a record of the stack trace to get there via a hash or similar)</li> <li>When tests are run, the endpoints return the stack trace hash or similar and this is compared to the expected output list.</li> </ul> <p><em><strong>Pros:</strong></em> Automatic; Catches the different branches that may result in the same output code</p> <p><em><strong>Cons:</strong></em> Generating the parse tree is non trivial; Doesn't detect dead code that never gets run; test suite needs to be kept in sync</p> <p><strong>3: Profiling</strong></p> <p>I've done this in the past on Embedded Systems with <a href="http://www.ghs.com/products/safety_critical/gcover.html" rel="nofollow">GreenHills Code Coverage Tools</a></p> <ul> <li>Start up a profiler like <a href="http://blog.nodejs.org/2012/04/25/profiling-node-js/" rel="nofollow">dtrace</a> and record the stack log for each test separately</li> <li>Parse the stack log and assign the 'test' to each line of code</li> <li>Manually analyse the code-with-annotations to find gaps.</li> </ul> <p><em><strong>Pros:</strong></em> Semi Automatic; Gives more information about total coverage to a developer; Can see </p> <p><em><strong>Cons:</strong></em> Slows down the tests; Unable to do performance testing in parallel; Doesn't flag when a possible outcome is never made to happen. </p> <p>What else is there, and what tools can help me with my Static Analysis and Profiling goals? </p>
21,052,915
0
<p>You can specify the mime type and content encoding explicitly, e.g.</p> <pre><code>d3.dsv(fieldSeparator, "text/plain; charset=ISO-8859-1"); </code></pre>
39,745,238
0
<p>Using java 8 shouldn't give this problem but it did for me</p> <p>I created my jar initially from Eclipse Export -> Runnable Jar and it was fine. When I moved to Maven it failed with the above. </p> <p>Comparing the two jars showed that nothing fx related was packaged with the jar (as I'd expect) but that the Eclipse generated manifest had <code>Class-Path: .</code> in it. Getting maven to package the jar with the following worked for me (with Java 8)</p> <pre><code> &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;archive&gt; &lt;manifest&gt; &lt;addClasspath&gt;true&lt;/addClasspath&gt; &lt;mainClass&gt;com.pg.fxapplication.Main&lt;/mainClass&gt; &lt;/manifest&gt; &lt;manifestEntries&gt; &lt;Class-Path&gt;.&lt;/Class-Path&gt; &lt;/manifestEntries&gt; &lt;/archive&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; </code></pre>
32,066,755
0
<p>Try to install <em>libmozjs</em>, then (don't forget to do a <em>sudo ldconfig</em> first) compile from the source elinks.</p> <pre><code>wget http://elinks.or.cz/download/elinks-current-0.13.tar.bz2 tar xjvf elinks-current-0.13.tar.bz2 cd elinks-0.13* ./configure make -j8 sudo make install </code></pre> <p>Check after ./configure if <em>ECMAScript</em> is flagged <em>SpiderMonkey document scripting</em>.</p> <p>p.s. Ubuntu 14.04 here.</p>
25,411,435
0
<p>You can also specify your insert using and update like syntax which some find more readable.</p> <pre><code>INSERT INTO customers SET field1 = value1 , field2 = value2 , field3 = value3 </code></pre> <p>et cetera...</p>
35,866,624
0
openweathermap API issue with mobile app <p>I am using openweathermap API in my iOS app.</p> <p>Below is my URL which i am call for get whether info.</p> <p><a href="http://api.openweathermap.org/data/2.5/weather?lat=21.282778&amp;lon=-157.829444&amp;APPID=MYAPPID&amp;lang=en-US" rel="nofollow">http://api.openweathermap.org/data/2.5/weather?lat=21.282778&amp;lon=-157.829444&amp;APPID=MYAPPID&amp;lang=en-US</a></p> <p>While open this url in browser i got response properly.</p> <p>But when i call Web-service from my iOS app i do not get response. I get below error :</p> <pre><code>{ cod = 401; message = "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."; } </code></pre> <p>I had created API key from this URL : <a href="http://home.openweathermap.org/" rel="nofollow">Create API key on Open Wheather</a></p>
30,672,928
0
MATLAB error in ode45: must return a column vector <p>I am getting this error in my code: </p> <ul> <li><strong>Error using odearguments (line 91) @(T,C)(C1.*((V1.<em>P_OPEN)+V2).</em>(CA_ER-C))-((V3.*(C.^2))/(C.^2+(K3^2))) must return a column vector.</strong></li> </ul> <p>But in the MATLAB documentation there is an example <a href="http://mathworks.com/help/matlab/ref/ode45.html?s_tid=srchtitle#zmw57dd0e475194" rel="nofollow">Example 3</a> where the vectors are given as input but it works just fine. Why is that I get an error in my code?<br> This is my code: </p> <pre><code>Ca_ER = 10e-6; c0 = 2e-6; c1 = .185; v1 = 6; v2 = .11; v3 = .09e6; v4 = 1.2; k3 = .1e-6; a1 = 400e6; a2 = 0.2e6; a3 = 400e6; a4 = 0.2e6; a5 = 20e6; b2 = .21; d1 = 0.13e-6; d2 = b2/a2; d3 = 943.4e-9; d4 = d1*d2/d3; d5 = 82.34e-9; IP= .5e-6; Ca=.001e-6:.01e-6:1e-6; num=Ca.*IP.*d2; deno= (Ca.*IP+ IP*d2+d1*d2+Ca.*d3).*(Ca+d5); p_open=( num./deno).^3; %this is the vector input dc=@(t,c) (c1.*((v1.*p_open)+v2).*(Ca_ER-c))-((v3.*(c.^2))/(c.^2+(k3^2))); [t,c]=ode45(dc,linspace(0, 100, 1000),.19e-6); plot(t,c); </code></pre>
19,899,982
0
<p>Apple doesn't offer support for that, but one workaround could be to use a category for UIImage with a method that loads the right version based on the OS version:</p> <pre><code>+(UIImage)imageNamed2:(NSString *)imageName{ NSString *finalImageName; if([[UIDevice currentDevice].systemVersion floatValue] &gt;= 7){ finalImageName = [NSString stringWithFormat:@"ios7-%@",imageName]; }else{ finalImageName = imageName; } return [self imageNamed:finalImageName]; } </code></pre> <p>This way, the images would be named:</p> <pre><code>example.png [email protected] [email protected] </code></pre> <p>And you can instantiate the image this way:</p> <pre><code>[UIImage imageNamed2:@"example.png"]; </code></pre> <p>Hope this helps</p>
5,122,806
0
ColdFusion Calendar - How can I find day from days in month? <p>Here's my code. I got it from a tutorial online.</p> <pre><code>&lt;CFPARAM NAME = "month" DEFAULT = "#DatePart('m', Now())#" /&gt; &lt;CFPARAM NAME = "year" DEFAULT = "#DatePart('yyyy', Now())#" /&gt; &lt;CFPARAM NAME = "currentday" DEFAULT = "#DatePart('d', Now())#" /&gt; &lt;CFPARAM NAME = "startmonth" DEFAULT = "#DatePart('m', Now())#" /&gt; &lt;CFPARAM NAME = "startyear" DEFAULT = "#DatePart('yyyy', Now())#" /&gt; &lt;cfset ThisMonthYear = CreateDate(year, month, '1') /&gt; &lt;cfset Days = DaysInMonth(ThisMonthYear) /&gt; &lt;cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear) /&gt; &lt;cfset LastMonth = DatePart('m', LastMonthYear) /&gt; &lt;cfset LastYear = DatePart('yyyy', LastMonthYear) /&gt; &lt;cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear) /&gt; &lt;cfset NextMonth = DatePart('m', NextMonthYear) /&gt; &lt;cfset NextYear = DatePart('yyyy', NextMonthYear) /&gt; </code></pre> <p>and here is my output code.</p> <pre><code>&lt;a href="calendar_day.cfm?month=#month#&amp;day=#THE_DAY#&amp;year=#year#"&gt; </code></pre> <p>I'm using this for a visible calendar, and want to be able to select the day from all days in the month. Is there any way to determine the day of the month when clicking on the day in the monthly calendar view?</p>
29,602,315
0
if(isset($_POST['submit'])){ } NOT WORKING on submit button <p>I have a problem where when ever I load my page it says that the form is done even when I don't press submit here is the code - </p> <pre><code>&lt;?php $db_host = 'localhost'; $db_name = 'info';enter code here $db_user = 'root'; $db_password = ''; try { $db = new PDO('mysql:host=' . $db_host . ';dbname=' . $db_name, $db_user, $db_password); echo "connected&lt;br&gt;&lt;br&gt;"; } catch (PDOException $e) { echo "Error: " . $e-&gt;getMessage(); die(); } if(isset($_POST['submit'])){ $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $info = $_POST['info']; $date = $_POST['date']; $sql = "INSERT INTO info (name, phone, email, info, date)"; $sql .= " VALUES (:name, :phone, :email, :info, :date)"; $query = $db-&gt;prepare($sql); $query-&gt;execute(array( ':name' =&gt; $name, ':phone' =&gt; $phone, ':email' =&gt; $email, ':info' =&gt; $info, ':date' =&gt; $date )); echo "done&lt;br&gt;"; } ?&gt; </code></pre>
16,182,300
0
SCP error: Bad configuration option: PermitLocalCommand <p>When I execute this command below:</p> <pre><code>scp -P 36000 [email protected]:~/tmp.txt SOQ_log.txt </code></pre> <p>I get an error:</p> <pre><code>command-line: line 0: Bad configuration option: PermitLocalCommand </code></pre> <p>Does anyone know why?</p>
12,891,500
0
asp.net website builds fine but publish gives error <p>I am working on asp.net website using ablecommerce asp.net CMS. I am trying to build the website and it works. but when I try to publish the website locally to deploy it on IIS, I start getting errors that this page is not available etc. I see that the page not found errors are actually located in some dll and reference is added.</p> <p>Errors are like this:</p> <pre><code>Error 5 The type or namespace name 'admin_orders_create_creditcardpaymentform_ascx' does not exist in the namespace 'ASP' (are you missing an assembly reference?) \Final Code\WebSite\Admin\Orders\Create\CreateOrder4.aspx.cs </code></pre> <p>Regards, Asif Hameed</p>
4,881,076
0
<p>Have you tried creating an XmlWriter with the encoding set to latin-1 and then saving the XDocument using it? I haven't tried it, but it might coerce it to use unnecessary character entities.</p> <p>And what kind of horrible software are you using if it doesn't even support Unicode?</p>
3,784,092
0
<p>The argument passed to <code>mysql_insert_id</code> is the resource of a database connection. You're feeding it the result of a MySQL query. Just <code>mysql_insert_id()</code> by itself <em>should</em> work unless you're opening multiple database connections. </p> <p><a href="http://us3.php.net/mysql_insert_id">http://us3.php.net/mysql_insert_id</a></p>
9,119,303
0
<p>Not exactly what you were asking for but as a Java programmer that spent some time with <a href="http://www.scala.org/" rel="nofollow">Scala</a> I've liked <a href="http://code.google.com/p/guava-libraries/" rel="nofollow">Google Guava</a> implementation of <a href="http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Optional.html" rel="nofollow">Optional</a> idiom.<br> <a href="http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000047.html" rel="nofollow">Elvis and Safe Operator Proposal</a> didn't make it into Java 7, maybe for 8. <a href="http://stackoverflow.com/questions/271526/how-to-avoid-null-statements-in-java">This stackoverflow topic</a> may be a interesting read too. </p>
25,642,524
0
Behat base_url issue or sqlite database <p>I access my page at <a href="http://web.dev/web/app_behat.php" rel="nofollow">http://web.dev/web/app_behat.php</a> and it works when I do it manually in browser.</p> <p>So I set</p> <pre><code>base_url: "http://web.dev/web/app_behat.php/" </code></pre> <p>and I get no route matched for any route but if i set</p> <pre><code>base_url: "http://web.dev/app_behat.php/" </code></pre> <p>route seems to be matched but i get missing table error, i have set up <a href="https://github.com/Behat/CommonContexts#example-using-symfonydoctrinecontext-to-reset-doctrine" rel="nofollow">SymfonyDoctrineContext</a> to take care of schema creation.</p> <p>Full behat.yml:</p> <pre><code>default: formatter: name: progress context: class: FootballRadar\Features\Context\FeatureContext extensions: Behat\Symfony2Extension\Extension: mink_driver: true kernel: env: test debug: true Behat\MinkExtension\Extension: base_url: "http://web.dev/app_behat.php/" default_session: symfony2 show_cmd: 'open -a "Google Chrome" %s' </code></pre> <p>EDIT:</p> <p>My config_behat.yml:</p> <pre><code>imports: - { resource: "config_dev.yml" } assetic: debug: true use_controller: enabled: true profiler: false framework: test: ~ session: storage_id: session.storage.mock_file profiler: collect: false web_profiler: toolbar: false intercept_redirects: false swiftmailer: disable_delivery: true doctrine: dbal: connections: default: driver: pdo_sqlite user: behat path: %kernel.root_dir%/behat/default.db.cache charset: utf8 model: driver: pdo_sqlite user: behat path: %kernel.root_dir%/behat/model.db.cache charset: utf8 monolog: handlers: test: type: test </code></pre> <p>Seems that all of You misunderstood my question and/or completely ignored my first sentence.</p> <p>I have a working application and I access it using </p> <p><a href="http://web.dev/web/" rel="nofollow">http://web.dev/web/</a> (<a href="http://web.dev/web/app.php/" rel="nofollow">http://web.dev/web/app.php/</a>) &lt;-- for prod</p> <p><a href="http://web.dev/web/app_dev.php/" rel="nofollow">http://web.dev/web/app_dev.php/</a> &lt;-- for dev</p> <p><a href="http://web.dev/web/app_behat.php/" rel="nofollow">http://web.dev/web/app_behat.php/</a> &lt;-- for behat</p> <p>all of them work as when i use them manually in chrome or other browser</p> <p>That is why I am surprised why <code>http://web.dev/web/app_behat.php/</code> gives me</p> <pre><code>No route found for "GET /web/app_behat.php/login" </code></pre> <p>and</p> <p><code>http://web.dev/app_behat.php/</code> gives</p> <pre><code>SQLSTATE[HY000]: General error: 1 no such table: users_new </code></pre> <p>With little debugging I confirmed <code>SymfonyDoctrineContext</code> does read my entities mappings and issues queries to create db schema, both db files have read/write permissions (for sake of test I gave them 777)</p> <p>Another thing I just realised, all this errors gets written to <code>test.log</code> file instead of <code>behat.log</code>. I create kernel with <code>$kernel = new AppKernel('behat', true);</code></p> <p>Maybe I just greatly misunderstood how behat is supposed to work?</p> <p>EDIT2:</p> <p>I have noticed that there are no entries made to apache access log when running behat feature for either of the paths</p> <p>versions i'm using from composer.json</p> <pre><code> "behat/behat": "2.5.*@dev", "behat/common-contexts": "1.2.*@dev", "behat/mink-extension": "*", "behat/mink-browserkit-driver": "*", "behat/mink-selenium2-driver": "*", "behat/symfony2-extension": "*", </code></pre>
32,783,381
0
<p>Assuming you still can get the node by id, you can check if the Name property is null</p> <pre><code>string.IsNullOrEmpty(node.Name) </code></pre> <p>It's not pretty but should work</p>
5,696,783
0
<p>Martin's remark is saying that only directly self-recursive calls are candidates (other criteria being met) for the TCO optimization. Indirect, mutually recursive method pairs (or larger sets of recursive methods) cannot be so optimized.</p>
37,967,422
0
Tab is out of focus on clicking outside <p>I have a webpage with four tabs. It is working fine except when I click outside the div,containing the tabs and its contents, the focus on the active tab is lost which is not desired.</p> <p><strong>Code</strong></p> <pre><code>&lt;body&gt; &lt;img src="images/2.png" style="width: 950px; height: 60px;"&gt; &lt;div style="margin-top: -50px; margin-left: 5px; position: absolute; font-size: 32px; color: green;"&gt;Test &lt;/div&gt; &lt;div style="width: 69px; height: 57px; margin-left: 951px; margin-top: -58px;"&gt; &lt;a href="#" title="Logout"&gt;&lt;img src="images/logout.png" style="width: 78px; height: 73px;"&gt;&lt;/a&gt; &lt;/div&gt; &lt;div style="margin-top: 100px;"&gt; &lt;ul id="tabs" class="tab"&gt; &lt;li&gt;&lt;a id="load" href="#" class="tablinks" onclick="openTab(event, 'Reference')"&gt;Reference&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="tablinks" onclick="openTab(event, 'TestStrategy')"&gt;Test Strategy&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="tablinks" onclick="openTab(event, 'TestCase')"&gt;Test Case&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="tablinks" onclick="openTab(event, 'TestSummary')"&gt;Test Summary&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;img src="images/line.png" style="margin-top: -14px; margin-left: 6px; width: 700px; height: 4px; position: absolute;"&gt; &lt;div id="Reference" class="tabcontent"&gt; &lt;p&gt;Document_1.docx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;Document_2.docx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;Document_3.docx&lt;/p&gt; &lt;hr align="left"&gt; &lt;/div&gt; &lt;div id="TestStrategy" class="tabcontent"&gt; &lt;p&gt;TS_1.docx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;TS_2.docx&lt;/p&gt; &lt;hr align="left"&gt; &lt;/div&gt; &lt;div id="TestCase" class="tabcontent"&gt; &lt;p&gt;TC_1.xlsx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;TC_2.xlsx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;TC_3.xlsx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;TC_4.xlsx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;TC_5.xlsx&lt;/p&gt; &lt;hr align="left"&gt; &lt;/div&gt; &lt;div id="TestSummary" class="tabcontent"&gt; &lt;p&gt;Summary_1.docx&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;Summary_2.pdf&lt;/p&gt; &lt;hr align="left"&gt; &lt;p&gt;Summary_3.ppt&lt;/p&gt; &lt;hr align="left"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Here is a <a href="http://jsfiddle.net/heh9ptvy/" rel="nofollow">fiddle</a>.</p> <p>How to resolve this?</p>
28,861,046
0
<ol> <li><p>You're using the GET method, which gets an app link url that was already created using the API, but will not create new ones.</p></li> <li><p>You can't create them from mobile devices since they require an app access token (not a user access token). If you look at the "Publishing" section of the documentation, you'll see that there's no Android or iOS code snippets.</p></li> <li><p>For detailed instructions on how to create an app link hosting url (from the command line, or server side), follow the steps here: <a href="https://developers.facebook.com/docs/applinks/hosting-api" rel="nofollow">https://developers.facebook.com/docs/applinks/hosting-api</a></p></li> </ol>
8,683,811
0
How does one get the number of rows in an SQL database?(Android SDK) <p>I looked for this on SO and saw this(and others like it): <a href="http://stackoverflow.com/questions/3408669/sql-direct-way-to-get-number-of-rows-in-table">sql direct way to get number of rows in table</a>, however, Select is shown as a token as is count. I tried to use mDb.execSQL() but that only returns void. Any help on how to do this would be appreciated. The code is:<br> public int getRowNumber(){ return mDb.execSQL("SELECT COUNT(*) FROM notes");} I get an error that says "cannot return void result". </p>