pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
4,854,427
0
<p>Are you trying to do different things if the objects in the array are of different classes? You could do something like this:</p> <pre><code>for (id obj in myArray) { // Generic things that you do to objects of *any* class go here. if ([obj isKindOfClass:[NSString class]]) { // NSString-specific code. } else if ([obj isKindOfClass:[NSNumber class]]) { // NSNumber-specific code. } } </code></pre>
8,102,796
0
<h2>Using native <code>Array.filter</code></h2> <p>If you are targeting only modern browsers (IE9+ or a <a href="http://kangax.github.com/es5-compat-table/" rel="nofollow">recent version</a> of any other major browser) you can use the JavaScript 1.6 array method <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter" rel="nofollow"><code>filter</code></a>.</p> <pre><code>var testItem, data = [{"id":"item-1","href":"google.com","icon":"google.com"}, {"id":"item-2","href":"youtube.com","icon":"youtube.com"}, {"id":"item-3","href":"google.com","icon":"google.com"}, {"id":"item-4","href":"google.com","icon":"google.com"}, {"id":"item-5","href":"youtube.com","icon":"youtube.com"}, {"id":"item-6","href":"asos.com","icon":"asos.com"}, {"id":"item-7","href":"google.com","icon":"google.com"}, {"id":"item-8","href":"mcdonalds.com","icon":"mcdonalds.com"}]; function getItemById(data, id) { // filter array down to only the item that has the id // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter var ret = data.filter(function (item) { return item.id === id; }); // Return the first item from the filtered array // returns undefined if item was not found return ret[0]; } testItem = getItemById(data, 'item-3'); </code></pre> <p><a href="http://jsfiddle.net/cwGeu/2/" rel="nofollow">Working example</a></p> <h2>Manually looping over the data</h2> <p>If you can't use filter you are probably stuck with just using a loop:</p> <pre><code>var testItem, data = [{"id":"item-1","href":"google.com","icon":"google.com"}, {"id":"item-2","href":"youtube.com","icon":"youtube.com"}, {"id":"item-3","href":"google.com","icon":"google.com"}, {"id":"item-4","href":"google.com","icon":"google.com"}, {"id":"item-5","href":"youtube.com","icon":"youtube.com"}, {"id":"item-6","href":"asos.com","icon":"asos.com"}, {"id":"item-7","href":"google.com","icon":"google.com"}, {"id":"item-8","href":"mcdonalds.com","icon":"mcdonalds.com"}]; function getItemById(data, id) { var i, len; for (i = 0, len = data.length; i &lt; len; i += 1) { if(id === data[i].id) { return data[i]; } } return undefined; } testItem = getItemById(data, 'item-3'); </code></pre> <p><a href="http://jsfiddle.net/gMcRB/1/" rel="nofollow">Working example</a></p> <p>Even though brute-forcing it with a loop might seem less elegant than using <code>Array.filter</code>, it turns out that in most cases the <a href="http://jsfiddle.net/53v3G/" rel="nofollow">loop is faster than <code>Array.filter</code></a>.</p> <h2>Refactoring to an object instead of an array</h2> <p>The best solution, assuming that the <code>id</code> of each of your items is unique, would be refactoring the way you are storing the data. Instead of an array of objects, use an object that uses the <code>id</code> as a key to store an object containing the <code>href</code> and <code>icon</code> key/property values.</p> <pre><code>var data = { "item-1": {"href": "google.com", "icon": "google.com"}, "item-2": {"href": "youtube.com", "icon": "youtube.com"}, "item-3": {"href": "google.com", "icon": "google.com"}, "item-4": {"href": "google.com", "icon": "google.com"}, "item-5": {"href": "youtube.com", "icon": "youtube.com"}, "item-6": {"href": "asos.com", "icon": "asos.com"}, "item-7": {"href": "google.com", "icon": "google.com"}, "item-8": {"href": "mcdonalds.com", "icon": "mcdonalds.com"} }; </code></pre> <p>This would make accessing items even easier and faster:</p> <pre><code>var data = JSON.parse(localStorage.getItem("result")); data["item-3"].href; </code></pre>
27,406,014
0
How to customize UITableView separator when the cells got a custom height <p>I followed this post: <a href="http://stackoverflow.com/questions/1374990/how-to-customize-tableview-separator-in-iphone">How to customize tableView separator in iPhone</a></p> <p>Problem is that it doesn't work well when I have custom height for my cell.</p> <p>I'll show you with two images, the one with two lines is the result of having a custom height for my cells.</p> <p><img src="https://i.stack.imgur.com/VzWI6.png" alt="enter image description here"></p> <p>With custom height: <img src="https://i.stack.imgur.com/cxc9d.png" alt="enter image description here"></p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)]; lineView.backgroundColor = [UIColor darkGrayColor]; [cell.contentView addSubview:lineView]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 50; } </code></pre>
27,316,625
0
Loop through element of a defined size in Jquery? <p>I'm creating an animation for my website where I got different divs containing an image and an aside where I put my text describing something related to the image. The aside is a little bit wider than my picture and what happens is that when I hover it, it slides to the right and has his width increased. </p> <p>When I hover another one the first one goes back to its initial position. So I found a solution that obliged me to naturally loop through all the divs that are not hovered, but the problem now is since every divs (including the one hovered last) is not hovered, they all get the animation (thus creating a visual bug because the aside is placed absolute and behind the image) while i'd like it to be only on the first one. </p> <p>So I thought I should loop through all the divs that are not hovered AND got a defined sized (the one they got after they are behind shown), but I couldnt get it work, neither did I find a solution to loop through elements with the each function... </p> <p>Here is my HTML code : </p> <pre><code> &lt;div class="partenaires-wrapper"&gt; &lt;img src="http://mylor.fr/mauro/wp-content/uploads/2014/08/sharks.png" alt="" width="223" height="138" /&gt; &lt;div class="partenaires-aside"&gt; Sed rutrum elementum odio, ut efficitur magna efficitur sit amet. Phasellus posuere eget felis non tempor. Morbi elementum, velit non aliquam suscipit, odio orci viverra felis, sit amet elementum tellus mauris a nunc. Aliquam nec nisl eget nunc pulvinar varius commodo id urna. Duis ac sem erat. Pellentesque aliquet posuere justo ac luctus. Aliquam porta placerat blandit. &lt;/div&gt; </code></pre> <p>and the Javascript part : </p> <pre><code>$(".partenaires-aside").mouseover(function () { $(".partenaires-aside").not(this).each(function () { $(this).delay( 800 ).animate({'width':'24%'}, 500); $(this).animate({'margin-left':'0%'}, 500); $(this).find("p").hide("slow"); }); $(this).animate({'margin-left':'30%'}, 500); $(this).animate({'width':'60%'}, 500); $(this).find("p").show("slow"); }); </code></pre> <p>I really dont know if made myself clear, but I hope you understood correctly. Thank you in advance for you help!</p>
34,438,181
0
<p>Actually you need to add the following folders:</p> <ul> <li>layout-sw320dp (xhdpi devices) </li> <li>layout-sw340dp (xxhdpi devices)</li> <li>layout-sw380dp (xxxhdpi devices)</li> </ul> <p>you must add folders only if you really need another whole layout in different devices. Other than that , use only default layout folder with proper layout structure and extract dimensions on different density folders.</p>
29,739,844
0
<p>It works! Here is my completed code for adding an event and deleting one that occurs at the same time.</p> <pre><code>function createEvent(calendarId,title,startDt,endDt,desc) { var cal = CalendarApp.getCalendarById(calendarID); var start = new Date(startDt); var end = new Date(endDt); var event = cal.createEvent(title, start, end, { description : desc }); var events = cal.getEvents(start, end, { search: 'open' }); for (i in events){ events[i].deleteEvent(); } }; </code></pre>
3,042,604
0
What happens when I create an index on a view? Are there any benefits versus using a table with indexes? <p>From what I understand the data will be "persisted" (physically stored, not just retrieved when i need it). Is this correct? </p> <p>If so what would be the advantage of using an indexed view versus just using a table?</p>
32,198,499
0
Unnecessary semicolon <p>Once I import v7-appcompat library into Eclipse, I get a warning described as "Unnecessary semicolon" at the end line of the R.java file. I attempt to remove it, but I guess I'm not able to. I appreciate any kind of help. Thanks in advance.</p>
19,192,060
0
<p>Ok, so I figured out a work around. Instead of using the <code>UserControl</code> object, I use the <code>Page</code> object to render the control as it will render the server controls properly. After this, I had to wrap my html code in a <code>form</code> object with <code>runat="server"</code>. Now I have no issues getting it.</p> <p>Downside is that I still have to make a call do databind the repeater as the <code>Load</code> event is never raised.</p> <p><strong>Control:</strong></p> <pre><code>&lt;form runat="server"&gt; &lt;table id="user-comments"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Created On&lt;/th&gt; &lt;th&gt;By&lt;/th&gt; &lt;th&gt;Comment&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;asp:Repeater ID="commentsRepeater" runat="server"&gt; &lt;ItemTemplate&gt; &lt;tr class="user-comment"&gt; &lt;td&gt;&lt;%#Eval("ReviewedOn")%&gt;&lt;/td&gt; &lt;td&gt;&lt;%#Eval("Reviewer")%&gt;&lt;/td&gt; &lt;td&gt;&lt;%#Eval("Comment")%&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/ItemTemplate&gt; &lt;/asp:Repeater&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p><strong>Code-behind</strong>:</p> <pre><code> public partial class UserComments : System.Web.UI.UserControl { public List&lt;CallReview&gt; Comments; public void BindComments() { commentsRepeater.DataSource = Comments; commentsRepeater.DataBind(); } } </code></pre> <p><strong>Code to render the control and get the raw HTML:</strong></p> <pre><code>//Will be used to load the control var loader = new Page(); var ctl = (UserComments)loader.LoadControl("~/Controls/UserComments.ascx"); //Set the comments property of the control ctl.Comments = _callAdapter.GetCallComments(callId); ctl.BindComments(); //Create streams the control will be rendered to TextWriter txtWriter = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(txtWriter); //Render the control and write it to the stream ctl.RenderControl(writer); //Return the HTML return txtWriter.ToString(); </code></pre>
4,596,520
0
<p>Performance isn't really a consideration, assuming that you're not talking about gigabytes of XML. Yes, it will take longer (XML is more verbose), but it's not going to be something that the user will notice.</p> <p>The real issue, in my opinion, is support for XML within JavaScript. <a href="http://en.wikipedia.org/wiki/ECMAScript_for_XML" rel="nofollow">E4X</a> is nice, but it isn't supported by Microsoft. So you'll need to use a third-party library (such as JQuery) to parse the XML.</p>
12,211,404
0
<p>In your first example, the path started at 125,275 and was at 125,275 again, before closing. Because 'Z' creates another smooth path segment connecting start and end point, you get that small loop. If you close it before returning to the startingpoint, you get the desired smooth shape touching all given points.</p> <p>This is the corrected version of the example path:</p> <pre><code>M125,275R 125,325 175,325 225,325 275,325 225,275 175,275Z </code></pre>
24,296,823
0
<p>Your design is correct. The number of tables is a reflection of the complexity (or not) of the application.</p> <p>The "paradigm to efficiently design this kind of scenario" is the relational model and you are designing in terms of tables because you are working within that paradigm.</p> <p>Your notions about "the downside" and "lookups" and "efficiency" presume implementation aspects without justification. The DBMS takes your declarations and updates and answers your queries and hides how. Implementation issues do arise, but far from the level of experience and knowledge suggested by your question.</p> <p>Just make a staightforward design.</p>
21,299,801
0
<blockquote> <p>Themes have to declare their support for post thumbnails before the interface for assigning these images will appear on the Edit Post and Edit Page screens. They do this by putting the following in their functions.php file:</p> <p><code>add_theme_support( 'post-thumbnails' );</code></p> </blockquote> <p>Source: <a href="http://codex.wordpress.org/Post_Thumbnails#Enabling_Support_for_Post_Thumbnails" rel="nofollow">http://codex.wordpress.org/Post_Thumbnails#Enabling_Support_for_Post_Thumbnails</a></p>
34,345,294
0
Is it possible to use socket.io between NodeJS and AngularJS <p>I have two independent applications (frontEnd and BackEnd). The backEnd is in NodeJS using express framework and the FrontEnd is in AngularJS. Is it possible to use socket.io to send a message from the server (NodeJS) to the client (AngularJS)? How I can do that? I've tried with the following code but it is not working:</p> <p>server code</p> <pre><code>var app = require('express')(); var server = require('http').Server(app); var io = require('socket.io')(server); io.sockets.on('connection', function(socket) { //This message is not showing console.log("socket"); socket.volatile.emit('notification', {message: 'push message'}); }); </code></pre> <p>client code</p> <pre><code>angular.module('pysFormWebApp') .factory('mySocket', function (socketFactory) { var mySocket = socketFactory({ prefix: 'foo~', ioSocket: io.connect('http://localhost:3000/') }); mySocket.forward('error'); return mySocket; }); angular.module('formModule') .controller('typingCtrl', ['$scope', 'mySocket', typingCtrl]); function typingCtrl ($scope, mySocket) { mySocket.forward('someEvent', $scope); $scope.$on('socket:someEvent', function (ev, data) { $scope.theData = data; console.log(data); }); </code></pre> <p>thanks for the help </p>
28,180,921
0
is there any way using plaint JS to get value of a css property of an element? <p>As far as I concern, .style.some_property only returns the value of the property if I setting it in javascript. If I don't, it returns empty string. So, is there any other way other than jQuery methods like css() and prop() to get value of a css property? </p>
10,156,891
0
php website and Jquery $.ajax() <p>The website I'm developing is structured in this way:</p> <p>It has a function that switches the module for the homepage content when <code>$_GET['module']</code> is set, example:</p> <pre><code>function switchmodules() { $module=$_GET['module']; switch($module) { case 'getnews': news(); break; default: def(); } } </code></pre> <p>As you can see, this switch calls another function for each module.</p> <p>For example I wrote <code>getNews()</code> to work in this way:</p> <pre><code>function getNews() { $id=$_GET['id']; if(!id) { //CODE TO LIST ALL NEWS } if(isset($id)) { //CODE TO GET ONLY 1 NEWS BY ID } } </code></pre> <p>So, as you can see I'm not using an unique file for each module; all operations of a module are part of an unique function in which an action is switched again to change the result.</p> <p>If I want to get a news from database I should use an url like this: <code>?index.php&amp;module=getnews&amp;id=1</code></p> <p>My question now is:<br> With jQuery and <code>$.ajax()</code> method is there a way to get a news (for example) using this structure based on functions switched by a get? Or do I have to change everything and make a file for each function?</p>
3,699,364
0
<p>CHCP returns the OEM codepage (OEMCP). The API is Get/SetConsoleCP. </p> <p>You can set the C++ locale to ".OCP" to match this locale.</p>
10,511,282
0
<p>Kind of standard <code>awk</code> way.</p> <pre><code>$ awk 'FNR==NR{sum+=$2;next}; {print $0,sum}' file.txt{,} 1 12 272 2 18 272 3 45 272 4 5 272 5 71 272 6 96 272 7 13 272 8 12 272 </code></pre>
31,295,261
0
How to get token from server BrainTree <p>How do I get the token from my server? I went the tedious process of simply getting the token to appear on my server but now I don't know how to pull it down and use it in my Android app. This is the method that Braintree suggested and it had a boat load of errors when I copied and pasted it. I managed to get past them but I had to implement a few methods that I don't think are right. </p> <p>All I need to be able to do is get the client token and use as a variable in my app. Someone please help. P.S. I'm really new at Android dev. </p> <pre><code>import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import com.loopj.android.http.*; import com.braintreepayments.api.dropin.BraintreePaymentActivity; import org.apache.http.Header; public class MainActivity extends ActionBarActivity { private int REQUEST_CODE; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } AsyncHttpClient client = new AsyncHttpClient(); public void fetchClientToken() { client.get("http://clomes.com/clomes/braintree/customer/gettoken", new TextHttpResponseHandler() { public String clientToken; @Override public void onFailure(int i, Header[] headers, String s, Throwable throwable) { } @Override public void onSuccess(int i, Header[] headers, String clientToken) { this.clientToken = clientToken; } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } </code></pre>
1,895,139
0
<p>There's many simple ways to do this in Rebol. It's interesting to use parse:</p> <pre><code>&gt;&gt; list: [system/history system/prompt] == [system/history system/prompt] &gt;&gt; parse list [(list-string: copy []) some [set path path! (append list-string mold path)]] == true &gt;&gt; list-string == ["system/history" "system/prompt"] </code></pre>
4,675,721
0
<p>Take a look here: <a href="http://dev.mysql.com/doc/refman/5.1/en/server-logs.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/server-logs.html</a> You're looking for general query log: <a href="http://dev.mysql.com/doc/refman/5.1/en/query-log.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.1/en/query-log.html</a></p>
34,797,753
0
<p>The argument you're passing to <code>pattern =</code> is where things are going wrong I believe. This three-step approach might get you the desired result:</p> <pre><code># Extract all .rds files list &lt;- list.files("Data/", pattern =".rds", full.names = TRUE) # Define pattern for grepl files &lt;- c(20388, 20389, 20390) pattern &lt;- paste(files, sep="", collapse="|") # Results in pattern [1] "20388|20389|20390" # grepl will interpret "|" as "or" # Now we can subset list with the following list[grepl(pattern,list)] </code></pre>
4,737,586
0
<p>This is answered (with examples) in the <a href="http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#SVG_web">svg primer</a>.</p> <p>tl;dr summary:</p> <ul> <li>remove 'width' and 'height' attributes on the svg root, and add a 'viewBox' attribute with the value "0 0 w h", where w and h are the absolute values usually found in the width and height attributes (note that percentages and other units aren't allowed in the viewBox attribute)</li> </ul>
31,760,685
0
<p>For the second regex, you essentially want "everything after (and including) the first letter". Thus you can simply try</p> <pre><code>string alphaPart = Regex.Match(s, @"[a-zA-Z].*").Value; </code></pre> <p>If you want to be more specific, you can restrict the "after" part to just the characters you expect, maybe</p> <pre><code>string alphaPart = Regex.Match(s, @"[a-zA-Z][a-zA-Z0-9 ()-]*").Value; </code></pre> <p>but you still need the leading <code>[a-zA-Z]</code> because otherwise you'd match the number part too.</p>
716,665
0
<p>The following should work:</p> <pre><code>if (get_magic_quotes_gpc()) { $content = stripslashes($content); } $content = mysql_real_escape_string($content); </code></pre> <p>If your column is utf8, you shouldn't have problems with special characters. Once you've formatted the content correctly, you can feed it to mysql using your standard insert methods.</p>
12,891,324
1
The view didn't return an HttpResponse object <p>This is the error I am getting: The view myapp.views.view_page didn't return an HttpResponse object</p> <p>Can anyone see what I'm doing wrong here? I can't seem to figure out why I would be getting that exception since I am returning an HttpResponseRedirect.</p> <p>views.py</p> <pre><code>from myapp.models import Page from django.shortcuts import render_to_response from django.http import HttpResponseRedirect from django.template import Template, RequestContext from django.core.context_processors import csrf def view_page(request, page_name): try: page = Page.objects.get(pk=page_name) except Page.DoesNotExist: return render_to_response("create.html", {"page_name" :page_name},context_instance=RequestContext(request)) content=page.content return render_to_response("view.html", {"page_name" :page_name , "content" :content},context_instance=RequestContext(request)) def edit_page(request, page_name): try: page = Page.objects.get(pk=page_name) content=page.content except Page.DoesNotExist: content = "" return render_to_response("edit.html", {"page_name" :page_name, "content" :content},context_instance=RequestContext(request)) def save_page(request, page_name): content = request.POST["content"] try: page = Page.objects.get(pk=page_name) page.content=content except Page.DoesNotExist: page = Page(name=page_name, content=content) page.save() return HttpResponseRedirect("/myproject/" + page_name + "/") </code></pre>
1,565,205
0
How to extend / amend OSGi lifecycle management? <p>I have a modular application that uses OSGi for lifecycle and dependency management. However, some of the bundles require some time after startup to be ready, for example, because they have to acquire data from somewhere. Also, they might be unable to process certain calls during a configuration update, for example a bundle that keeps a connection to a db can't send queries while it is updating the connection parameters.</p> <p>So, it seems to me that a bundle can have more subtle states than those managed by the OSGi container, and since they affect bundle interaction, there needs to be some handling. I can see three basic strategies for doing this:</p> <ul> <li>screw subtlety, and for example put all initialization code into <code>BundleActivator.start()</code>. If it takes forever to acquire that data, well then the bundle just won't be started forever. I'm not 100% sure that this would cover all cases, and it seems slightly wrong.</li> <li>fit my bundles with an additional event system that they use to notify each other of more subtle states like "momentarily unavailable" or "really ready now". This might simply be unnecessary overhead.</li> <li>have the bundle keep its more subtle state changes to itself and just take calls anyway, deferring them internally if necessary. This might not be appropriate when the caller could actually handle unavailability better.</li> </ul> <p><strong>Do you have any general advice on that? Is there even something in OSGi that I could use?</strong></p>
14,306,262
0
<p>I had the server techs update my server to MySql 5.5 and the issue is now fixed. I'm guessing it had something to do with the library or MySql install.</p>
27,561,141
0
<p>Please try this code:</p> <pre><code>package com.secondhandbooks.http; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Dictionary; import java.util.Enumeration; import java.util.List; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntity; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.DefaultHttpClient; import org.json.JSONObject; import android.app.ProgressDialog; import android.content.Context; import android.os.AsyncTask; import android.util.Log; import com.secondhandbooks.util.ConvertStreamIntoString; import com.secondhandbooks.util.SaveImageIntoDrawable; public abstract class BaseAsync_Post extends AsyncTask&lt;String, String, InputStream&gt; { Context context ; private HttpPost httppost; String url ; Dictionary&lt;String, String&gt; dictionary ; public BaseAsync_Post(String url , Dictionary&lt;String, String&gt; dictionary, Context context) { this.url = url ; this.dictionary = dictionary; this.context = context ; Enumeration&lt;String&gt; enumeration = dictionary.keys() ; showLogs("constructor") ; while ( enumeration.hasMoreElements() ) { showLogs( enumeration.nextElement() ) ; } } @Override abstract protected void onPreExecute() ; @Override abstract protected void onPostExecute(InputStream result) ; @Override protected InputStream doInBackground(String... params) { // TODO Auto-generated method stub // TODO Auto-generated method stub InputStream is = null; HttpClient httpclient = new DefaultHttpClient(); httppost = new HttpPost(url); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); try { List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(50); Enumeration&lt;String&gt; enumeration = dictionary.keys() ; while ( enumeration.hasMoreElements() ) { String key = enumeration.nextElement() ; if ( key.equals("file") ) { final File file = new File(SaveImageIntoDrawable.savedImagePath); if ( file.isFile() ) { showLogs("is file"); } else { showLogs("no-file"); } FileBody fb = new FileBody(file); entity.addPart(key, fb); } else { entity.addPart(key, new StringBody(dictionary.get(key))); } } httppost.setEntity(entity); HttpResponse response = httpclient.execute(httppost); HttpEntity entity1 = response.getEntity(); BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity1); is = bufHttpEntity.getContent(); } catch (ClientProtocolException e) { e.printStackTrace(); showLogs("ClientProtocolException"); } catch (IOException e) { e.printStackTrace(); showLogs("IOException"); } return is; } public String getString(JSONObject json, String TAG) { String returnParseData = ""; try { Object aObj = json.get(TAG); if (aObj instanceof Boolean) { returnParseData = Boolean.toString(json.getBoolean(TAG)); } else if (aObj instanceof Integer) { returnParseData = Integer.toString(json.getInt(TAG)); } else if (aObj instanceof String) { returnParseData = json.getString(TAG); } else { returnParseData = json.getString(TAG); } } catch (Exception err) { err.printStackTrace(); returnParseData = ""; } return returnParseData; } public String getIntintoString(JSONObject json, String TAG) { int returnParseData = -1; try { returnParseData = json.getInt(TAG) ; } catch (Exception err) { err.printStackTrace(); returnParseData = -1; } return Integer.toString(returnParseData) ; } public void showLogs ( String msg ) { Log.e("HTTP-POST", msg) ; } } </code></pre>
17,037,920
0
Call div in another page as inside a dialog box <p>I have developed a website using a template. There, a dialog box is prompt properly when click on a tag. But I need to call the dialog box div which is in another different page. Because I need to get a id which is passing from the URL to use with the GET['id'] with PHP. I have tried calling the div in this way</p> <pre><code> &lt;a href="x.html#myModal2"&gt;Alert&lt;/a&gt; </code></pre> <p>But its not working. Any one can give me a suggestion or a guidance to achieve my objective?</p> <p>here is my calling tag and the dialog box div</p> <pre><code> &lt;a href="#myModal2" role="button" class="btn btn-danger" data-toggle="modal"&gt;Alert&lt;/a&gt; &lt;div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&lt;/button&gt; &lt;h3 id="myModalLabel2"&gt;Alert Header&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p&gt;Body goes here...&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button data-dismiss="modal" class="btn green"&gt;OK&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>here is the same div which I need to call in the x.html page</p> <pre><code>&lt;div id="myModal1" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&lt;/button&gt; &lt;h3 id="myModalLabel1"&gt;Modal Header&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p&gt;Body goes here...&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;Close&lt;/button&gt; &lt;button class="btn yellow"&gt;Save&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
34,651,765
0
I want to do photo effects which is uploaded by user in javascript <p>I want do some photo fun effects in my website. If user upload their file, its automatically display the output, which effect is user selected. This is doing in JavaScript with html. I want yours favour for how to do mask effect in JavaScript. I just did upload the image from local and its display in same page and also i need to apply the effects in it.This is my script</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; window.onload = function () { var fileUpload = document.getElementById("fileupload"); fileUpload.onchange = function () { if (typeof (FileReader) != "undefined") { var dvPreview = document.getElementById("dvPreview"); dvPreview.innerHTML = ""; var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.jpg|.jpeg|.gif|.png|.bmp)$/; for (var i = 0; i &lt; fileUpload.files.length; i++) { var file = fileUpload.files[i]; if (regex.test(file.name.toLowerCase())) { var reader = new FileReader(); reader.onload = function (e) { var img = document.createElement("IMG"); img.height = "600"; img.width = "600"; img.src = e.target.result; dvPreview.appendChild(img); } reader.readAsDataURL(file); } else { alert(file.name + " is not a valid image file."); dvPreview.innerHTML = ""; return false; } } } else { alert("This browser does not support HTML5 FileReader."); } } }; &lt;/script&gt; </code></pre> <p>My Html code:</p> <pre><code>&lt;input id="fileupload" type="file" multiple="multiple" /&gt;&lt;hr /&gt; &lt;b&gt;Live Preview&lt;/b&gt;&lt;br&gt; &lt;div id="dvPreview" &gt; &lt;/div&gt; </code></pre> <p>How can i apply the effects which image is uploaded by user. <a href="http://i.stack.imgur.com/vMFfQ.png" rel="nofollow">Mask image is here</a> | <a href="http://i.stack.imgur.com/UYrPE.jpg" rel="nofollow">I need this output - Output image is here</a></p> <p>User uploaded image need to be in background with blur effect and image is in a design i need dude's. Thanks for advance to spend your golden time for me.</p>
1,918,219
0
<p>You can have each tab be a real view controller with nib and everything. The only catch is that you must forward on the standard view controller calls you want to receive (viewWillAppear, etc) but it makes the coding much cleaner since you code just as you would for any other view (although for a smaller space). </p> <p>You call each controllers "view" property to get out the view, which you add as a subview of a container view you have under the tabs.</p>
24,750,005
0
how to retain the animated position in opengl es 2.0 <p>I am doing frame based animation for 300 frames in opengl es 2.0</p> <p>I want a rectangle to translate by +200 pixels in X axis and also scaled up by double (2 units) in the first 100 frames. For example, the initial value (frame 0) of the rectangle's centre point is at 100 pixels (i.e. rectCenterX = 100) on the screen; At 100th frame, rectCenterX = 300 (100 + 200) pixels. Also the rect size is doubled the original size.</p> <p>Then, the animated rectangle has to stay there for the next 100 frames (without any animation). i.e. the rectCenterX = 300 pixels for frames 101 to 200. At 101st frame, rectCenterX = 300 pixels. the rect size is double the original size. At 200th frame, rectCenterX = 300 pixels. the rect size is double the original size.</p> <p>Then, I want the same animated rectangle to translate by +200 pixels in X axis and also scaled down by half (0.5 units) in the last 100 frames. At 300th frame, rectCenterX = 500 pixels.the rect size is again as the original size.</p> <p>I am using simple linear interpolation to calculate the delta-animation value for each frame.</p> <p>In short,</p> <pre><code>Animation-Type Animation-Value Start-Frame End-Frame 1.Translate +200 0 100 2.Scale +2 0 100 3.Translate +200 201 300 4.Scale +0.5 201 300 </code></pre> <p>Pseudo code: The below drawFrame() is executed for 300 times (300 frames) in a loop.</p> <pre><code>float RectMVMatrix[4][4] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; // identity matrix int totalframes = 300; float translate-delta; // interpolated translation value for each frame float scale-delta; // interpolated scale value for each frame // The usual code for draw is: void drawFrame(int iCurrentFrame) { // mySetIdentity(RectMVMatrix); // comment this line to retain the animated position. mytranslate(RectMVMatrix, translate-delta, X_AXIS); // to translate the mv matrix in x axis by translate-delta value myscale(RectMVMatrix, scale-delta); // to scale the mv matrix by scale-delta value ... // opengl calls glDrawArrays(...); eglswapbuffers(...); } </code></pre> <p>The above code will work fine for first 100 frames. in order to retain the animated rectangle during the frames 101 to 200, i removed the "mySetIdentity(RectMVMatrix);" in the above drawFrame().</p> <p>Now on entering the drawFrame() for the 2nd frame, the RectMVMatrix will have the animated value of first frame</p> <p>e.g. RectMVMatrix[4][4] = { 1.01, 0, 0, 2, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };// 2 pixels translation and 1.01 units scaling after first frame This RectMVMatrix is used for mytranslate() in 2nd frame. The translate function will affect the value of "RectMVMatrix[0][0]". Thus translation affects the scaling values also.</p> <p>Eventually output is getting wrong.</p> <p>How to retain the animated position without affecting the current ModelView matrix?</p>
6,863,254
0
<p>In <code>Event* EventHandler::DequeueEvent()</code> you have line <code>Event* result = new Event(*this-&gt;_eventQueue.front());</code> Here the slicing occurs. You can do the following:</p> <pre><code>class Event { public: virtual Event* clone() { // create a new instance and copy all the fields } </code></pre> <p>}</p> <p>Then override <code>clone()</code> in derived classes, e.g. </p> <pre><code>class KeyboardKeyEvent :public Event { public: ... virtual KeyboardKeyEvent* clone(); // note - it returns different type } </code></pre> <p>Then change <code>Event* EventHandler::DequeueEvent()</code> : <code>Event* result = (*this-&gt;_eventQueue.front()).clone();</code></p>
8,821,689
0
<p>You can supply a <code>function(i, attr)</code> into your <code>.attr()</code></p> <pre><code>for (var i = 0, len = data.length; i &lt; len; i++) { var $div = $(".venue:first").clone(); data.[i].photos; $div.find(".photos").attr("src", function(index, src){ return data[i].photos[index]; }); } </code></pre>
12,320,641
0
<p>The best way to do this i think... is having an object with the infowindows that you have opened</p> <p>i have two objects, infos have all the infowindows created and markers contains all markers with they infowindows so i just execute this functions that loop the infowindow object and close all the infowindows</p> <pre><code>function CloseInfowindows() { for (var mkey in infos) { var mobj = markers[mkey]; mobj.infowindow.close(); } } </code></pre>
4,250,568
0
<p>I use successfully the following procedure to get images with SmartGWT working.</p> <p>At the same level as the <code>client</code> package of your GWT module I create a folder named <code>public</code>. (In Eclipse you cannot create a package named <code>public</code> because this is not a valid package name. You have to create it explicitly as a folder.) This directory with name <code>public</code> is treated special by GWT. The GWT compiler copies all the included content to the resulting main module directory. So I usually create a subdirectory <code>images</code> under <code>public</code> and put all the images belonging to my GWT module in there.</p> <p>For example:</p> <pre><code>com/stuff client Main.java ... public images a.png b.png mainmodule.gwt.xml </code></pre> <p>Then right at the beginning of the entry point I tell SmartGWT to look at the <code>images</code> subdirectory for the images (in this example is <code>mainmodule</code> the name of my main GWT module):</p> <pre><code>public void onModuleLoad() { Page.setAppImgDir("[APP]/mainmodule/images/"); ... } </code></pre> <p>The <code>[APP]</code> part of the path is special SmartGWT syntax.</p> <p>Later I am able to create an IButton like so:</p> <pre><code>final IButton aBtn = new IButton("A Button"); aBtn.setIcon("a.png"); </code></pre> <p>Sometimes it is necessary to create the URL to an image not for SmartGWT but for plain GWT or plain HTML. For these cases you can create the URL with</p> <pre><code>final String bUrl = GWT.getModuleBaseURL() + "images/b.png"; </code></pre>
25,871,007
0
Cross-year DatePeriod width DateInterval P7D losing new year week <p>I'm trying to have an array of yearweeks using PHP DatePeriod like so :</p> <pre><code>$from = new DateTime('2014-09-16'); $to = new DateTime('2015-02-25'); $interval = new DateInterval('P7D'); // 7Days =&gt; 1 Week $daterange = new DatePeriod($from, $interval, $to); $yearweeks = array(); foreach($daterange as $date) { $yearweeks[$date-&gt;format('YW')] = 'W' . $date-&gt;format('W-Y'); } </code></pre> <p>The result is pretty strange ! The first week of the new year is missing. I have fist week of previous year instead like so :</p> <pre><code>Array ( ... [201451] =&gt; W51-2014 [201452] =&gt; W52-2014 [201401] =&gt; W01-2014 // WTF ? /!\ [201501] =&gt; W01-2015 expected ! /!\ [201502] =&gt; W02-2015 [201503] =&gt; W03-2015 ... ) </code></pre> <p>Is there a trick to avoid this kind of error ? </p>
22,654,622
0
Sublime2: Unable to change translate_tabs_to_spaces setting <p>I want HTML files to have a 2 space indent so I've updated my Packages/User/html.sublime-settings file as follows:</p> <pre><code>{ "extensions": [ "erb", "html" ], "tab_size": 2, "translate_tabs_to_spaces": true, } </code></pre> <p>However, whenever I save a file as an HTML file (i.e. with the .html extension) the Tab Size remains 4.</p> <p>What else do I need to change?</p>
13,383,178
0
<p>Depends on how large your DB is, and how frequent the stats are changed.</p> <p>If it not that large, you can use query sets freely and create the appropriate indexes, and use some cache mechanism so you will not have to make the same queries all over again.</p> <p>But if it is very big database, and it takes a lot of resources to get the data back, I would create some schedule tasks, or use Django signals to collect data as the some order occurs.</p> <p>Another option always is to use 3rd-party tool to do all of this.</p>
27,323,000
0
Error building Android app in release mode, in Android Studio <p>I'm trying to sign my android app in release mode, in Android Studio.</p> <p>I followed <a href="http://developer.android.com/tools/publishing/app-signing.html" rel="nofollow">this official guide</a>. So I have created the keystore and a private key. Then I tried to Generate the Signed APK, from <strong>Build -> Generate Signed API Key</strong>. But the build fails, with the following error:</p> <pre><code>:app:packageRelease FAILED Error:A problem was found with the configuration of task ':app:packageRelease'. &gt; File 'C:\Documents\myapp\android.jks' specified for property 'signingConfig.storeFile' does not exist. </code></pre> <p>I have also checked the build.gradle configuration. And I have found this:</p> <pre><code> signingConfigs { releaseConfig { keyAlias 'xxxxxxxxxx' keyPassword 'xxxxxxxxx' storeFile file('C:\Documents\myapp\android.jks') storePassword 'xxxxxxxxx' } } </code></pre> <p>but in the same gradle file I have this:</p> <pre><code>buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.releaseConfig } } </code></pre> <p>What's wrong?</p>
855,243
0
<p>Try any of this:</p> <pre><code>Response.Cache.SetExpires(DateTime.Now.AddSeconds(360)); Response.Cache.SetCacheability(HttpCacheability.Private) Response.Cache.SetSlidingExpiration(true); Page.Response.Cache.SetCacheability(HttpCacheability.NoCache) </code></pre> <p>Also see this <a href="http://stackoverflow.com/questions/533867/whats-the-best-method-for-forcing-cache-expiration-in-asp-net">question</a>.</p>
25,278,941
0
<p>Or using @Brandon Bertelsen's example data</p> <pre><code>dat1 &lt;- transform(dat[grep("^\\d+$", dat$A),,drop=F], A= as.numeric(as.character(A))) dat1 # A #6 1 #7 2 #8 3 #9 4 #10 5 str(dat1) #'data.frame': 5 obs. of 1 variable: #$ A: num 1 2 3 4 5 </code></pre>
2,387,347
0
<p>Try this:</p> <pre><code>/\b\w{3,16}\b/ </code></pre> <p>Explained:</p> <ul> <li><code>\b</code> matches a word boundary</li> <li><code>\w</code> matches a word character</li> <li><code>{3,16}</code> applies to the <code>\w</code> and it indicates that at least 3 and at most 16 characters should be matched.</li> </ul> <p>FYI: I omitted the start anchor (<code>^</code>) and end anchor (<code>$</code>) from the regex you noted in your question because it seems like you want to find matches with longer strings of text as input and the anchors would restrict the matching to only instances where the entire input string matched.</p> <p>UPDATE:</p> <p>Here is the proof that this regex works:</p> <pre><code>&lt;?php $input = 'rjm1986 * SinuhePalma * excel2010 * Jimineedles * 209663603 * C6A7XR * Snojog * XmafiaX * Cival2 * HitmanPirrie * MAX * 4163016 * Dredd23 * Daddy420 * mattpauley * Mykillurdeath * 244833585 * KCKnight * Greystoke * Fatbastard * Fucku4 * Davkar * Banchy2 * ET187 * Slayr69 * Nik1236 * SeriousAl * 315791 * 216996334 * K1ra * Koops1 * LastFallout * zmileben * bismark * Krlssi * FuckOff1 * 1owni * Ulme * Rxtvjq * halfdeadman * Jamacola * LBTG1008 * toypark * Magicman6497 * Tyboe187 * Bob187 * Zetrox'; $matches = array(); preg_match_all('/\b\w{3,16}\b/', $input, $matches); print_r($matches); ?&gt; </code></pre> <p>Outputs:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; rjm1986 [1] =&gt; SinuhePalma [2] =&gt; excel2010 [3] =&gt; Jimineedles [4] =&gt; 209663603 [5] =&gt; C6A7XR [6] =&gt; Snojog [7] =&gt; XmafiaX [8] =&gt; Cival2 [9] =&gt; HitmanPirrie [10] =&gt; MAX [11] =&gt; 4163016 [12] =&gt; Dredd23 [13] =&gt; Daddy420 [14] =&gt; mattpauley [15] =&gt; Mykillurdeath [16] =&gt; 244833585 [17] =&gt; KCKnight [18] =&gt; Greystoke [19] =&gt; Fatbastard [20] =&gt; Fucku4 [21] =&gt; Davkar [22] =&gt; Banchy2 [23] =&gt; ET187 [24] =&gt; Slayr69 [25] =&gt; Nik1236 [26] =&gt; SeriousAl [27] =&gt; 315791 [28] =&gt; 216996334 [29] =&gt; K1ra [30] =&gt; Koops1 [31] =&gt; LastFallout [32] =&gt; zmileben [33] =&gt; bismark [34] =&gt; Krlssi [35] =&gt; FuckOff1 [36] =&gt; 1owni [37] =&gt; Ulme [38] =&gt; Rxtvjq [39] =&gt; halfdeadman [40] =&gt; Jamacola [41] =&gt; LBTG1008 [42] =&gt; toypark [43] =&gt; Magicman6497 [44] =&gt; Tyboe187 [45] =&gt; Bob187 [46] =&gt; Zetrox ) ) </code></pre>
7,577,616
0
<p>MATLAB 7.0 provides the <code>NTHROOT</code> function, which returns the real roots of a number. So your formula becomes <code>NTHROOT(-8, 3) = -2</code></p> <p>If you are using a version prior to MATLAB 7.0 (R14), please read the following:</p> <p>To obtain the real cube root of a negative real number "x", rather than executing:</p> <pre><code>x.^(1/3) </code></pre> <p>use the command:</p> <pre><code>sign(x).*abs(x.^(1/3)) </code></pre> <p>This will find the absolute value of the root and modify it by the sign of the argument.</p> <p><a href="http://www.mathworks.com.au/support/solutions/en/data/1-15M1N/index.html?product=ML&amp;solution=1-15M1N" rel="nofollow">See this</a></p>
35,791,076
0
<p><strong>[UPDATE: IT'S WORTH JUMPING TO THE <em>EDIT</em> SECTION]</strong></p> <p>Ok, I found a solution, even though it doesn't compile with all the compilers because of a bug in GCC (see <a href="http://stackoverflow.com/questions/35790350/noexcept-inheriting-constructors-and-the-invalid-use-of-an-incomplete-type-that">this question</a> for further details).</p> <p>The solution is based on inherited constructors and the way functions calls are resolved.<br> Consider the following example:</p> <pre><code>#include &lt;utility&gt; #include &lt;iostream&gt; struct B { B(int y) noexcept: x{y} { } virtual void f() = 0; int x; }; struct D: public B { private: using B::B; public: template&lt;typename... Args&gt; D(Args... args) noexcept(noexcept(D{std::forward&lt;Args&gt;(args)...})) : B{std::forward&lt;Args&gt;(args)...} { } void f() override { std::cout &lt;&lt; x &lt;&lt; std::endl; } }; int main() { B *b = new D{42}; b-&gt;f(); } </code></pre> <p>I guess it's quite clear.<br> Anyway, let me know if you find that something needs more details and I'll be glad to update the answer.<br> The basic idea is that we can inherit directly the <code>noexcept</code> definition from the base class along with its constructors, so that we have no longer to refer to that class in our <code>noexcept</code> statements.</p> <p><a href="http://coliru.stacked-crooked.com/a/fdbd0c1c70e74f64" rel="nofollow">Here</a> you can see the above mentioned working example.</p> <p><strong>[EDIT]</strong></p> <p>As from the comments, the example suffers of a problem if the constructors of the base class and the derived one have the same signature.<br> Thank to Piotr Skotnicki for having pointed it out.<br> I'm going to mention those comments and I'll copy and paste the code proposed along with them (with a mention of the authors where needed).</p> <p>First of all, <a href="http://coliru.stacked-crooked.com/a/fe0fb0d62f8d2b95" rel="nofollow">here</a> we can see that the example as it is does not work as expected (thanks to Piotr Skotnicki for the link).<br> The code is almost the same previously posted, so it doesn't worth to copy and paste it here.<br> Also, from the same author, it follows an example <a href="http://coliru.stacked-crooked.com/a/7a7b48ef686cdc2a" rel="nofollow">that shows that the same solution works as expected under certain circumstances</a> (see the comments for furter details):</p> <pre><code>#include &lt;utility&gt; #include &lt;iostream&gt; struct B { B(int y) noexcept: x{y} { std::cout &lt;&lt; "B: Am I actually called?\n"; } virtual void f() = 0; int x; }; struct D: private B { private: using B::B; public: template&lt;typename... Args&gt; D(int a, Args&amp;&amp;... args) noexcept(noexcept(D{std::forward&lt;Args&gt;(args)...})) : B{std::forward&lt;Args&gt;(args)...} { std::cout &lt;&lt; "D: Am I actually called?\n"; } void f() override { std::cout &lt;&lt; x &lt;&lt; std::endl; } }; int main() { D* d = new D{71, 42}; (void)d; } </code></pre> <p>Also, I propose an alternative solution that is a bit more intrusive and is based on the idea for which the <code>std::allocator_arg_t</code> stands for, that is also the same proposed by Piotr Skotnicki in a comment:</p> <blockquote> <p>it's enough if derived class' constructor wins in overload resolution.</p> </blockquote> <p>It follows the code mentioned <a href="http://coliru.stacked-crooked.com/a/df24001de4f3f925" rel="nofollow">here</a>:</p> <pre><code>#include &lt;utility&gt; #include &lt;iostream&gt; struct B { B(int y) noexcept: x{y} { std::cout &lt;&lt; "B: Am I actually called?\n"; } virtual void f() = 0; int x; }; struct D: public B { private: using B::B; public: struct D_tag { }; template&lt;typename... Args&gt; D(D_tag, Args&amp;&amp;... args) noexcept(noexcept(D{std::forward&lt;Args&gt;(args)...})) : B{std::forward&lt;Args&gt;(args)...} { std::cout &lt;&lt; "D: Am I actually called?\n"; } void f() override { std::cout &lt;&lt; x &lt;&lt; std::endl; } }; int main() { D* d = new D{D::D_tag{}, 42}; (void)d; } </code></pre> <p>Thanks once more to Piotr Skotnicki for his help and comments, really appreciated.</p>
6,482,113
0
Concatenating two fields in a collect <p>Rails 2.3.5</p> <p>I'm not having any luck searching for an answer on this. I know I could just write out a manual sql statement with a concat in it, but I thought I'd ask:</p> <p>To load a select, I'm running a query of shift records. I'm trying to make the value in the select be shift date followed by a space and then the shift name. I can't figure out the syntax for doing a concat of two fields in a collect. The Ruby docs make it looks like plus signs and double quotes should work in a collect but everything I try gets a "expected numeric" error from Rails.</p> <pre><code> @shift_list = [a find query].collect{|s| [s.shift_date + " " + s.shift_name, s.id]} </code></pre> <p>Thanks for any help - much appreciated.</p>
30,706,458
0
convert unsigned short mat to vector in opencv <p>I load a depth image in opencv with</p> <pre><code>cv::Mat depth = cv::imread("blabla.png",CV_LOAD_IMAGE_UNCHANGED); </code></pre> <p>then get a subimage of it with</p> <pre><code>cv::Mat sub_image= depth(cv::Rect( roi_x,roi_y,roi_size,roi_size)).clone(); </code></pre> <p>now I want to convert that sub_image into a vector</p> <p>I try with</p> <pre><code>std::vector&lt;uchar&gt; array; array.assign(sub_image.datastart,sub_image.dataend); </code></pre> <p>that found here in StackOverflow in a similar question but it seems it doesnt work properly.</p> <p>The size of array after assignment isnt roi_size * roi_size, but instead roi_size*roi_size*2 </p> <p>Is something wrong with the type of vector?? I also tried various other types like double, float, int, etc</p> <p>The type of the depth image is unsigned short right??</p> <p>Edit:</p> <p>array fills properly (correct size roi_size*roi_size) when I normalize the depth image </p> <pre><code>cv::Mat depthView; cv::normalize(depth, depthView, 0, 255, cv::NORM_MINMAX,CV_8UC1); </code></pre> <p>but thats not what I want to do</p>
8,076,814
0
<p>In UIWebView delegate you can handle the navigation notification and prevent it; from the notification you will know the PDF URL, that will allow you to use NSURLConnection to download it.</p>
12,580,705
0
ASP.NET MVC and friendly URLs <p>I'm trying to learn a bit more about creating friendly URLs, particularly in relation to something like an e-commerce site. If you take a look at this site as an example: <a href="http://www.wiggle.co.uk/" rel="nofollow">http://www.wiggle.co.uk/</a> </p> <p>It basically lets you refine your search based on the categories. So if I go to <a href="http://www.wiggle.co.uk/mens/road-time-trial-bikes/" rel="nofollow">http://www.wiggle.co.uk/mens/road-time-trial-bikes/</a> it will list all men's road bikes, if I then go to <a href="http://www.wiggle.co.uk/road-time-trial-bikes/" rel="nofollow">http://www.wiggle.co.uk/road-time-trial-bikes/</a> it will list men's and women's bikes, and if I go to <a href="http://www.wiggle.co.uk/bianchi-sempre-105/" rel="nofollow">http://www.wiggle.co.uk/bianchi-sempre-105/</a> it will display a particular bike.</p> <p>I'm not really sure what the routing would look like for something like this, as you could have many filters in the URL. I'm also not sure how how it's able to distinguish between what's a filter and what's a product. </p>
19,300,264
0
<p>It's usually a good idea to check if <a href="http://twistedmatrix.com/trac/" rel="nofollow">Twisted</a> has support for various operations, since it can be combined with Tornado using <code>tornado.platform.twisted</code>. For XML-RPC there is following code: <a href="http://twistedmatrix.com/documents/13.0.0/web/howto/xmlrpc.html" rel="nofollow">http://twistedmatrix.com/documents/13.0.0/web/howto/xmlrpc.html</a> A simple example:</p> <pre><code>import tornado.httpserver import tornado.ioloop import tornado.web import tornado.platform.twisted tornado.platform.twisted.install() from twisted.web.xmlrpc import Proxy from twisted.internet import reactor proxy = Proxy('http://advogato.org/XMLRPC') from tornado.options import define, options define("port", default=8000, help="run on the given port", type=int) class IndexHandler(tornado.web.RequestHandler): def printValue(self, value): self.write(repr(value)) self.finish() def printError(self, error): self.write('error: %s' % error) self.finish() @tornado.web.asynchronous def get(self): proxy.callRemote('test.sumprod', 3, 5).addCallbacks(self.printValue, self.printError) if __name__ == "__main__": tornado.options.parse_command_line() app = tornado.web.Application(handlers=[(r"/", IndexHandler)]) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start() </code></pre> <p>Benchmarking:</p> <pre><code>$ ab -n 1000 -c 5 http://localhost:8000/ This is ApacheBench, Version 2.3 &lt;$Revision: 655654 $&gt; Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: TornadoServer/3.0.1 Server Hostname: localhost Server Port: 8000 Document Path: / Document Length: 7 bytes Concurrency Level: 5 Time taken for tests: 76.529 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 201000 bytes HTML transferred: 7000 bytes Requests per second: 13.07 [#/sec] (mean) Time per request: 382.646 [ms] (mean) Time per request: 76.529 [ms] (mean, across all concurrent requests) Transfer rate: 2.56 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 302 382 498.9 308 5318 Waiting: 302 382 498.9 308 5318 Total: 302 382 498.9 308 5318 Percentage of the requests served within a certain time (ms) 50% 308 66% 310 75% 311 80% 313 90% 320 95% 334 98% 1310 99% 3309 100% 5318 (longest request) </code></pre> <p>Straight use of <code>xmlrpclib</code> for comparison:</p> <pre><code>import tornado.httpserver import tornado.ioloop import tornado.web import xmlrpclib server = xmlrpclib.ServerProxy('http://advogato.org/XMLRPC') from tornado.options import define, options define("port", default=8000, help="run on the given port", type=int) class IndexHandler(tornado.web.RequestHandler): def get(self): self.write(repr(server.test.sumprod(3, 5))) if __name__ == "__main__": tornado.options.parse_command_line() app = tornado.web.Application(handlers=[(r"/", IndexHandler)]) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start() </code></pre> <p>Benchmarking:</p> <pre><code>$ ab -n 1000 -c 5 http://localhost:8000/ This is ApacheBench, Version 2.3 &lt;$Revision: 655654 $&gt; Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: TornadoServer/3.0.1 Server Hostname: localhost Server Port: 8000 Document Path: / Document Length: 7 bytes Concurrency Level: 5 Time taken for tests: 325.538 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 201000 bytes HTML transferred: 7000 bytes Requests per second: 3.07 [#/sec] (mean) Time per request: 1627.690 [ms] (mean) Time per request: 325.538 [ms] (mean, across all concurrent requests) Transfer rate: 0.60 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 305 1625 484.5 1532 4537 Waiting: 305 1624 484.5 1532 4537 Total: 305 1625 484.5 1532 4537 Percentage of the requests served within a certain time (ms) 50% 1532 66% 1535 75% 1537 80% 1539 90% 1547 95% 1984 98% 4524 99% 4533 100% 4537 (longest request) </code></pre> <p>Much worse.</p>
4,051,369
0
<p>Suppose you have an integer array</p> <pre><code>int Marks[1000]={22,32,12,..............}; </code></pre> <p>First of all you sort your array</p> <pre><code>int g,r,c; for ( r=0; r &lt;=999; r++) { for ( g=r+1;g&lt;=1000;g++) { if ( Marks[r] &lt; Marks[g] ) { c=Marks[r]; // these 3 statements swap values Marks[r] =Marks[g]; // in the 2 cells being compared Marks[g] = c; } } } </code></pre> <p>Now you find that largest number is Marks[0] and second large is Marks[1]</p>
13,519,338
0
PyDev "New Project" crashes Eclipse <p>I'm a Python and PyDev newbie. My environment is OS X 10.6.11, Eclipse Indigo, PyDev 2.7.1, Python 2.6 and 3.3.</p> <p>Starting from any perspective (PyDev, Java, others), selecting New->Project->PyDev->PyDev Project results in an endless spinning color beachball. The only way out is to Force Quit Eclipse.</p> <p>Starting from the PyDev perspective, if I select New->Project, and then select General->Project, the same crash occurs.</p> <p>My only recourse seems to be to create a generic project from, say, the Java perspective, then right-click the project in the package explorer view and choose PyDev->Set as PyDev Project, then switch to the PyDev perspective, then configure the project folder manually.</p> <p>Am I missing something in my installation? Is this a known problem with PyDev?</p>
26,827,252
0
<p>if you <em>really</em> want to do this, you could use reflection:</p> <pre><code>Person obj = new Person(); Method method = Person.class.getMethod("getFirstname"); String firstname = method.invoke(obj); </code></pre> <p>but as mentioned in the comments, you better use a map to hold attribute values:</p> <pre><code>class Person { private Map&lt;String,Object&gt; attrs = new HashMap&lt;&gt;(); public void setAttribute(String attr, Object value) { attrs.put(attr,vaue); } public Object getAttribute(String attr) { attrs.get(attr); } } Person person = new Person(); person.setAttribute("firstname","patrick"); String firstname = (String)person.getAttribute("firstname"); </code></pre>
10,269,164
0
how to use the postgres database embedded with Mac Lion? <p>i can only find psql command, but can't find any other postgres commands or tools, can anyone tell me how to create database and connect to it using the default postgres shipped with mac lion?</p> <p>only if it doesn't work ,i dont' want to install another postgres instance.</p>
12,903,917
0
<p>Your code cannot be compiled because in java character <code>'</code> ( single quote ) is used to mark one character. In order to define string you should use double quote <code>"</code>. </p> <p>In your case I believe that you wanted to check whether your string contains digits only and were confused with regular expression syntax you tried to use incorrectly.</p> <p>You can either rewirte your if statement as following:</p> <p>char c = str.charAt(i); <code>if(c&gt;= '0' &amp;&amp; c &lt;= 9) {</code></p> <p>or use pattern matching, e.g. <code>Pattern.compile("\\d+").matcher(str).matches()</code></p> <p>In this case you even do not need to implement any loop.</p>
7,757,365
0
Does LINQ work with IEnumerable? <p>I have a class that implements <code>IEnumerable</code>, but doesn't implement <code>IEnumerable&lt;T&gt;</code>. I can't change this class, and I can't use another class instead of it. As I've understood from MSDN <a href="http://msdn.microsoft.com/en-us/library/bb308959.aspx#linqoverview_topic3">LINQ can be used if class implements <code>IEnumerable&lt;T&gt;</code></a>. I've tried using <code>instance.ToQueryable()</code>, but it still doesn't enable LINQ methods. I know for sure that this class can contain instances of only one type, so the class could implement <code>IEnumerable&lt;T&gt;</code>, but it just doesn't. So what can I do to query this class using LINQ expressions?</p>
15,934,544
0
<p>alright so this is what worked, the null characters in the array were causing issues and were returning the last null in the array so i forced the array to break after each if/else statement by putting x = memberAcc.length +1; and y = newMember.length +1; to do this. Causing the entire array to be checked and then forced to be broken allowing me to return to my Menu while loop.</p>
37,907,227
0
<p>Do it the same way like you did with your update, use SQL parameters for the where clause. So this code should work:</p> <pre><code>protected void Button2_Click(object sender, EventArgs e) { string sel = DropDownList1.SelectedValue; // if your selection is empty, abort early if( sel == null || string.IsNullOrEmpty(sel.Text)) return; // use a SQL parameter like you did with update string query = "DELETE FROM MovieList WHERE Movie=@MovieValue"; System.Data.OleDb.OleDbCommand ocmd = new System.Data.OleDb.OleDbCommand(query, new System.Data.OleDb.OleDbConnection(CSTR)); // here the selected text for the movie is set to the movie parameter ocmd.Parameters.AddWithValue("@MovieValue", sel.Text); ocmd.Connection.Open(); ocmd.ExecuteNonQuery(); ocmd.Connection.Close(); populateDropDowns(); } </code></pre>
4,402,022
0
<p>Neither are a direct port, but of the two -- MySQL's syntax is more similar to SQL Server's than PostgreSQL. </p> <p>SQL Server 2000 didn't have analytic/ranking/windowing functionality -- neither does MySQL currently. Also, no WITH/CTE support - again, MySQL doesn't support this either. If you were migrating away from SQL Server 2005+, I'd have recommended PostgreSQL 8.4+ for the sake of either of the two things I just mentioned.</p>
20,088,539
0
Corona SDK with Graphic 2.0 position not working <p>I have upgraded my Corona SDK version to 2013.2076 (with Graphic 2.0). But now my background images are not working and the app is crashing.</p> <pre><code>local background = display.newImageRect("/bg.png", 570, 360 ) background:setReferencePoint( display.CenterReferencePoint ) background.x = display.contentCenterX ; background.y = display.contentCenterY gameGroup:insert(background) </code></pre> <p>It is working perfectly in previous version of Corona SDK. I am not being able to identify the issue. Please help</p>
281,894
0
<p>Here's a trick: calculating a <code>SUM()</code> of values that are known to be either 1 or 0 is equivalent to a <code>COUNT()</code> of the rows where the value is 1. And you know that a boolean comparison returns 1 or 0 (or NULL).</p> <pre><code>SELECT c.catname, COUNT(m.catid) AS item_count, SUM(i.ownerid = @ownerid) AS owner_item_count FROM categories c LEFT JOIN map m USING (catid) LEFT JOIN items i USING (itemid) GROUP BY c.catid; </code></pre> <p>As for the bonus question, you could simply do an inner join instead of an outer join, which would mean only categories with at least one row in <code>map</code> would be returned.</p> <pre><code>SELECT c.catname, COUNT(m.catid) AS item_count, SUM(i.ownerid = @ownerid) AS owner_item_count FROM categories c INNER JOIN map m USING (catid) INNER JOIN items i USING (itemid) GROUP BY c.catid; </code></pre> <p>Here's another solution, which is not as efficient but I'll show it to explain why you got the error:</p> <pre><code>SELECT c.catname, COUNT(m.catid) AS item_count, SUM(i.ownerid = @ownerid) AS owner_item_count FROM categories c LEFT JOIN map m USING (catid) LEFT JOIN items i USING (itemid) GROUP BY c.catid HAVING item_count &gt; 0; </code></pre> <p>You can't use column aliases in the <code>WHERE</code> clause, because expressions in the <code>WHERE</code> clause are evaluated before the expressions in the select-list. In other words, the values associated with select-list expressions aren't available yet.</p> <p>You can use column aliases in the <code>GROUP BY</code>, <code>HAVING</code>, and <code>ORDER BY</code> clauses. These clauses are run after all the expressions in the select-list have been evaluated.</p>
13,209,463
0
<p>There would be no point in <code>std::vector::operator[]</code> returning a reference if you couldn't actually do anything with it. Your code is perfectly fine.</p>
669,696
0
<p>You should check out <a href="http://weblogs.asp.net/podwysocki/archive/2008/11/08/code-contracts-for-net-4-0-spec-comes-alive.aspx" rel="nofollow noreferrer"><strong>Code Contracts</strong></a>; they do pretty much exactly what you're asking. Example:</p> <pre><code>[Pure] public static double GetDistance(Point p1, Point p2) { CodeContract.RequiresAlways(p1 != null); CodeContract.RequiresAlways(p2 != null); // ... } </code></pre>
28,608,607
0
<p><strong>Main thread</strong></p> <ol> <li>Create an event. For instance, <code>TSimpleEvent</code> will suffice for your needs.</li> <li>Set the event to be non-signaled. For <code>TSimpleEvent</code> that's a call to <code>ResetEvent</code>. I expect that a newly minted <code>TSimpleEvent</code> would be in the non-signaled state, but off the top of my head I cannot remember that detail.</li> <li>Create the thread, passing the event in the constructor.</li> <li>Wait for the event to become signaled. For <code>TSimpleEvent</code> that means calling <code>WaitFor</code>.</li> </ol> <p><strong>Worker thread</strong></p> <ol> <li>Make a note of the event passed to the thread's constructor.</li> <li>At the start of the thread execution, signal the event. For <code>TSimpleEvent</code> that means calling <code>SetEvent</code>.</li> </ol>
23,270,775
0
<p>You problem is explained in the logcat :</p> <pre><code>android.widget.ImageView cannot be cast to android.widget.TextView </code></pre> <p>And by looking at the next line of your Logcat you can see where it happened:</p> <pre><code>at com.nando.gridview.Dialog.onCreate(Dialog.java:21) </code></pre> <p>So change the following:</p> <pre><code>TextView DialogText=(TextView) findViewById(R.id.imageViewDialog); </code></pre> <p>Into this:</p> <pre><code>TextView DialogText=(TextView) findViewById(R.id.idofyourtextview); </code></pre>
30,398,847
0
<p>Try this:</p> <pre><code>#data df &lt;- read.table(text=" tissueA tissueB tissueC gene1 4.5 6.2 5.8 gene2 3.2 4.7 6.6") #result apply(df,1,function(i){ my.max &lt;- max(i) my.statistic &lt;- (1-log2(i)/log2(my.max)) my.sum &lt;- sum(my.statistic) my.answer &lt;- my.sum/(length(i)-1) my.answer }) #result # gene1 gene2 # 0.1060983 0.2817665 </code></pre>
1,573,785
0
<p>Because when linking statically, the order in which you specify the libraries and object files does matter. Specifically, a library must be mentioned after object files that use symbols from it.</p>
8,127,828
0
Scrolling a Gallery with buttons <p>I have a Gallery whose Adapter creates several LinearLayout instances. Those linear layout instances have buttons, however, and when someone clicks the buttons, they can't drag the gallery.</p> <p>My idea is having a menu that the user can scroll through. The kind of thing that would normally be done with a ScrollView, but because I want the scrolled view to 'Snap' to the current button pages, a Gallery works better.</p> <p>This question is similar to this one: <a href="http://stackoverflow.com/questions/7192417/android-gallery-of-linearlayouts">Android gallery of LinearLayouts</a></p> <p>However, while I've fixed the 'buttons appear clicked' when dragging issue, I can't seem to make it work like a ScrollView does, by having the buttons work as part of the dragging area.</p> <p>Any hints?</p> <p>Not sure if the code is relevant, but here it is.</p> <p>Layout that contains the gallery:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;Gallery android:id="@+id/gallery" android:layout_width="match_parent" android:layout_height="wrap_content" android:fadingEdge="none" android:spacing="0dp"/&gt; &lt;/FrameLayout&gt; </code></pre> <p>The test activity that populates the gallery:</p> <pre><code>import com.zehfernando.display.widgets.ZGallery; public class ScrollTestActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.scrolltest); Gallery gallery = (Gallery) findViewById(R.id.gallery); gallery.setAdapter(new LayoutAdapter(this)); } public class LayoutAdapter extends BaseAdapter { private Context mContext; public LayoutAdapter(Context c) { mContext = c; } public int getCount() { return 3; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater vi = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = vi.inflate(R.layout.scrolllayout, null); v.setMinimumWidth(getWindowManager().getDefaultDisplay().getWidth()); return v; } } } </code></pre> <p>The layout for the frames that go inside the gallery:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;com.zehfernando.display.widgets.ScrollableLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/buttonRegister" android:layout_width="200dp" android:layout_height="72dp" android:text="REGISTER"/&gt; &lt;Button android:id="@+id/buttonUnregister" android:layout_width="match_parent" android:layout_height="72dp" android:text="UNREGISTER" /&gt; &lt;/com.zehfernando.display.widgets.ScrollableLinearLayout&gt; </code></pre> <p>"ScrollableLinearLayout" is just my class that extends LinearLayout to override onPressed.</p>
7,959,576
0
<p>Two things to consider:</p> <ol> <li><p>Maybe you should have a habit of rebasing these branches onto the tip of master (or wherever) before landing them. This way, they are strictly redundant as KingCrush suggests above, and can be destroyed to be recreated later if you find a problem.</p></li> <li><p>Use rename to mark branches you're not sure if you'll need again with a specific prefix, so that you can scan past them quickly in a list of branches when you know you're not looking for an obsolete feature branch.</p></li> </ol> <p>You could use some mixture of these techniques, e.g. always rebase, then rename branch foo to landed-foo, and then after a set interval (say, one release, or 30 days) delete the landed-foo branch.</p> <p>Notice that if you don't rebase (and run any tests on the rebased version) you have no way to be sure that a bug found after it lands was actually in the code as developed, and not caused by the impact of merging it after development, so in this case you might want to keep the branch for a while. This will happen more often with invasive / very large changes, not like your question scenario.</p>
8,246,629
0
<p>In BlackBerry, for performance resons, there was a file size limitation regarding attachments, so only a portion of the message was downloaded. The attachments were not actually delivered to the device unless the user opened them.</p> <p>Now, in JDE 5.0, they introduced a new class, <a href="http://www.blackberry.com/developers/docs/7.0.0api/net/rim/blackberry/api/mail/AttachmentDownloadManager.html" rel="nofollow"><code>AttachmentDownloadManager</code></a>, that allows the programmer to force a retrieval from code.</p> <p>It could be something like this (not tested):</p> <pre><code>Message m = ... //The mail message instance. AttachmentDownloadManager atm = new AttachmentDownloadManager(); BodyPart[] bparr = atm.getAttachmentBodyParts(m); atm.download(bparr, &lt;some folder path&gt;, null); </code></pre>
4,276,218
0
How do you set different scale limits for different facets? <p>Some sample data:</p> <pre><code>dfr &lt;- data.frame( x = rep.int(1:10, 2), y = runif(20), g = factor(rep(letters[1:2], each = 10)) ) </code></pre> <p>A simple scatterplot with two facets:</p> <pre><code>p &lt;- ggplot(dfr, aes(x, y)) + geom_point() + facet_wrap(~ g, scales = "free_y") </code></pre> <p>I can set the axis limits for all panels with</p> <pre><code>p + scale_y_continuous(limits = c(0.2, 0.8)) </code></pre> <p>(or a wrapper for this like <code>ylim</code>)</p> <p>but how do I set different axis limits for different facets?</p> <p>The latticey way to do it would be to pass a list to this argument, e.g.,</p> <pre><code>p + scale_y_continuous(limits = list(c(0.2, 0.8), c(0, 0.5))) </code></pre> <p>Unfortunately that just throws an error in the ggplot2 case.</p> <p><strong>EDIT:</strong></p> <p>Here's a partial hack. If you want to extend the range of the scales then you can add columns to your dataset specifying the limits, then draw them with <code>geom_blank</code>.</p> <p>Modified dataset:</p> <pre><code>dfr &lt;- data.frame( x = rep.int(1:10, 2), y = runif(20), g = factor(rep(letters[1:2], each = 10)), ymin = rep(c(-0.6, 0.3), each = 10), ymax = rep(c(1.8, 0.5), each = 10) ) </code></pre> <p>Updated plot:</p> <pre><code>p + geom_blank(aes(y = ymin)) + geom_blank(aes(y = ymax)) </code></pre> <p>Now the scales are different and the left hand one is correct. Unfortunately, the right hand scale doesn't contract since it needs to make room for the points.</p> <p>In case it helps, we can now rephrase the question as "is it possible to draw points without the scales being recalculated and without explicitly calling <code>scale_y_continuous</code>?"</p>
19,762,416
0
adding images to the ckeditor <p>i want to add image again in the ck editor when i click on button "add gap"</p> <p>here is my code</p> <pre><code>&lt;div class="control-group" align="left" style="float: left" onselect="selectText()"&gt; &lt;textarea name="editor1" id="myTextarea"&gt;&lt;p&gt;please type&lt;img src="img/gap-placeholder.png"/&gt;&lt;/p&gt; &lt;/textarea&gt; &lt;/div&gt; &lt;div style="float: left;margin-left: 5px"&gt; &lt;input type="button" value="Add Gap" onclick="insertText();"/&gt; &lt;/div&gt; </code></pre>
35,462,483
0
Cannot uninstall ionic using npm on Mac <p>I am trying to switch to ionic2. Installing on top of my previous installation of ionic 1 appears to succeed (based on the output) but ionic1 remains as shown by ionic info. Here were the steps. Any help would be appreciated.</p> <ol> <li>Successfully Installed ionic2@beta using sudo npm install -g ionic@beta</li> <li>ionic -v shows version 1.7.14</li> <li>Uninstalled using npm uninstall -g ionic</li> <li>Successfully (based on printout) uninstalled ionic 2</li> <li>ionic -v shows version 1.7.14 (WTF)</li> <li>Tried 'npm uninstall -g ionic' again</li> <li>Received command prompt immediately, no other outputs (no affect)</li> <li>ionic -v shows version 1.7.14</li> </ol>
5,357,951
0
<p>I have finally found my own answer again. Basically, <strong>it came down to restart intellij</strong> and the plugin will show under plugins. For some reason while doing "Grails/Synchronize Grails Settings" was not making the plugin show up.</p> <p>So to successfully install the gails mail plugin do as follows</p> <ol> <li>Add <strong>activation1-1.jar</strong> and <strong>mail.jar</strong> to your lib folder</li> <li>In <strong>BuildConfig.groovy</strong> uncomment mavenCenral()</li> <li>Run grails command: <strong>grails install-plugin mail</strong></li> <li>In IntelliJ click on <strong>Apply Grails Changes to IDEA project structure</strong> if asked in the<br> yellow popup</li> <li>If IntelliJ still does not recognize the plugin do <strong>Grails/Synchronize Grails</strong> either by right clicking on "Plugins" or in the project name</li> <li>If IntelliJ still does not recognize the plugin, restart IntelliJ do a <strong>Grails/Synchronize Grails</strong>.</li> <li>The plugin should be correctly installed and ready to use.</li> </ol>
21,879,098
0
<p>This is called reverse geocoding. Here is a sample code that does that:</p> <pre><code>MapAddress address; ReverseGeocodeQuery query = new ReverseGeocodeQuery(); query.GeoCoordinate = myGeoCoordinate; query.QueryCompleted += (s, e) =&gt; { if (e.Error != null) return; address = e.Result[0].Information.Address; }; query.QueryAsync(); </code></pre> <p>That API is available on Windows Phone 8 and I see the question is tagged WP7 but since you seem to use the <code>Geolocator</code> API, I guess you are on WP8. Otherwise, you'd have to use this kind of service: <a href="http://msdn.microsoft.com/en-us/library/ff701710.aspx" rel="nofollow">Find a Location by Point</a></p>
40,717,336
0
<p>Change the database tables collations types to <code>utf8_general_ci</code> and also table fields collations change to <code>utf8_general_ci</code>.</p> <p><a href="https://i.stack.imgur.com/hi7gl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hi7gl.png" alt="enter image description here"></a></p>
16,993,902
0
<p>IMHO, the concept is wrong. You dont need to use merge-sort here. Try searching for PriorityQueue or actually BinaryHeap in order to solve this task. Secondly, merge sort on linked list is not a good idea since it will not be efficient at all. I think you should totally rework your solution.</p> <p>NB. Just implement the operation YourLinkedList.getByIndex() for convinience, add the size atribute to hold the number of items in the linked list, then create one more linkedList and perform the bottom-up merge-sort like you would do with a simple array.</p> <p>Structures:</p> <pre><code>public class Item { private String word; private Item next; public Item(String word) { this.word = word; } public Item getNext() { return next; } public void setNext(Item next) { this.next = next; } public String getWord() { return word; } public void setWord(String word) { this.word = word; } } </code></pre> <p>Linked List:</p> <pre><code>public class LinkedList { private int size = 0; private Item first = null; public void swapFragment(LinkedList list, int from, int to) { if (from &gt;= 0 &amp;&amp; to &lt; size) { list.get(to-from).setNext(this.get(to+1)); if (from &gt; 0) { this.get(from-1).setNext(list.get(0)); } else { this.first = list.get(0); } } } public void addItem(String word) { if (first == null) { first = new Item(word); } else { Item item = first; while (item.getNext() != null) { item = item.getNext(); } item.setNext(new Item(word)); } this.size++; } public Item get(int index) { if (index &gt;= size) { return null; } else { Item item = first; for(int i = 1; i &lt;= index; i++) { item = item.getNext(); } return item; } } public int getSize() { return size; } public void setSize(int size) { this.size = size; } public String toString() { Item item = first; String message = null; if (item != null) { message = item.getWord() + " "; } else { return null; } while (item.getNext() != null) { item = item.getNext(); message = message + item.getWord() + " "; } return message; } } </code></pre> <p>Merge Sort:</p> <pre><code>public class ListMergeSort { public void sort(LinkedList list, int lo, int hi) { if (hi &lt;= lo) { return; } int mid = lo + (hi-lo)/2; sort(list, lo, mid); sort(list, mid+1, hi); merge(list, lo, hi, mid); } private void merge(LinkedList list, int lo, int hi, int mid) { int i = lo; int j = mid+1; LinkedList newList = new LinkedList(); for (int k = lo; k &lt;= hi; k++) { if (i &gt; mid) { newList.addItem(list.get(j).getWord()); j++; } else if (j &gt; hi) { newList.addItem(list.get(i).getWord()); i++; } else if (list.get(i).getWord().compareTo(list.get(j).getWord()) &lt; 0) { newList.addItem(list.get(i).getWord()); i++; } else { newList.addItem(list.get(j).getWord()); j++; } } list.swapFragment(newList, lo, hi); } } </code></pre> <p>Test Class for Strings:</p> <pre><code>import org.junit.*; public class MergeTest { @Test public void testWords() { LinkedList list = new LinkedList(); list.addItem("word"); list.addItem("pipe"); list.addItem("trainer"); list.addItem("stark"); list.addItem("33"); list.addItem("dmitry"); ListMergeSort lms = new ListMergeSort(); lms.sort(list, 0, list.getSize()-1); } } </code></pre> <p>Now you just need to create a class which receives a string as an argument, splits it with String.split() and adds the resulting words into the internal LinkedList datastructure. Then you sort them inside with the merge sort and you get the result.</p>
5,547,785
0
Extjs listener on keystroke checking if its ANY character <p>I cant seem to find this anywhere. I want to find the best way to check whether a keystroke is actually a character. </p> <pre><code>listeners:{ 'keyup':function(f, e){ //Is key a letter/character } } </code></pre> <p>EDIT</p> <p>Thanks to everyone who has answered, I DO know how to detect the actual key that was pressed, I want to know how to detect whether the key is actually a character (not arrows, backspace, enter etc) </p>
7,177,184
0
How to create Filter for org.eclipse.jface.viewers.CheckboxTreeViewer? <p>I have to create Filter for my CheckboxTreeViewer. I'm not getting how to do that. I'm using following class</p> <pre><code>org.eclipse.pde.internal.ui.shared.FilteredCheckboxTree </code></pre> <p>and following way to get the FilteredCheckboxTree object:</p> <pre><code>FilteredTree ft = new FilteredCheckboxTree(parent, null, 0, null); </code></pre> <p>but it is telling me: </p> <p>The constructor FilteredCheckboxTree(Composite, FormToolkit, int, PatternFilter) refers to the missing type FormToolkit. </p> <p>I'm not getting what exactly the problem is. Please help if you know about it. Or if there is any other way to get Filter then do let me know.</p> <p>Thanks in advance!!!</p>
6,208,325
0
<p>Seems to work for me, what browser are you using?</p> <p><a href="http://jsfiddle.net/YLCff/" rel="nofollow">http://jsfiddle.net/YLCff/</a></p>
12,220,876
0
<p>You can achieve it using jQuery. Please include the latest jQuery Lib.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; section { display:table; width: 100%; border:1px solid red; } div { display: table-cell; } .leader { background: grey; } .right{ float: right; } .left { float:left; } &lt;/style&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $(".leader").width($("section").width() - ($(".left").width() +$(".right").width())); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;section&gt; &lt;div class="left"&gt; Variable wrappable content &lt;/div&gt; &lt;div class="leader"&gt; &lt;!--empty space--&gt; &lt;/div&gt; &lt;div class="right"&gt; &lt;!--fixed length--&gt; Date &lt;/div&gt; &lt;/section&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
37,200,924
0
Update Realm relationship with primary ids <p>Is it possible to update a Realm object's relationships by passing only the ids of the relationships?</p> <p>If I have a <code>Library</code> class that has a <code>List&lt;Books&gt;</code> relationship and I wanted to merge two <code>Libraries</code> together, I would presume that could be done like:</p> <pre><code>let bookIds = (firstLibrary.books.toArray() + secondLibrary.books.toArray).map { $0.id } </code></pre> <p>Then I use ObjectMapper &amp; SugarRecord:</p> <pre><code>let changes = ["books": bookIds] Mapper&lt;T&gt;().map(changes, toObject: secondLibrary) let realm = self.realm realm.add(secondLibrary, update: true) </code></pre> <p>But the list of books doesn't get updated. I assume this is because ObjectMapper doesn't know anything about primary ids and therefore trying to map them into an object doesn't do anything.</p> <p>Does Realm have the capability to update via primary id? If it does, I'd gladly rewrite my persistence stack.</p>
13,186,580
0
Using boost::ref to indicate intention in coding conventions <p>When functions take non-const refs as arguments, it can create hard-to-read code because at the calling site it is not obvious which inputs might be changed. This has lead some code conventions to enforce that pointers be used instead, for example</p> <pre><code>void func(int input, int* output); int input = 1, output = 0; func(input, &amp;output); </code></pre> <p>instead of</p> <pre><code>void func(int input, int&amp; output); int input = 1, output = 0; func(input, output); </code></pre> <p>Personally, I hate using pointers because of the need to check for null. This has lead me to wonder if boost::ref (or std::ref for C++11) can be used to signal intention, as follows:</p> <pre><code>void func(int input, int&amp; output); int input = 1, output = 0; func(input, boost::ref(output)); </code></pre> <p>This would be used as a company coding convention. <strong>My question is, are there any reasons why this would not be a good idea?</strong></p>
40,826,060
0
<p>Closing and opening the Visual Studio Solution worked for me.</p>
6,673,807
0
<p>This is the Spotlight For Help search field, which is entirely controlled by the system. It automatically provides results from your application's Help Book and menu items. AFAIK you can't populate it "manually". It works automatically when you create a Help Book for your application.</p> <p>See <a href="http://developer.apple.com/library/mac/#documentation/Carbon/Conceptual/ProvidingUserAssitAppleHelp/user_help_concepts/apple_help_concepts.html#//apple_ref/doc/uid/TP30000903-CH205-BABBDDJC" rel="nofollow">Apple Help Concepts: The Help Menu</a>.</p>
6,175,408
0
Is it possible to change mouse cursor when handling drag (from DragOver event)? <p>We need to display a feedback to the user when he drags-in items into our application. Our client prefers this feedback to be in form of a custom cursor.</p> <p>This is already implemented for drag-out, using a custom cursor that is set in <code>GiveFeedback</code> event handler (raised by <code>DoDragDrop</code> when dragging items out of our app). The <code>GiveFeedbackEventArgs</code> allows us to specify <code>UseDefaultCursors</code> property - setting this to false allows us to override the cursor.</p> <p>However, the <code>DragOver</code> event handler argument, which is the equivalent of <code>GiveFeedback</code>, does not have <code>UseDefaultCursors</code> property and changing the cursor from there does not have any effect.</p> <p><strong>Sample (this has no effect):</strong></p> <pre><code>private void browser_DragOver(object sender, DragEventArgs e) { Cursor.Current = Cursors.WaitCursor; } </code></pre> <p>The drag operation originates from outside our app. (for in-app drag, it works using the <code>GiveFeedback</code> event.</p> <p>How to change the cursor when receiving a drag? Is this even possible/feasible?</p>
19,128,094
0
<p>The code I had to add to my view controller, after applying the constraints as per the ilya’s answer:</p> <p>In <code>controlTextDidChange</code> (<code>_controlWidthConstraint</code> refers to the fixed width constraint of the input; it’s probably 0 by default for the second input):</p> <pre><code>// Get the new width that fits float oldWidth = textControl.frame.size.width; [input sizeToFit]; float controlWidth = textControl.frame.size.width; // Don’t let the sizeToFit method modify the frame though NSRect controlRect = textControl.frame; controlRect.size.width = oldWidth; textControl.frame = controlRect; _controlWidthConstraint.constant = controlWidth; </code></pre>
33,657,969
0
Bluemix logging issue to papertrail <p>Any idea why syslog:// protocol from <code>bluemix</code> app is not connecting to <code>PaperTrail</code> third party logging service?</p> <p>Here is my process: </p> <p><a href="https://i.stack.imgur.com/OZ2rd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OZ2rd.png" alt="enter image description here"></a></p> <ol> <li>create user provided service</li> <li>bind this service</li> <li>restage</li> </ol> <p>then on the papertrail nothing happens:</p> <p><a href="https://i.stack.imgur.com/2KapV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2KapV.png" alt="enter image description here"></a></p> <p>You can try it out. The testing app URL is: <a href="http://658.eu-gb.mybluemix.net" rel="nofollow noreferrer">http://658.eu-gb.mybluemix.net</a></p> <p>Its just Hello world simple nodejs app.</p>
316,863
0
<p>One solution that I feel strikes the right balance in the Framework/Roll-your-own dilemma is the use of three key perl modules: <a href="http://cpan.uwinnipeg.ca/htdocs/CGI.pm/CGI.pm.html#ABSTRACT" rel="nofollow noreferrer">CGI.pm</a>, <a href="http://www.tt2.org/" rel="nofollow noreferrer">Template Toolkit</a> , and <a href="http://cpan.uwinnipeg.ca/htdocs/DBI/DBI/FAQ.html#Basic_Information_amp_Information_So" rel="nofollow noreferrer">DBI</a>. With these three modules you can do elegant MVC programming that is easy to write and to maintain.</p> <p>All three modules are very flexible with Template Toolkit (TT) allowing you to output data in html, XML, or even pdf if you need to. You can also include perl logic in TT, even add your database interface there. This makes your CGI scripts very small and easy to maintain, especially when you use the "standard" pragma. </p> <p>It also allows you to put JavaScript and AJAXy stuff in the template itself which mimics the separation between client and server. </p> <p>These three modules are among the most popular on CPAN, have excellent documentation and a broad user base. Plus developing with these means you can rather quickly move to mod_perl once you have prototyped your code giving you a quick transition to Apache's embedded perl environment.</p> <p>All in all a compact yet flexible toolset.</p>
20,558,286
0
Javascript program, if statement difficulties <p>this code does not work, at least not complete way it should. I'm trying to run it so an item is selected and then deposit amounts are chosen on the select menu until the proper amount is equaled or exceeded, resulting in change, but I cant seem to get my if statements to work properly. If anyone sees the problem, I would much appreciate the help.</p> <p><a href="http://jsfiddle.net/YgX4z/" rel="nofollow">http://jsfiddle.net/YgX4z/</a> </p> <pre><code>&lt;script type="text/javascript"&gt; var select; function changedepositedInput(objDropDown) { //console.log(parseFloat(objDropDown)); var objdeposited = document.getElementById("deposited"); objdeposited.value=parseFloat(objdeposited.value||'0'); var total=parseInt(objdeposited.value||'0'); objdeposited.value = parseFloat(objDropDown.value||'0')+total; var cost=parseInt('0'); var water = document.getElementById("water"); var soda = document.getElementById("soda"); var coffee = document.getElementById("coffee"); var beer = document.getElementById("beer"); if (water.checked) {cost=parseInt('75');} if (soda.checked) {cost=parseInt('150');} if (coffee.checked) {cost=parseInt('100');} if (beer.checked) {cost=parseInt('200');} if (total&gt;cost) { var change=document.getElementById("change"); change.value=total-cost; } else { var change=document.geElementById("change"); change.value="0"; } if (total&gt;=cost) { var objdelivered=document.getElementById("delivered"); objdelivered.value="Yes"; } else { var objdelivered=document.getElementById("delivered"); objdelivered.value="No"; } } &lt;/script&gt; &lt;h1&gt;Vending Machine Project&lt;/h1&gt; &lt;form name="vendingmachine" action=" "&gt; Choose Bevrage&lt;br&gt; &lt;input name="item" type="radio" id="water" checked="checked"&gt;Water 75 cents&lt;br&gt; &lt;input name="item" type="radio" id="soda"&gt;Soda $1.50&lt;br&gt; &lt;input name="item" type="radio" id="coffee"&gt;Coffee $1.00&lt;br&gt; &lt;input name="item" type="radio" id="beer"&gt;Beer $2.00&lt;br&gt; &lt;p&gt; &lt;label&gt;Deposit Money: &lt;select name="money" id="money" onchange="changedepositedInput(this)"&gt; &lt;option value="0"&gt;Choose Amount&lt;/option&gt; &lt;option value="10"&gt;10 cents&lt;/option&gt; &lt;option value="25"&gt;25 cents&lt;/option&gt; &lt;option value="50"&gt;50 cents&lt;/option&gt; &lt;option value="75"&gt;75 cents&lt;/option&gt; &lt;option value="100"&gt;$1.00&lt;/option&gt; &lt;/select&gt; &lt;/label&gt; &lt;/p&gt; &lt;p&gt;Total Deposited:&lt;input name="deposited" id="deposited" type="text" readonly="TRUE" value=""&gt;&lt;/p&gt; &lt;p&gt;Change Returned:&lt;input name="change" id="change" type="text" readonly="TRUE" value=" "&gt;&lt;/p&gt; &lt;p&gt;Bevrage Delivered:&lt;input name="delivered" id="delivered" type="text" readonly="TRUE" value=" "&gt;&lt;/p&gt; &lt;p&gt;&lt;input type="reset" value="Start Over"&gt;&lt;/p&gt; </code></pre> <p></p>
24,514,831
0
<p>It would be helpful if you showed the SQL statement that returns the results.</p> <p>Are the returned arrays in separate $row results?</p> <p>In that case you need to iterate through each $row result, something like:</p> <pre><code>foreach($query-&gt;result() as $row) { for ($p=1; $p&lt;=2; $p++) { echo number_format($row["novhigh_".$p],2); } } </code></pre> <p>On a side note: It looks like the key definition inside the arrays is not logical, why not have the same key value for the "novhigh" element? </p>
4,928,392
0
<p>I have not used it, but Apache James looks like it will support a SQL Backend: <a href="http://james.apache.org/server/3/feature-persistence.html" rel="nofollow">http://james.apache.org/server/3/feature-persistence.html</a> (Make sure you use version 3).</p> <p>Amother option might be to use Apache James Mailets (These are like Servlets for mail) and have them write the statistics to a database when an action takes place on the mail server.</p>
3,328,519
0
Retrieve Data Step by Step after a certain delay using ajax and jquery in php <p>I am a beginner at Jquery. What i want is to display the data using AJAX in a step by step manner. So let say if in my database there is a table "DATA" with a field name "info" having multiple rows as a data </p> <h2>info</h2> <p>1 2 3 4 5</p> <p>Now i want to display all the five rows but after a certain delay of time let say after a second.</p> <p>So i want to use Jquery with AJAX to retrieve data from mySQL table and display each row after a second.</p> <p>Please provide an example for solving this problem. Thanks in Advance...</p>
37,929,151
0
Rails: Fetch nth table record <p>I know I can find the first user in my database in the command line with,</p> <pre><code>User.first </code></pre> <p>And I can find the last with </p> <pre><code>User.last </code></pre> <p>my question is how would I call the 11th user in a database.</p>
16,134,309
0
<p>if we have function f(n) = 3n^2-9n , lower order terms and costants can be ignored, we consider higher order terms ,because they play major role in growth of function. By considering only higher order term we can easily find the upper bound, here is the example.</p> <pre><code> f(n)= 3n^2-9n For all sufficient large value of n&gt;=1, 3n^2&lt;=3n^2 and -9n &lt;= n^2 thus, f(n)=3n^2 -9n &lt;= 3n^2 + n^2 &lt;= 4n^2 *The upper bound of f(n) is 4n^2 , that means for all sufficient large value of n&gt;=1, the value of f(n) wouldn't be greater than 4n^2.* therefore, f(n)= Θ(n^2) where c=4 and n0=1 </code></pre> <p><img src="https://i.stack.imgur.com/5vf3g.jpg" alt="enter image description here"></p> <p><strong>we can directly find the upper bound by saying to ignore lower order terms and constants in the equation f(n)= 3n^2-9n , result will be the same Θ(n^2)</strong></p>
21,169,377
0
XCode 5 - OpenURL not working in ViewController <p>Getting error on <code>UIApplication Expecting ':'</code>.</p> <pre><code>@interface ViewController () @end @implementation ViewController -(IBAction) pushButton{ [[UIApplication sharedApplication openURL: [NSURL URLWithString:@"http://www.portfoliopathway.com"]]; } </code></pre>
40,929,170
0
How to order by one column in one table and another column in other table ,but in a single query? <p>I tried two queries which work fine individually:</p> <p>1) <code>select * from {disputeticket} ORDER BY {creationtime} ASC</code><br> The query is working , here FK=PK of CsTicketState (Column name=State)</p> <p>2) <code>select * from {CsTicketState} where order by {SEQUENCENUMBER} asc</code><br> This one also works, here PK(column name)</p> <p>I need to have both on a single query. Sequence number is 0,1,2</p> <p>I tried the below query but only the first part is getting sorted, not the second part.</p> <pre><code>select {dp:pk},{dp:ticketid},{dp:state},{cts:code},{cts:sequencenumber} from {disputeticket as dp join CsTicketState AS cts on {dp:state}={cts:pk}} ORDER BY {cts:sequencenumber},{dp:creationtime} ASC </code></pre>
36,441,900
0
<p>2) I've already answered similar question <a href="http://stackoverflow.com/a/34278630/1991579">here</a>:</p> <blockquote> <p>If you are using 1 thread, for example, in EventLoopGroup for boss group for 2 different bootstraps, it means that you can't handle connections to this bootstraps simultaneously. So in very very bad case, when boss thread handle only connections for one bootstrap, connections to another will never be handled.</p> <p>Same for workers EventLoopGroup.</p> </blockquote> <p>3) You can do it, and it will work fine. But same as in 2: you can't handle server response simultaneously. If it's ok for you, do it.</p>
11,832,690
0
Swipe Gesture for iOS in Flash CS6 <p>I'm creating an app for iOS (mainly) in Flash CS6 and I'm having a few problems with getting a particular page to work.</p> <p>The layout is as follows: I have a movie clip that is 3 times the width of the stage with my content, with the instance name of <code>txtContent</code>.</p> <p>On a separate layer, my Action Script (v3.0) reads as follows:</p> <pre><code>import com.greensock.*; import flash.events.MouseEvent; //Swipe Multitouch.inputMode = MultitouchInputMode.GESTURE; var currentTile:Number = 1; var totalTiles:Number = 3; txtContent.addEventListener(TransformGestureEvent.GESTURE_SWIPE , onSwipe); function moveLeft():void{ txtContent.x += 640; } function moveRight():void{ txtContent.x -= 640; } function onSwipe (e:TransformGestureEvent):void{ if (e.offsetX == 1) { if(currentTile &gt; 1){ moveLeft() currentTile-- } else {} } if (e.offsetX == -1) { if(currentTile &lt; totalTiles){ moveRight() currentTile++ } } } stop(); </code></pre> <p>When I test the movie, with a touch layer, the movie clip successfully moves left and right for each swipe, and does not continue to move too far in either direction, in effect ignoring any other swipes.</p> <p>However, when I compile the IPA and test on the iPhone, only the first two "tiles" move (I can only see two thirds of the movie clip with swiping), as if I swipe to the third "tile" I cannot swipe back at all. No matter what I do, it gets stuck on that third section.</p> <p>Is there a problem in my code that isn't registering properly in iOS?</p> <p>FYI, I'm testing on an iPhone 3GS.</p>