pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
7,406,247
0
<p><code>Too much recursion</code> means that something is looping over and over again, possibly infinitely. The reason that's happening with your current code is because <code>&lt;a&gt;</code> is a parent of <code>&lt;img&gt;</code>, so any click event on <code>&lt;img&gt;</code> bubble up to the parent <code>&lt;a&gt;</code> (search for "event bubbling" in Google). So your code is basically saying "when someone clicks on <code>&lt;a&gt;</code>, trigger a click on <code>&lt;img&gt;</code> and then <code>&lt;a&gt;</code> (because of event bubbling)" -- which of course causes the code to run again.</p> <p>If the JavaScript plugin already has binded events to clicks on the image, I don't see why you need to bind a click event to the parent <code>&lt;a&gt;</code> that simply clicks on the image. What do you need to happen that isn't already happening when the user clicks on the <code>&lt;img&gt;</code> -- without including your jQuery code?</p>
17,517,466
0
Visual Studio 2013 Preview Native C++ Edit and Continue <p>Has anyone been able to use <a href="http://msdn.microsoft.com/en-us/library/esaeyddf(v=vs.120).aspx" rel="nofollow">Edit and Continue</a> with Visual Studio 2013 Preview and a C++ native application (either 32 or 64 bit)?</p> <p>After making a simple console application, setting a breakpoint, then making any type of change: </p> <pre><code>Edit and Continue : error 1002 : Data symbol has changed </code></pre> <p>This MSDN page suggests it should work, and I've done everything I think I need to do, such as enabling native Edit and Continue in Tools->Options->Debugging->Edit and Continue<br> <a href="http://msdn.microsoft.com/en-us/library/esaeyddf(v=vs.120).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/esaeyddf(v=vs.120).aspx</a></p> <p>I have no problems with it working in VS 2012. I realize it is a "preview", but I'd be surprised if it is simply broken without any comment. At least a better error could be displayed, such as "not yet enabled in preview".</p> <p>All my googling shows comments about E&amp;C being added for 64bit managed apps, but nothing about native. I tested a simple managed app, and it works there.</p>
41,041,344
0
Retrieve Google Analytics quotas consumption via API <p>i want to be able to fetch all the quotas status related to the google analytics API consumption. One part of it seems to be available via IAM:</p> <p><a href="https://i.stack.imgur.com/7TGr2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7TGr2.png" alt="IAM Quota monitoring console"></a></p> <p>First, accessing to these data through an API would be nice..is it possible with the IAM API ?? If so, can i get a sample ?</p> <p>Next, i need one more data: the google analytics quota consumption PER VIEW (which is limited to 10.000 queries per view per day)..is it also possible to fetch this data, one way or another ?</p> <p>Cheers,</p> <p>Clément.</p>
10,820,054
0
<p>I found the answer -</p> <pre><code>xrLabelGoal.Text = ((DataRowView)GetCurrentRow()).Row["goalnumber"].ToString(); </code></pre> <p>Turns out I was missing the System.Data which allowed me to use the DataRowView. This fixed it. </p>
36,033,771
0
Adaptive size classes weired issue <p>My app is universal. I have different constraints for iphone and ipad. Using adaptive size classes, Particularly i am assigning label leading margin to superview = 390, for ipad only. As you can see in attached image. <a href="https://i.stack.imgur.com/J2mcg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J2mcg.png" alt="enter image description here"></a></p> <p>It is working fine, when text to label is static, but my text to label is getting changed dynamically and continuously. Because of this, my lablel's position is getting shifted horizontally.</p> <p><a href="https://i.stack.imgur.com/9n37v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9n37v.png" alt="original position of label"></a></p> <p><a href="https://i.stack.imgur.com/FizDh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FizDh.png" alt="changing to this position"></a></p> <p><a href="https://i.stack.imgur.com/Hicml.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hicml.png" alt="enter image description here"></a></p>
10,634,536
0
<p>Here is the code I'm using. Change BUFFER_SIZE for your needs.</p> <pre><code>import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class ZipUtils { private static final int BUFFER_SIZE = 4096; private static void extractFile(ZipInputStream in, File outdir, String name) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(outdir,name))); int count = -1; while ((count = in.read(buffer)) != -1) out.write(buffer, 0, count); out.close(); } private static void mkdirs(File outdir,String path) { File d = new File(outdir, path); if( !d.exists() ) d.mkdirs(); } private static String dirpart(String name) { int s = name.lastIndexOf( File.separatorChar ); return s == -1 ? null : name.substring( 0, s ); } /*** * Extract zipfile to outdir with complete directory structure * @param zipfile Input .zip file * @param outdir Output directory */ public static void extract(File zipfile, File outdir) { try { ZipInputStream zin = new ZipInputStream(new FileInputStream(zipfile)); ZipEntry entry; String name, dir; while ((entry = zin.getNextEntry()) != null) { name = entry.getName(); if( entry.isDirectory() ) { mkdirs(outdir,name); continue; } /* this part is necessary because file entry can come before * directory entry where is file located * i.e.: * /foo/foo.txt * /foo/ */ dir = dirpart(name); if( dir != null ) mkdirs(outdir,dir); extractFile(zin, outdir, name); } zin.close(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
18,169,735
0
<p>The input method framework is based upon the idea of an input connection. The framework instantiates one between the keyboard and the EditText. If you want to accept text from the keyboard you need to implement that side of the interface yourself, then get the framework to use your interface as the other half of the input session. This is really, really non-trivial and if you do it wrong specialized keyboards like Swype, Swiftkey, etc will not work correctly. I wouldn't suggest doing it without a very good reason. </p> <p>If you just want them to type into an existing edit text, focus that view instead. That way the input connection will be set to that view and everything will be done for you.</p>
6,394,860
0
<p>@Maz - thank you for that. I'm learning at the moment and need to look at <code>service_set</code>.</p> <p>@arustgi - that worked perfectly. For the benefit of fellow novices stumbling over this, I pass in <code>'queryset': Service.objects.all()</code> and use:</p> <pre><code> {% regroup object_list by area as area_list %} {% for area in area_list %} &lt;h2 class="separate"&gt;{{ area.grouper }}&lt;/h2&gt; {% for service in area.list %} &lt;div class="column"&gt; &lt;h3&gt;{{ service.title }}&lt;/h3&gt; {{ service.body }} &lt;/div&gt; {% endfor %} {% endfor %} </code></pre> <p>Concise, descriptive code. Many thanks, both of you</p>
8,835,956
0
Make CVDisplayLink + Automatic Reference Counting play well together <p>I recently switched from using NSTimer to CVDisplayLink to redraw my OpenGL animation, but i've got a little problem making it work with ARC switched on:</p> <pre><code>/* * This is the renderer output callback function. */ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) { // now is the time to render the scene [((__bridge BDOpenGLView*)displayLinkContext) setNeedsDisplay:YES]; // always succeeds, because we don't actually do anything here anyway return kCVReturnSuccess; } </code></pre> <p>The display link callback function has to be written in C, to be used as a parameter for</p> <pre><code>// set the renderer output callback function CVDisplayLinkSetOutputCallback(displayLink, &amp;displayLinkCallback, (__bridge void*)self); </code></pre> <p>So i can't use <code>self</code> within in the callback, but using <code>((__bridge BDOpenGLView*) displayLinkContext)</code> produces a memory leak:</p> <pre><code>objc[29390]: Object 0x1001b01f0 of class NSConcreteMapTable autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug </code></pre> <p>I read, that i have to set up an <code>NSAutoreleasePool</code> myself, but i can't with ARC switched on.</p> <p>Am i missing something?</p>
27,251,414
0
java.util.concurrent.TimeoutException: Request timed out to in gatling <p>Hi i'm running concurrent users 200 over 200 seconds, when I execute same script after 2-3 sets I'm getting this error do i need to do some settings in gatling for example shareConnections in conf file or its because server is not able to respond to more request.</p> <pre><code>class LoginandLogout extends Simulation { val scn = scenario("LoginandLogout") .exec(Login.open_login) .pause(Constants.SHORT_PAUSE) .exec(CommonSteps.cscc_logout_page) setUp(scn.inject(rampUsers(200) over (200 seconds))).protocols(CommonSteps.httpProtocol) } </code></pre> <p>I'm using gatling 2.0.0-RC5 scala 2.10.2</p>
38,972,851
0
<p>If you are using a version of .net less than 4.5, manual collection may be inevitable (especially if you are dealing with many 'large objects'). </p> <p>this link describes why:</p> <p><a href="https://blogs.msdn.microsoft.com/dotnet/2011/10/03/large-object-heap-improvements-in-net-4-5/" rel="nofollow">https://blogs.msdn.microsoft.com/dotnet/2011/10/03/large-object-heap-improvements-in-net-4-5/</a></p>
12,789,997
0
<pre><code>set.intersection(*map(set,d3)) </code></pre> <p><em>Will</em> actually work, though because <code>d3</code> already contains sets you can just do:</p> <pre><code>set.intersection(*d3) </code></pre> <p>And, in fact, only the first one needs to be a <code>set</code> - the others can be any iterable, and <code>intersection</code> will setify them by itself.</p> <p>The problem you're having doesn't seem to be in this code - rather, </p> <pre><code>for list1 in masterlist: list1 = thingList1 </code></pre> <p>Won't actually put anything into <code>thingList1</code>. It is hard to tell without seeing what <code>masterlist</code> looks like, but you may want something like:</p> <pre><code>for list1 in masterlist: thingList1[:] = list1 </code></pre> <p><code>print</code> your three lists before you do the intersection to make sure they contain what you expect.</p>
17,611,242
0
<p>First of all, C++ is not designed to work like that. So it is not a surprise that this is happening.</p> <p>But, since you're using Visual Studio, you could take advantage of <a href="http://en.wikipedia.org/wiki/C%2B%2B/CX#Partial_classes" rel="nofollow">partial classes</a>. Unfortunately, it seems this characteristic is only related to C++/CX so maybe yo won't be able to use it.</p> <p>You will still need to declare a partial class in your namespace hierarchy, but I guess it could be empty.</p> <p>To be honest, I haven't used this feature and I don't know how far can it be bent in order to achieve what you want. But you could anyway give it a try.</p> <p>Remember that this is a Visual Studio extension, so your code won't be cross-platform.</p> <p>Hope this helps. Somehow.</p>
20,594,029
1
How do you order what websites reply in Skype4Py? <p>I use Skype4Py for my Skype Bot I've been working on. <br> I was wondering how I could order what the APIs respond.<br> For example, if I wanted to get the weather, I'd type !weather<br> and it would respond with: </p> <blockquote> <p>Gathering weather information. Please wait...<br> Weather: { "data": { "current_condition": [ {"cloudcover": "0", "humidity": "39", "observation_time": "11:33 AM", "precipMM": "0.0", "pressure": "1023", "temp_C": "11", "temp_F": "51", "visibility": "16", "weatherCode": "113", "weatherDesc": [ {"value": "Clear" } ], "weatherIconUrl": [ {"value": "http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0008_clear_sky_night.png" } ], "winddir16Point": "N", "winddirDegree": "0", "windspeedKmph": "0", "windspeedMiles": "0" } ], "request": [ {"query": "90210", "type": "Zipcode" } ] }} </p> </blockquote> <p>and I would like to have it be more like: </p> <blockquote> <p>Weather:<br> Current Temp: 51 F | 22 C<br> Humidity: 39%<br> Wind Speed: 0 MPH</p> </blockquote> <p>or something cleanly ordered out like that.<br> That way it looks less ugly in Skype, and looks more professional. </p> <hr> <p>I should've added the code: </p> <pre><code> def weather(zip): try: return urllib2.urlopen('http://api.worldweatheronline.com/free/v1/weather.ashx?q='+zip+'&amp;format=json&amp;num_of_days=1&amp;fx=no&amp;cc=yes&amp;key=r8nkqkdsrgskdqa9spp8s4hx' ).read() except: return False </code></pre> <p>That is my functions.py </p> <p>This is my commands.py: </p> <pre><code> elif msg.startswith('!weather '): debug.action('!weather command executed.') send(self.nick + 'Gathering weather information. Please wait...') zip = msg.replace('!weather ', '', 1); current = functions.weather(zip) if 4 &gt; 2: send('Weather: ' + current) else: send('Weather: ' + current) </code></pre> <p>Like I stated, I'm using Skype4Py, and yeah. </p>
27,324,005
0
<p>The jar may be in your deployed folder, but is the jar (or your deployed folder with a wildcard) in the CLASSPATH?</p>
36,256,638
0
<p>First you read a byte from <code>pFile1</code> with <code>fgetc()</code> so the file pointer has moved one step ahead, then you do a <code>fread()</code> so the first byte will never land in <code>buffer</code></p> <pre><code> for(counter=0; counter&lt;fileLen; counter++) { fputc(fgetc(pFile1),pFile2); ch = fread(buffer, sizeof(char), 6000000, pFile1); printf("%02x", buffer[counter]); } </code></pre> <p>I find it a bit difficult to understand why you do the fread in the manner you do. If you really want to display the byte you just read then just assign the return value from <code>fgetc</code> to a variable and print it out .</p> <pre><code> for (counter=0; counter&lt;fileLen; ++counter) { int ch = fgetc(pfile1); printf("%02X", ch ); int written = fputc(ch,pfile2); if (written != EOF) { buffer[counter]=ch; } else // some error handling } </code></pre>
12,987,229
0
<p>Yes <a href="http://docs.python.org/library/stdtypes.html#dict.get" rel="nofollow">dict.get</a> is the correct (or at least, the simplest) way:</p> <pre><code>sorted(trial_list, key=trial_dict.get) </code></pre> <p>As Mark Amery commented, the equivalent explicit lambda:</p> <pre><code>sorted(trial_list, key=lambda x: trial_dict[x]) </code></pre> <p>might be better, for at least two reasons:</p> <ol> <li>the sort expression is visible and immediately editable</li> <li>it doesn't suppress errors (when the list contains something that is not in the dict). </li> </ol>
27,912,810
0
Change turtle size keeping lower point position constant <p>I have distributed turtles on the world having size <code>x</code> and I wish to increase their size to <code>y</code> but the I want to keep their location of their lower further point same (Check figure below). How can one accomplish this? </p> <p>EDIT: I wished to write a procedure that could be applicable for all turtle heading, that is if the turtle is heading 0 or 90 or 45. Direct math in such case could be complicated. <img src="https://i.stack.imgur.com/foaIr.png" alt="Figure"></p>
1,481,039
0
Show certain InfoWindow in Google Map API V3 <p>I wrote the following code to display markers. There are 2 buttons which show Next or Previous Infowindow for markers. But problem is that InfoWindows are not shown using google.maps.event.trigger Can someone help me with this problem. Thank you. Here is code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt; &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"/&gt; &lt;title&gt;Google Maps JavaScript API v3 Example: Common Loader&lt;/title&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var infowindow; var map; var bounds; var markers = []; var markerIndex=0; function initialize() { var myLatlng = new google.maps.LatLng(41.051407, 28.991134); var myOptions = { zoom: 5, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); markers = document.getElementsByTagName("marker"); for (var i = 0; i &lt; markers.length; i++) { var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(markers[i].getAttribute("name"), latlng, markers[i].getAttribute("phone"), markers[i].getAttribute("distance")); } rebound(map); } function createMarker(name, latlng, phone, distance) { var marker = new google.maps.Marker({position: latlng, map: map}); var myHtml = "&lt;table style='width:100%;'&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;" + name + "&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;" + phone + "&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align='right'&gt;" + distance + "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"; google.maps.event.addListener(marker, "click", function() { if (infowindow) infowindow.close(); infowindow = new google.maps.InfoWindow({content: myHtml}); infowindow.open(map, marker); }); return marker; } function rebound(mymap){ bounds = new google.maps.LatLngBounds(); for (var i = 0; i &lt; markers.length; i++) { bounds.extend(new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")))); } mymap.fitBounds(bounds); } function showNextInfo() { if(markerIndex&lt;markers.length-1) markerIndex++; else markerIndex = 0 ; alert(markers[markerIndex].getAttribute('name')); google.maps.event.trigger(markers[markerIndex],"click"); } function showPrevInfo() { if(markerIndex&gt;0) markerIndex--; else markerIndex = markers.length-1 ; google.maps.event.trigger(markers[markerIndex],'click'); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialize()"&gt; &lt;div id="map_canvas" style="width:400px; height:300px"&gt;&lt;/div&gt; &lt;markers&gt; &lt;marker name='Name1' lat='41.051407' lng='28.991134' phone='+902121234561' distance=''/&gt; &lt;marker name='Name2' lat='40.858746' lng='29.121666' phone='+902121234562' distance=''/&gt; &lt;marker name='Name3' lat='41.014604' lng='28.972256' phone='+902121234562' distance=''/&gt; &lt;marker name='Name4' lat='41.012386' lng='26.978350' phone='+902121234562' distance=''/&gt; &lt;/markers&gt; &lt;input type="button" onclick="showPrevInfo()" value="prev"&gt;&amp;nbsp;&lt;input type="button" onclick="showNextInfo()" value="next"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
35,069,505
0
<p>If you want to test just the logic (and not that <code>date</code> is working correctly), then allow your script to accept <code>CUR_DAY</code> and <code>CUR_HOUR</code> as arguments or via the environment, instead of always running <code>date</code>.</p> <p>Via the environment (<code>CUR_DAY=9 CUR_HOUR=22 myscript</code>)</p> <pre><code>: ${CUR_DAY:=$(date +%a)} : ${CUR_HOUR:=$(date +%H)} </code></pre> <p>Via arguments (<code>myscript 9 22</code>)</p> <pre><code>CUR_DAY=${1:-$(date +%a)} CUR_HOUR=${2:-$(date +%H)} </code></pre> <p>Either approach will work in any POSIX-compliant shell.</p>
972,282
0
<p><strong>Regarding #9:</strong></p> <p>When you provide a context to your selector queries you limit the size of the tree being traversed to find the elements matching your selector, especially if you're using selectors that use tag names like: $('div > span').</p> <p>Performance depends on the type of selector and the number of elements in the context you're providing.</p> <p>Take a look at <a href="https://developer.mozilla.org/En/DOM/Document.getElementsByTagName" rel="nofollow noreferrer">getElementsByTagName</a> to better understand these issues.</p> <p>As for "which one is better" - this depends heavily on the size of the DOM being traversed and on a number of other elements, but in general, the first selector (the one with the context) should be faster.</p> <p><strong>Regarding #12:</strong></p> <p>In general, it is good practice to use event delegation when the number of child elements inside a parent element (cells inside a table, for example) is unknown and is expected to be quite large. This usually applies to cases where data is pulled from a server. The common scenarios are tree and grid structures.</p> <p><strong>Regarding #13:</strong></p> <p>I think the example provided in the document you're referring to does the job, but I'll try to elaborate a bit further. Classes are a common and standard way to attach additional information to HTML nodes. Lets take a Tab bar as an example: assuming you have a standard class "tab" which applies to every tab in your tab bar, you could add an additional class to one of the tabs to indicate that it is currently selected. Adding an additional class called "selected" would allow you to apply a different style to the selected tab and query the tab bar using jQuery for some additional logic (for example: check which tab is currently selected to perform an HTTP request and retrieve the content for this tab).</p> <p><strong>Regarding #14:</strong></p> <p>Classes are limited in the type and amount of data you can (or should) store in them. Data is a more flexible way to store large amounts of state data for HTML elements.</p>
6,048,553
0
<p>Is your project configured as a console application? It needs to be built with different switches in order to set the flags in the exe file so that the OS loader will know that it needs to create a console window for the process. GUI apps don't set that flag, and don't get a console window.</p> <p>In VS2010, right click on your project's Properties link, click on the Application tab, and change Output Type from Windows Application to Console Application. Rebuild and run.</p>
12,453,586
0
what is the usage of HTML5 figure with img <p>Is there any specific advantage/usage of using HTML5 <a href="https://developer.mozilla.org/en-US/docs/HTML/Element/figure"><code>&lt;figure&gt;</code></a> over <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img"><code>&lt;img&gt;</code></a>?</p> <p>I think <code>&lt;figure&gt;</code> is useless without <a href="https://developer.mozilla.org/en-US/docs/HTML/Element/figcaption"><code>&lt;figurecaption&gt;</code></a>, isn't it?</p> <p>It will be helpful if explain with an example.</p>
29,751,046
0
Is it possible to apply DDD with generic classes and dynamic queries retrieval? <p>I´m wondering if it´s possible to use DDD without using EF's stuff, cause in my project the classes are generic complex types with generic inheritance that may vary from time to time, also the DB tables and fields may vary from one client DB version to another, also the queries to the database that are dynamically constructed depending of the generic object that it's produced. </p> <p>I'm currently taking into consideration this design pattern: <a href="https://www.google.be/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=3&amp;cad=rja&amp;uact=8&amp;ved=0CC4QFjAC&amp;url=http%3A%2F%2Fmysoftwarebrasil.googlecode.com%2Fsvn%2Ftrunk%2FApostilas%2FN-Layered_Domain_Oriented_Architecture_Gu.pdf&amp;ei=ag41VfDnNMfaaPemgUA&amp;usg=AFQjCNHx-myttEEeUuE9bGuKZzqvdXS5yA&amp;sig2=pO-t4JxMN35HYoJKUIg0AA&amp;bvm=bv.91071109,d.d2s" rel="nofollow">DDD N-Layered .NET 4.0 Architecture Guide </a> by Cesar de la Torre among others.</p> <p>Thank you all in advance. </p>
19,421,659
0
VS 2012 Plugin to make working with Classic ASP Easier <p>I am currently working with a Classic ASP project that grabs some data from the database, creates a bunch of HTML and embeds the data into it, then emails that to people.</p> <p>I want to know where this HTML body is being generated (company wants to make a change to it), the files involved are numerous and have hundreds of includes .. is there a way I can easily determine the location of the emailing code?</p> <blockquote> <p>Ctrl + Shift + F</p> </blockquote> <p>Does not work because that HTML is shared among many pages, and none of them match the Source Code in the Email I am getting. Could this be because Outlook 2010 adds extra Markup?</p> <p>Are there any VS 2012 plugins that make working with Classic ASP easier and aid me solve my problem?</p> <p>Would greatly appreciate any help.</p> <p>Thanks</p>
30,710,709
0
<p>Use the <code>ng-click</code> directive:</p> <pre><code>&lt;div class="item" ng-click="clicked(d)" ng-class="{ active: d.selected }"&gt; &lt;h3 class="spaceWrap"&gt;&lt;b&gt;{{d.Name}}&lt;/b&gt;&lt;/h3&gt; &lt;/div&gt; </code></pre> <p>controller:</p> <pre><code>var selected = []; $scope.clicked = function (member) { var index = selected.indexOf(member); if(index &gt; -1) { selected.splice(index, 1); member.selected = false; } else { selected.push(member); member.selected = true; } } </code></pre> <p><a href="http://jsfiddle.net/po1cod44/1/">JSFIDDLE</a></p>
14,626,462
0
Highchart renderer path issue in IE8 <p>I have been using </p> <pre><code>chart.renderer.path(['M', 12, 0, 'L', 6, 12, 'L', 18, 12, 'Z']).attr({ 'stroke-width' : 2, 'fill' : 'black', 'transform' : "translate(" + x + "," + y + ")" }).add(); </code></pre> <p>to draw triangle path over the chart and move to require position by using Translate attribute.</p> <p>But In IE8, the transform attribute is being ignored (the triangle appears in the top left corner), but it works fine in FF, Chrome etc. Is that the problem with CSS3 support issue?</p> <p>Is there any work around to fix this issue?</p> <p>Thanks Peter</p>
1,935,509
0
How to set the message of the NotEmpty validator on a Zend_Form_Element? <p>I have a form element that I'm setting as required:</p> <pre><code>$this-&gt;addElement('text', 'email', array( 'label' =&gt; 'Email address:', 'required' =&gt; true )); </code></pre> <p>Since I'm setting required to true, it makes sure that it's not empty. The default error message looks like this:</p> <pre><code>"Value is required and can't be empty" </code></pre> <p>I tried setting the message on the validator, but this throws a fatal error:</p> <pre><code>$validator = $this-&gt;getElement('email')-&gt;getValidator('NotEmpty'); $validator-&gt;setMessage('Please enter your email address.'); </code></pre> <blockquote> <p>Call to a member function setMessage() on a non-object</p> </blockquote> <p>How can I set the message to a custom error message?</p>
36,555,645
0
The most correct implementation with regards to OOP design? <p>Right now I have a subclass of <code>UICollectionViewCell</code> called <code>MyCollectionViewCell</code> and this class has a few <code>UITextViews</code> and as a result implements its own <code>UITextFieldDelegate</code> methods. I also have a subclass of <code>UIView</code> called <code>MyView</code> that is a container view for 2 <code>UIViews</code> all in the same <code>UIViewController</code> and has some methods that control the interactions between the two views. </p> <p>My question is should I create delegates for <code>MyCollectionViewCell</code> and <code>MyView</code> so that the <code>ViewController</code> can handle all the logic or should I keep the classes self contained so that they control their own actions which can be called via the <code>ViewController</code> that they are both contained in?</p>
14,386,487
0
Bootstrap progress bar using $.get <p>I realize there are a good number of progress bar related questions already present on SO. I browsed through many of them and was unable to get things working.</p> <p>Simply put, I am developing a page in JSP and I want to use an animated progress bar within bootstrap to display while the calls are being made for the data.</p> <p>HTML:</p> <pre><code>&lt;div class="row-fluid"&gt; &lt;div class="span12 progress progress-striped active"&gt; &lt;div id="searchAnimation" class="bar" hidden="true"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Servlet (Not sure if this part is relevant, but better safe than sorry):</p> <pre><code>@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //String that gets returned as HTML StringBuilder returnAsHTML = new StringBuilder(); //See if the class is closed, has a lab, or is just a regular class for(ClassInfo classes : springClassListings) { //Class is full, style accordingly if(classes.getSectionMeetingInfo().contentEquals("LEC") &amp;&amp; classes.getSectionEnrolled().contentEquals("0")) { returnAsHTML.append(closedClass(classes)); } else if(classes.getSectionMeetingInfo().contentEquals("LAB")) //These are labs, style accordingly { returnAsHTML.append(labClass(classes)); } else //These are normal classes without lab components { returnAsHTML.append(openClass(classes)); } } response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(returnAsHTML.toString()); } </code></pre> <p>And my scripting:</p> <pre><code>//Serves up the data $('#btnData').click(function() { //THIS IS THE PROGRESS BAR $("#searchAnimation").show(); $.get('daoServlet', function(responseText) { $('#dataDisp').html(responseText); }); }); </code></pre> <p>I get the idea, % the width of the progress bar by a where the $.get call is at in terms of getting the data. I just don't understand how to do it.</p> <p>PS - I know my for/if in the doGet is a nasty anti pattern, I just haven't figured out a way around it yet.</p>
37,204,549
0
<p>it's working properly here. Make sure you're using returns inside a function.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function test(a, b){ var dateFrom = Date.parse(a); var dateTo = Date.parse(b); if ( dateFrom &gt; dateTo ) { console.log( a, ' &gt; ',b ); return false; } console.log( a, ' &lt;= ', b ); return true; } var result = test('06-05-2016 13:05', '13-05-2016 13:05'); document.getElementById('test').innerHTML = result; console.log( result )</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="test"&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
30,522,654
0
<p>First <a href="http://www.1001freefonts.com/" rel="nofollow">download</a> the .ttf file of the font you need (arial.ttf). Place it in the assets folder(Inside assest folder create new folder named "fonts" and place it inside it). If "txtyour" is the textvies you want to apply the font , use the following piece of code,</p> <pre><code> Typeface type = Typeface.createFromAsset(getAssets(),"fonts/arial.ttf"); txtview.setTypeface(type); </code></pre>
23,019,653
0
<p>Thanks for responding Ali. I figured it out. Here is what I am doing: </p> <p>Sender: I am sending the ID as the "contentId" (instead of a video url) in the loadMedia method.</p> <p>Receiver: I added the ansynchronous call to the beginning of the "onLoad" event and then overwrite the data['media']['contentId'] value with the URL of the video.</p>
3,920,557
0
<p>Look at <a href="http://msdn.microsoft.com/en-us/library/ms536914%28v=vs.85%29.aspx" rel="nofollow"><code>oncontextmenu()</code></a>.</p> <p>Careful though, users expect the default when they right click. It may annoy some power users.</p> <p><a href="http://luke.breuer.com/tutorial/javascript-context-menu-tutorial.htm" rel="nofollow">This</a> looks like good reading.</p>
13,567,122
0
How to parse text in Groovy <p>I need to parse a text (output from a svn command) in order to retrieve a number (svn revision). This is my code. Note that I need to retrieve all the output stream as a text to do other operations.</p> <pre><code>def proc = cmdLine.execute() // Call *execute* on the strin proc.waitFor() // Wait for the command to finish def output = proc.in.text </code></pre> <p>//other stuff happening here</p> <pre><code>output.eachLine { line -&gt; def revisionPrefix = "Last Changed Rev: " if (line.startsWith(revisionPrefix)) res = new Integer(line.substring(revisionPrefix.length()).trim()) } </code></pre> <p>This code is working fine, but since I'm still a novice in Groovy, I'm wondering if there were a better idiomatic way to avoid the ugly if...</p> <p>Example of svn output (but of course the problem is more general)</p> <pre><code>Path: . Working Copy Root Path: /svn URL: svn+ssh://svn.company.com/opt/svnserve/repos/project/trunk Repository Root: svn+ssh://svn.company.com/opt/svnserve/repos Repository UUID: 516c549e-805d-4d3d-bafa-98aea39579ae Revision: 25447 Node Kind: directory Schedule: normal Last Changed Author: ubi Last Changed Rev: 25362 Last Changed Date: 2012-11-22 10:27:00 +0000 (Thu, 22 Nov 2012) </code></pre> <p>I've got inspiration from the answer below and I solved using find(). My solution is:</p> <pre><code>def revisionPrefix = "Last Changed Rev: " def line = output.readLines().find { line -&gt; line.startsWith(revisionPrefix) } def res = new Integer(line?.substring(revisionPrefix.length())?.trim()?:"0") </code></pre> <p>3 lines, no if, very clean</p>
11,809,126
1
Cannot determine vowels from consonants <p>With the code below, no matter what the first letter of the input is, it is always determined as a vowel:</p> <pre><code>original = raw_input("Please type in a word: ") firstLetter = original[0] print firstLetter if firstLetter == "a" or "e" or "i" or "o" or "u": print "vowel" else: print "consonant" </code></pre> <p>In fact, it doesn't matter what the boolean is in the if statement... if it is == or != , it is still return <code>"vowel"</code>. Why?</p>
26,009,819
0
<p>Qt does not include a compiler. On Windows you're probably either compiling with mingw or Visual C++. Either way, the issue is that you're calling a function that expects a wide character string but you're trying to hand it an 8-bit character string.</p> <p>For compatibility reasons, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.aspx" rel="nofollow">Win32 uses a different set of API functions if you have _UNICODE defined</a>. In your case, you do have _UNICODE defined. You can continue using the 8-bit std::string but simply change the method from <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045%28v=vs.85%29.aspx" rel="nofollow">LoadImage() to LoadImageA()</a>. Or if you don't mind changing your Bitmap class, you could switch from std::string to std::wstring to take advantage of Windows' Unicode features.</p> <p>But perhaps the larger question is why use Win32 to load bitmaps and std::string if you're using Qt? Qt's <a href="http://qt-project.org/doc/qt-5/QImage.html" rel="nofollow">QImage class</a> and <a href="http://qt-project.org/doc/qt-5/qstring.html" rel="nofollow">QString class</a> provide a full-featured, cross-platform strings and image loaders. Like any comprehensive framework, Qt works best if you only use external features on an as-needed basis. </p>
27,584,059
0
<p>Update:</p> <p>Use the <a href="http://api.jquery.com/replacewith/" rel="nofollow">replaceWith</a> jquery for this, for example:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;find demo&lt;/title&gt; &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;ol type="1"&gt; &lt;h1&gt;Main Title&lt;/h1&gt; &lt;/ol&gt; &lt;script&gt; $("h1").replaceWith( "&lt;li&gt;" + $("h1").text() + "&lt;/li&gt;" ); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
39,814,785
0
Acknowledgements in socket.io when using mongoose <p>I use <code>socket.io</code> to communicate between server and client.</p> <p>On the server, I have</p> <pre><code>socket.on('new object', (id, object) =&gt; { Model.findByIdAndUpdate(id, { $addToSet: { objects: object } }, { new: true }).then(model =&gt; { io.sockets.emit('new object', object); }).catch(err =&gt; { console.log(err); }); }); </code></pre> <p>So when a new object is created, I broadcast it to all sockets (including the sender).</p> <p>What I want is to tell the client who started this process from the client if everything was successful.</p> <p>I have found <a href="http://socket.io/docs/#sending-and-getting-data-(acknowledgements)" rel="nofollow">http://socket.io/docs/#sending-and-getting-data-(acknowledgements)</a>, but I don't know exactly how to do it.</p> <p>I guess I should do something like</p> <pre><code>socket.on('new object', (id, object, callbackFunction) =&gt; { Model.findByIdAndUpdate(id, { $addToSet: { objects: object } }, { new: true }).then(model =&gt; { callbackFunction('success'); io.sockets.emit('new object', object); }).catch(err =&gt; { callbackFunction('error'); }); }); </code></pre> <p>and on the client have</p> <pre><code>socket.emit('new object', id, object, function (msg) { alert(msg); }); </code></pre> <p>but is this correct? I guess there will be a problem of calling <code>callbackFunction</code> inside <code>then</code> and <code>catch</code>.</p>
28,067,925
0
<p>You could do something like this:</p> <pre><code>Dim sLowerCase As String = "qwertyuiopasdfghjklzxcvbnm" Dim sUpperCase As String = "MNBVCXZLKJHGFDSAPOIUYTREWQ" Dim sNumbers As String = "1234567890" Dim x = New Random(Now.GetHashCode) Dim y = {sLowerCase, sUpperCase, sNumbers} Dim z = y(x.Next(0, y.Length)) Debug.Print(z) </code></pre>
23,827,108
0
SQL Server transactional replication performance <p>I have an issue with SQL Server transactional replication performance. The published articles are on a database which is being used quite heavily however i am not convinced the replication is should be going this slow and I could use some advice on interpreting the information from replication monitor.</p> <p><img src="https://i.stack.imgur.com/tm3yS.png" alt="http://i.imgur.com/Alx37tO.png"> <img src="https://i.stack.imgur.com/T89Tt.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/POdnS.png" alt="enter image description here"></p> <p>I have noticed that the distributor agent has a delivery rate of 0 which concerns me. Can someone explain what the following information means in real terms and how i can go about improving the performance of replication?</p>
20,097,995
0
Referencing Databases In SQL 2008 Mirrored Reporting <p>I have 2 databases.</p> <p>1 is a mirror of the other, <strong>EXCEPT</strong>, 1 has a table called <strong>DOG</strong> and the other has the same table but it is called <strong>DOG2</strong>.</p> <p>I have an ssrs report that references DOG..DOGID. </p> <p>Now when DOG goes down I want to use the connection string to DOG2, the only issue is my reference to DOG..ID will no longer be valid if I am connecting to DOG2. </p> <p>Is there a way in SQL code to make it so if DOG..DOGID is invalid use DOG2..DOGID?</p>
9,330,629
0
<p>I have same problem I solved so:</p> <p>first create a class KeyBoardManager:</p> <pre><code>import android.content.Context; import android.os.Handler; import android.view.inputmethod.InputMethodManager; public class KeyBoardManager { public KeyBoardManager(Context context) { final Handler handler = new Handler(); final InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); new Thread(new Runnable() { @Override public void run() { while(true){ try{Thread.sleep(100);}catch (Exception e) {} handler.post(new Runnable() { @Override public void run() { if(!imm.isAcceptingText()){ imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); } } }); } } }).start(); } } </code></pre> <p>and in method onCreate of first activity you create a new instance of KeyBoardManager like:</p> <pre><code>public class Main extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); new KeyBoardManager(this); } } </code></pre> <p>and when your edittext is draw in screen for the firs time you call:]</p> <pre><code>(new Handler()).postDelayed(new Runnable() { editText.requestFocus(); editText.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN , 0, 0, 0)); editText.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0)); }, 200); </code></pre>
7,694,627
0
<p>this should explain it:</p> <p><a href="http://mobile.tutsplus.com/tutorials/android/android-application-preferences/" rel="nofollow">http://mobile.tutsplus.com/tutorials/android/android-application-preferences/</a></p>
28,868,396
0
<p>You need to use a string rather than a variable:</p> <pre><code>if user_seating == 'economy': </code></pre> <p>The way you have it, Python is looking for an actual variable named <code>economy</code> declared in your code (which there isn't as the <code>NameError</code> tells you).</p>
16,830,269
0
<pre><code>// You may use FormClosing Event of Form private void yourForm_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("Want to exit from Application ?", MessageBoxButtons.YesNo) == DialogResult.Yes) { Environment.Exit(0); } else { // your Code for Changes or anything you want to allow user changes etc. e.Cancel = true; } } </code></pre>
20,903,795
0
<p>I think the basic recipe to do this without tabindex (why do you want to do this btw?) would be something like:</p> <pre><code>$(document).on('keypress',function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { //if the key pressed was 'tab'... e.preventDefault(); //put code here to focus on the next tab, //probably using http://api.jquery.com/focus/ .focus() //remember to select the very first tab when you reach the last tab! } }); </code></pre> <p>with thanks to this answer: <a href="http://stackoverflow.com/questions/1314450/jquery-how-to-capture-the-tab-keypress-within-a-textbox">jQuery: How to capture the TAB keypress within a Textbox</a></p>
14,001,367
0
<p>What you might be seeing is that until the alert box is dismissed, the code afterwards is not executed. The alert command is a blocking one.</p> <p>Perhaps you can use <code>console.log()</code> for debugging purposes of this feature. This will not block your code and it will be executed on the <code>keydown</code> event.</p>
3,269,538
0
<p>I think it will be very useful to you to look at the code of the validator of <a href="http://trac.symfony-project.org/browser/plugins/sfDoctrineGuardPlugin/trunk/lib/validator/sfGuardValidatorUser.class.php" rel="nofollow noreferrer">sfDoctrineGuardPlugin</a>. They create that post validator, and <a href="http://trac.symfony-project.org/browser/plugins/sfDoctrineGuardPlugin/trunk/lib/form/doctrine/base/BasesfGuardFormSignin.class.php" rel="nofollow noreferrer">set it in the form</a>. Even if you don't want to use sfDoctrineGuardPlugin (or sfGuardPlugin if you use Propel) its code can be a valuable source of inspiration. </p>
28,971,935
0
<p>The only version of OneNote that is available for Mac OSX is available through the app store.</p> <p>There is no version of OneNote 2010 that works on Mac.</p>
5,063,262
0
<p>Sounds like your rendering thread is just sat there waiting for the update thread to finish what its doing which causes the "jitter". Perhaps put in some code that logs how long a thread has to wait for before being allowed access to the other thread to find out if this really is the issue.</p>
20,621,434
0
<p>Try the jQuery function <code>val()</code> instead of the non-existant property <code>.value</code>:</p> <pre><code>$('#postcode_entry').val() </code></pre>
21,289,705
0
<p>You do not need the <code>'</code> surrounding the <code>?</code>'s.</p> <pre><code>PreparedStatement st = connection.prepareStatement("INSERT INTO Members VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?"); </code></pre> <p><code>BUT</code> the real problem here is you double single quoted one of the <code>?</code> to look like :<code>'?'',</code></p>
35,583,765
0
<p>You could possibly INNER JOIN the two result sets</p> <pre><code>select from test1 AS T1 INNER JOIN (select * from test1 where head_Id_Head = 5 and detail_Id_Detail = 4) AS T2 ON T2.company_Id_Company = T1.company_Id_Company where T1.head_Id_Head = 1 and T1.detail_Id_Detail = 7 </code></pre> <p>Or even simpler</p> <pre><code>select * from test1 where head_Id_Head = 1 and detail_Id_Detail = 7 AND company_Id_Company IN (select company_Id_Company from test1 where head_Id_Head = 5 and detail_Id_Detail = 4) </code></pre>
26,270,537
0
<p>Your id is null when you submit the form that's why you are getting this error.</p> <p>Either specify the the id parameter nullable as you have done in the get method or </p> <p>store the id in a hidden field to pass it automatically with the model like this</p> <pre><code>@HTML.HiddenFor(Model.id) </code></pre> <p>or pass it manually</p> <pre><code>@HTML.Hidden("id",id) </code></pre>
3,537,191
0
<p>Dependency Injection implies you get properly initialized references appearing "by magic".</p> <p>You call the setRequest() method with the request object, but DI frequently also allows for setting the fields without invoking methods.</p> <p>Guice does not as such require a container, but uses class loader magic started in the main method. Would that be useable for you?</p>
24,914,251
0
how can i detect if JS parameters have extra text? <p>If I have a function with parameters (or argument) like this:</p> <pre><code>check('red', 'blue', 'arial') </code></pre> <p>What i would like to know is can you have text like this:</p> <pre><code>check(background:'red', color:'blue', font:'arial') </code></pre> <p>In the function I have a if statement so if the parameter or argument has background: before it, it changes the background to the parameter after the background:</p> <pre><code> function check(one, two, three){ if (one==background:one){ document.body.style.background= one ; } } </code></pre> <p>I know this doesn't work, how would you do this or something like it?</p> <p>Can I use a if statement but code it to detect if a parameter has 'background:' before it? Is this possible or is there a better way of doing it? I would like to use pure JavaScript if that is possible.</p>
7,301,549
0
<p>The browser <em>sends</em> the value of radio buttons only when they are checked.</p> <p>Also, each radio button must have the same name (if you want to user to be able to check only one of them). Only the value changes:</p> <pre><code>print '&lt;input type=checkbox checked value="'.htmlspecialchars($element).'" name=checked_items /&gt;'; </code></pre> <p>POST this and check the value of <code>$_POST['checked_items']</code></p>
40,723,751
0
Why and I getting: "Invalid regular expression. Uncaught SyntaxError. Invalid escape."? <p>Im trying to create an html input tag that accepts only numbers entered in 1 of 2 formats, and reject all other input. </p> <p>I want to accept numbers in these formats only, including requiring the dashes:</p> <pre><code>1234-12 </code></pre> <p>and </p> <pre><code>1234-12-12 </code></pre> <p><strong>note:</strong> this is not for dates, but rather legal chapter numbers</p> <p>Everything I am reading about regex says that the following should work, but it isn't.</p> <pre><code>&lt;input class="form-control" type="text" pattern="^(\d{4}\-\d{2}\-\d{2})|(\d{4}\-\d{2})$" required /&gt; </code></pre> <p>Devtools Console Error in Chrome:</p> <blockquote> <p>Pattern attribute value <code>^(\d{4}\-\d{2}\-\d{2})|(\d{4}\-\d{2})$</code> is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^(\d{4}-\d{2}-\d{2})|(\d{4}-\d{2})$/: Invalid escape</p> </blockquote>
27,493,621
0
<p>You've reached the end of the file. You should be able to do this to go back to the beginning:</p> <pre><code>searchFile.seek(0) </code></pre>
35,250,889
1
Python uiautomator doesn't works on MacOS <p>I wanna use uiautomator on Python to test some android apps. </p> <p>When I run this single code:</p> <pre><code>from uiautomator import device as d d.screen.on() </code></pre> <p>that show me the error below:</p> <pre><code>Traceback (most recent call last): File "cerrar.py", line 8, in &lt;module&gt; d.screen.on() File "/usr/local/lib/python2.7/site-packages/uiautomator/__init__.py", line 813, in on return devive_self.wakeup() </code></pre> <p>...</p> <pre><code>"$ANDROID_HOME environment not set." </code></pre> <p>I already have done the environment variables with:</p> <pre><code>vi ~/.bash_profile export ANDROID_HOME=/Applications/android-sdk-macosx export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools source ~/.bash_profile </code></pre> <p>Both ways android-sdk installed by android website or brew install, was tried it.</p> <p>if I run: <code>echo $ANDROID_HOME</code> or <code>adb devices</code> or <code>android</code></p> <p>Does works well...</p> <p>I can't understand what's going on whether the environment variables exists.</p> <p>My equip is: MacBook Pro Yosemite OS</p>
10,918,758
0
<p>I assume this causes the problems in your code within the onItemSelected()-method:</p> <pre><code>player1.findViewById(R.id.editTextPlayer1); player2.findViewById(R.id.editTextPlayer2); //... </code></pre> <p>The method findViewById() returns a sub view of another view or of the main view of the activity. In your case the references seem to be Null pointers and you also do not handle the result, which would be the only reason to use the method.</p> <p>You should set these references only once in your onCreate()-method:</p> <pre><code>spinner = (Spinner)findViewById(R.id.spinnerplayers); //... player1 = (EditText)findViewById(R.id.editTextPlayer1); player2 = (EditText)findViewById(R.id.editTextPlayer2); //... </code></pre> <p>This way all your references are valid after onCreate() and you can access them securely in the onItemSelected() method (which I assume caused the NullPointerException)</p>
11,119,015
0
Rearrange table row in basis of class using javascript <p>For example, I have this code:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td class="last"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="last"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="another"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="another"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I want this to be set like this using javascript:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td class="another"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="another"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="last"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="last"&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Just what is needed is, javascript should detect td with class "last" and take whole table row to bottom of the table.</p>
27,707,260
0
<p>To create just the strings you need, you could also do:</p> <pre><code> x &lt;- rep(seq(2002, 2014, 1), 4) x &lt;- sort(x) y &lt;- rep(seq(1, 4, 1), 12) rows &lt;- paste(x, y, sep = ".") &gt; rows [1] "2002.1" "2002.2" "2002.3" "2002.4" "2003.1" "2003.2" "2003.3" "2003.4" [9] "2004.1" "2004.2" "2004.3" "2004.4" "2005.1" "2005.2" "2005.3" "2005.4" [17] "2006.1" "2006.2" "2006.3" "2006.4" "2007.1" "2007.2" "2007.3" "2007.4" [25] "2008.1" "2008.2" "2008.3" "2008.4" "2009.1" "2009.2" "2009.3" "2009.4" [33] "2010.1" "2010.2" "2010.3" "2010.4" "2011.1" "2011.2" "2011.3" "2011.4" [41] "2012.1" "2012.2" "2012.3" "2012.4" "2013.1" "2013.2" "2013.3" "2013.4" [49] "2014.1" "2014.2" "2014.3" "2014.4" </code></pre>
16,310,139
0
<pre><code>CREATE LOGIN [IIS APPPOOL\MyAppPool] FROM WINDOWS; CREATE USER MyAppPoolUser FOR LOGIN [IIS APPPOOL\MyAppPool]; </code></pre>
24,392,234
0
Memory leak when manually compiling directives in Angular <p>I'm trying to manually compile a directive and add it to the DOM via JQuery. The directive is a simple div with an ngClick handler. No JQuery plugins are used in the directive itself (which seems to be the focus of many of the other memory leak threads).</p> <p>If you run a profiler you will find that it leaks nodes. Is there something that can be done to fix this or is it a problem in JQuery/Angular?</p> <p><a href="http://jsfiddle.net/wsgKL/1/" rel="nofollow">Fiddle here</a><br> <a href="http://postimg.org/image/8rx18ln7n/" rel="nofollow">Profiler screenshot</a></p> <p>HTML</p> <pre><code>&lt;div ng-app="TestApp"&gt; &lt;buttons&gt;&lt;/buttons&gt; &lt;div id="container"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Javascript</p> <pre><code>var ButtonsCtrl = function($scope, $compile) { this.scope = $scope; this.compile = $compile; }; ButtonsCtrl.prototype.toggle = function() { var c = angular.element('#container').children(); if (0 in c &amp;&amp; c[0]) { c.scope().$destroy(); c.remove(); } else { var s = this.scope.$new(); this.compile('&lt;thing color="blue"&gt;&lt;/thing&gt;')(s).appendTo('#container'); } }; var ThingCtrl = function($scope) {}; ThingCtrl.prototype.clicky = function() { alert('test'); }; var module = angular.module('components', []); module.directive('buttons', function() { return { restrict: 'E', template: '&lt;button ng-click="ctrl.toggle()"&gt;toggle&lt;/button&gt;', controller: ButtonsCtrl, controllerAs: 'ctrl' } }); module.directive('thing', function() { return { restrict: 'E', scope: { color: '@' }, template: '&lt;div style="width:50px;height:50px;background:{{color}};" ng-click="ctrl.clicky()"&gt;&lt;/div&gt;', controller: ThingCtrl, controllerAs: 'ctrl' }; }); angular.module('TestApp', ['components']); </code></pre>
34,991,354
0
<p>Django's <a href="https://docs.djangoproject.com/en/1.9/topics/auth/default/#django.contrib.auth.authenticate" rel="nofollow"><code>authenticate</code></a> method checks against a <code>username</code>, not an email.</p> <blockquote> <p>It takes credentials in the form of keyword arguments, for the default configuration this is <strong>username</strong> and password.</p> </blockquote> <p>The simple solution to this is, when defining a user, set their username to the same as the email.</p>
16,740,797
0
<p>In case (a), What do you expect to happen if the pattern occurs within the 10 lines?</p> <p>Anyway, here are some awk scripts which should work (untested, though; I don't have Solaris):</p> <pre><code># pattern plus 10 lines awk 'n{--n;print}/PATTERN/{if(n==0)print;n=10}' # between two patterns awk '/PATTERN1/,/PATTERN2/{print}' </code></pre> <p>The second one can also be done similarly with <code>sed</code></p>
40,997,469
0
<p>Check again into your <code>package.json</code> file their is available <code>node-gyp</code> module or not with version ID if there is not available then add and again install from <code>npm</code>.</p>
38,342,349
0
<p>Have you looked into the Comparable interface? You will need to wrap the Map&lt;String,String> inside a new class that has a comparable() method in order to make it sortable. More info here: <a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_comparable.htm" rel="nofollow">https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_comparable.htm</a></p> <pre><code>public class MapWrapper implements Comparable { public Map&lt;String,String&gt; record; public MapWrapper(Map&lt;String,String&gt; record) { this.record = record; } public Integer compareTo(Object compareTo) { MapWrapper compareToMap = (MapWrapper)compareTo; if (record.get('Savings') == compareToMap.record.get('Savings')) return 0; if (record.get('Savings') &gt; compareToMap.record.get('Savings')) return 1; return -1; } } </code></pre> <p>Your list will contain MapWrapper objects instead of Map&lt;String,String>. You can then sort it using List.sort():</p> <pre><code>List&lt;MapWrapper&gt; myList = new MapWrapper[]{}; myList.add(new MapWrapper(new Map&lt;String,String&gt;{'Name'=&gt;'John','Savings'=&gt;'300'})); myList.add(new MapWrapper(new Map&lt;String,String&gt;{'Name'=&gt;'David','Savings'=&gt;'100'})); System.debug(myList); //Unsorted myList.sort(); System.debug(myList); //Sorted </code></pre> <p>If you need to keep your structure as a <code>List&lt;Map&lt;String,String&gt;&gt;</code> without the wrapper, you can still do it but you will need to implement the sort algorithm yourself. The easiest way to do it is using bubble sort. </p>
9,205,542
0
<p>After you initialize the PDO object try setting the <a href="http://php.net/manual/en/pdo.setattribute.php" rel="nofollow">error mode</a> higher.</p> <p><code>$db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);</code></p> <p>The default is <code>PDO::ERRMODE_SILENT</code> which will output no warnings/errors. With this default setting, you have to poll <a href="http://www.php.net/manual/en/pdo.errorinfo.php" rel="nofollow"><code>errorInfo()</code></a> to see error details.</p>
27,286,288
0
UINavigationBar barButtonItem change back button image and title <p>Is it possible to change the back button on a UINavigationBar and change the title?</p> <p>When I try to set the customView property, I get an image right next to the default button.</p> <p>I use this code</p> <pre><code>self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithImage:backButtonImage landscapeImagePhone:nil style:UIBarButtonItemStylePlain target:nil action:nil]; </code></pre> <p>I want the title to be "Back" which is easy enough to do in Storyboard. But the problem is that no matter if I use code above or use customView property, the default back button remains. </p>
3,528,311
0
Simple Transactions <p>I have 2 linq 2 SQL statements I'd like to be in a transaction (the SQL server is remote, outside firewalls etc) all other communication works but when I wrap these 2 statements in a TransactionScope() I begin having to configure MSDTC which we did, but then there are firewall issues (I think) is there a simpler way?</p> <p>the basics of what I want to do boil down to this: (both are stored procs under the hood)</p> <pre><code>using (var transactionScope = new TransactionScope()) { Repository.DataContext.SubmitChanges(); Repository.DataContext.spDoFinalStuff(tempID, ref finalId); transactionScope.Complete(); } </code></pre> <p>What is the simplest way to achieve this?</p> <p><strong>EDIT:</strong><br> first I got this: The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024) On our servers I followed the instructions <a href="http://stackoverflow.com/questions/320986/transactionscope-error-against-sql-server-2000-the-partner-transaction-manager/321090#321090">here</a> to correct this. However the instructions don't seem to apply to windows 7 (my dev box) see my comment on above answer.</p> <p>after correcting the issue (on the non win7 boxes) I get this: The transaction has already been implicitly or explicitly committed or aborted (Exception from HRESULT: 0x8004D00E) which some googling <a href="http://andrewmyhre.wordpress.com/2008/02/14/how-to-fix-transactionscope-already-been-implicitly-or-explicitly-committed-or-aborted-error/" rel="nofollow noreferrer">suggested</a> may be firewall issue.</p> <p><strong>EDIT</strong><br> I just discovered the remote DB is SQL 2000 </p>
15,670,439
0
<p>I think,better option is <strong>Universal App</strong>.</p> <blockquote> <p>The app is large and contains a lot of images. The main drawback of a universal app is that I'm capped at 50MB over-air download, and that the single binary means iPhones get all the iPad images and vice versa.</p> </blockquote> <p>Yes. This is the only difficulty that I measured. However you can clearly specify which images should be load in iPad and which should only load in iPhone by naming it separately. </p> <p>If Im correct , you can use some thing like <code>myImage~iPhone.png or myImage~iPad.png</code></p>
30,518,201
0
No space between tabpanel and a form element <p>I have a tabPanel where I put a form. There is no space between the tabPanel and the first element of the form. Is there a class in tbs to fix that?</p> <pre><code>&lt;div class="row"&gt; &lt;div class="span12"&gt; &lt;ul class="nav nav-tabs" role="tablist"&gt; &lt;li role="presentation"&gt;&lt;a href="#information" data-toggle="tab"&gt;Information&lt;/a&gt;&lt;/li&gt; &lt;li role="presentation" class="active"&gt;&lt;a href="#contactReference" data-toggle="tab"&gt;Référence&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id='content' class="tab-content"&gt; &lt;div role="tabpanel" class="tab-pane" id="information"&gt; &lt;div class="row"&gt; &lt;div class="span12"&gt; &lt;form class="form-horizontal" role="form"&gt; &lt;div class="form-group"&gt; &lt;label for="lastName" class="col-sm-2 control-label"&gt;Nom&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="text" class="form-control" id="lastName" placeholder="Entrer le nom" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></p> <p><a href="https://jsfiddle.net/DTcHh/8262/" rel="nofollow">demo</a></p>
23,020,697
0
<p>From the Flask <code>Request</code> class documentation:</p> <blockquote> <p><strong>json</strong></p> <p>If the mimetype is application/json this will contain the parsed JSON data. Otherwise this will be None.</p> <p>The get_json() method should be used instead.</p> </blockquote> <p>I think your problem appears because request.form doesn't contain <code>hosts</code> key (contains something else), because your mimetype is not json (application/json).</p> <p>For a more precise answer please write what comes in <code>request.form</code>?</p>
32,275,703
0
<p>Personally I would have a count that tracks the current 'click' that the user is on, like so:</p> <pre><code>protected void btnPrevious_Click1(object sender, EventArgs e) { if(stepCount == 0) //Ensuring that we never get into minus numbers stepCount = 0; stepCount--; DAL.TicketsDataSetTableAdapters.TicketDetailsTableAdapter eobj = new DAL.TicketsDataSetTableAdapters.TicketDetailsTableAdapter(); DataTable dt = new DataTable(); dt = eobj.GetTicketUpdates(txtSupportRef.Text); txtNextStep.Text = eobj.GetTicketData(txtSupportRef.Text).Rows[0][stepCount].ToString(); } protected void btnNext_Click1(object sender, EventArgs e) { if(stepCount == 0) //Ensuring that we never get into minus numbers stepCount = 0; stepCount++; DAL.TicketsDataSetTableAdapters.TicketDetailsTableAdapter eobj = new DAL.TicketsDataSetTableAdapters.TicketDetailsTableAdapter(); DataTable dt = new DataTable(); dt = eobj.GetTicketUpdates(txtSupportRef.Text); txtNextStep.Text = eobj.GetTicketData(txtSupportRef.Text).Rows[0][stepCount].ToString(); } </code></pre> <p>You could also add a check in the next button click to check if the user is currently on the <strong>last record</strong> and if they are, send them to the start of the records list again.</p>
6,634,493
0
Can I save flash game and play it without being connected to the Internet? <p>Not sure if this question belongs on SO but ...</p> <p>Can I play <a href="http://www.flashtowerdefence.com/flash/145/Desktop_Tower_Defense_1_9.html" rel="nofollow">Desktop Tower Defense</a> without being connected to the Internet?</p> <p>I can load the page and then disconnect from the net but my question is if I can download the game and play any time without connecting to the net.</p>
28,623,723
0
<p>If you just want to reverse string, then use:</p> <pre><code>DECLARE @string VARCHAR(10) = 'mystring' SELECT REVERSE(@string) </code></pre>
28,869,430
0
<p>Here's my solution:</p> <pre><code>var items = [ { id: 1, name: 'bill' }, { id: 2, name: 'sam' }, { id: 3, name: 'mary' }, { id: 4, name: 'jane' } ]; var order = [ { id: 1, sortindex: 4 }, { id: 2, sortindex: 2 }, { id: 3, sortindex: 1 }, { id: 4, sortindex: 3 } ]; _(items) .indexBy('id') .at(_.pluck(_.sortBy(order, 'sortindex'), 'id')) .pluck('name') .value(); // → [ 'mary', 'sam', 'jane', 'bill' ] </code></pre> <p>Here's what's going on:</p> <ul> <li>The <a href="https://lodash.com/docs#indexBy" rel="nofollow">indexBy()</a> function transforms <code>items</code> into an object, where the <code>id</code> values are the keys.</li> <li>The <a href="https://lodash.com/docs#at" rel="nofollow">at()</a> function gets values from the object, <strong>in order</strong>, of the passed in keys.</li> <li>The <a href="https://lodash.com/docs#sortBy" rel="nofollow">sortBy()</a> function sorts <code>order</code> by the <code>sortindex</code> key.</li> <li>The <a href="https://lodash.com/docs#pluck" rel="nofollow">pluck()</a> function gets the sorted <code>id</code> array.</li> </ul>
35,066,320
0
What is groupId and artifactId of jar built by Intellij Idea? <p>I built <code>jar</code> of project in <code>Intellij Idea</code>(<code>Build</code>-<code>Build Artifact</code>), and I'm trying to add it to another project that uses <code>Maven</code>. I have to add it to <code>pom.xml</code>, but I need to know groupId, artifactId and version of my <code>jar</code>.</p>
32,377,786
0
<p>If you're gathering facts, you can access hostvars via the normal jinja2 + variable lookup:</p> <p>e.g. </p> <pre><code>- hosts: serverA.example.org gather_facts: True ... tasks: - set_fact: taco_tuesday: False </code></pre> <p>and then, if this has run, on another host:</p> <pre><code>- hosts: serverB.example.org ... tasks: - debug: var="{{ hostvars['serverA.example.org']['ansible_memtotal_mb'] }}" - debug: var="{{ hostvars['serverA.example.org']['taco_tuesday'] }}" </code></pre> <p>Keep in mind that if you have multiple Ansible control machines (where you call <code>ansible</code> and <code>ansible-playbook</code> from), you should take advantage of the fact that Ansible can store its <a href="http://docs.ansible.com/ansible/playbooks_variables.html#fact-caching" rel="nofollow">facts/variables in a cache</a> (currently Redis and json), that way the control machines are less likely to have different hostvars. With this, you could set your control machines to use a file in a shared folder (which has its risks -- what if two control machines are running on the same host at the same time?), or set/get facts from a Redis server.</p> <p>For my uses of Amazon data, I prefer to just fetch the resource each time using a tag/metadata lookup. I wrote an <a href="https://github.com/tfishersp/aws_tag" rel="nofollow">Ansible plugin</a> that allows me to do this a little more easily as I prefer this to thinking about hostvars and run ordering (but your mileage may vary).</p>
35,820,286
0
<p>I think the issue is about images color profiling which can lead to different rendering on different browsers.</p> <p>You can read more about it here: <a href="https://css-tricks.com/color-rendering-difference-firefox-vs-safari/" rel="nofollow">https://css-tricks.com/color-rendering-difference-firefox-vs-safari/</a></p> <p><strong>EDIT:</strong></p> <p>Your img has a <em>RGB</em> profile. So I converted it to <em>sRGB</em> which is the recommended color profile for the web.</p> <p>OUTPUT:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.bg{ background:#DE9964; width:332px; height:91px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;img src="http://i68.tinypic.com/29bld6r.png"&gt; &lt;div class="bg"&gt;&lt;/div&gt;</code></pre> </div> </div> </p> <p>Now it should look the same both on Chrome and Safari. </p> <p>Tested on Mac OS X - Chrome 48.0 and Safari 9.0.3</p>
34,935,044
0
<p>Your solution will almost definitely end up involving <code>ssh</code> in some capacity.</p> <p>You may want something to help manage the execution of commands on multiple servers; <a href="http://www.ansible.com/" rel="nofollow">ansible</a> is a great choice for something like this.</p> <p>For example, if I want to install <code>libvirt</code> on a bunch of servers and make sure <code>libvirtd</code> is running, I might pass a configuration like this to <code>ansible-playbook</code>:</p> <pre><code>- hosts: all tasks: - yum: name: libvirt state: installed - service: name: libvirtd state: running enabled: true </code></pre> <p>This would ssh to all of the servers in my "inventory" (a file -- or command -- that provides ansible with a list of servers), install the <code>libvirt</code> package, start <code>libvirtd</code>, and then arrange for the service to start automatically at boot.</p> <p>Alternatively, if I want to run <code>puppet apply</code> on a bunch of servers, I could just use the <code>ansible</code> command to run an ad-hoc command without requiring a configuration file:</p> <pre><code>ansible all -m command -a 'puppet apply' </code></pre>
25,741,535
0
<p>Single product is displayed from wp-content\plugins\woocommerce\templates\single-product.php </p> <p>This file (wp-content\plugins\woocommerce\templates\content-single-product.php) is called from single-product.php for adding content and add-to-cart button on single product page. </p>
34,795,069
0
<p>This is <strong>placement new</strong> syntax. It constructs an object of type <code>FBatchedLine</code> at the memory pointed to by <code>BatchedLines</code> with the constructor arguments <code>(Start, End, Color, LifeTime, Thickness, DepthPriority)</code>. After the call, <code>BatchedLines</code> can be used to reference the constructed object.</p> <p>Informally, you could imagine invoking the constructor with <code>BatchedLines</code> being <code>this</code>.</p>
2,248,138
0
How to expose xaml properties? <p>I created a ComboBox subclass and added my functionality.</p> <p>Now I want to expose external properties of the TextBox for example:</p> <pre><code>&lt;a:MyComboBox SpellCheck.IsEnabled="True" TextBox.SelectedText="{Binding X}" /&gt; </code></pre> <p>Is this possible, I maybe didn't choose the wrong particular property but I guess you understand what I mean.</p> <p>Is this possible?<br> Do I have to create all the properties individually?</p>
3,261,708
0
Vim (MacVim) backword key problem under insert mode <p>Look, this is driving me crazy. Under insert mode, when I select a word with mouse (vim shows: --insert(visual)..), and when I press backword key, the cursor would always delete the selected word AND move to one extra word backword. e.g. "a fox jumps". When I tried to delete jumps, after pressing the BS key, vim would delete 'jumps' AS WELL AS the cursor moves to the starting position of 'fox'.</p> <p>What is going on? How to solve this?</p>
11,157,108
1
OpenCL delete data from RAM <p>I'm coping data in python using OpenCL onto my graphic card. There I've a kernel processing the data with n threads. After this step I copy the result back to python and in a new kernel. (The data is very big 900MB and the result is 100MB) With the result I need to calculate triangles which are about 200MB. All data exceed the memory on my graphic card. </p> <p>I do not need the the first 900MB anymore after the first kernel finished it's work.</p> <p>My question is, how can I delete the first dataset (stored in one array) from the graphic card?</p> <p>Here some code:</p> <pre><code>#Write self.gridBuf = cl.Buffer(self.context, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=self.grid) #DO PART 1 ... #Read result cl.enqueue_read_buffer(self.queue, self.indexBuf,index).wait() </code></pre>
4,203,615
0
<p>While this is hardly an easy solution to implement quickly, I find that running Netbeans 6.9 on a multi-core processor works. While it might ramp up on one core, the other (3 in my case) are still free for other tasks. Given that you're on a Mac, YMMV. </p> <p>Of course, it would be better to avoid the CPU hog in the first place, but if you can't find the source, but still love the IDE (as I do)...</p>
6,893,005
0
<p>Think outside the box. Which application of the ones you use regularly does this? A debugger of course! But, how can you achieve such a behavior, to emulate a low cpu?</p> <p>The secret to your question is <code>asm _int 3</code>. This is the assembly "pause me" command that is send from the attached debugger to the application you are debugging.</p> <p>More about int 3 to this <a href="http://stackoverflow.com/questions/3747852/int-3-0xcc-x86-asm">question</a>.</p> <p>You can use the code from <a href="http://www.codeproject.com/KB/threads/pausep.aspx" rel="nofollow">this</a> tool to pause/resume your process continuously. You can add an interval and make that tool pause your application for that amount of time.</p> <p>The emulated-cpu-speed would be: (YourCPU/Interval) -0.00001% because of the signaling and other processes running on your machine, but it should do the trick.</p> <p>About the low memory emulation: You can create a wrapper class that allocates memory for the application and replace each allocation with call to this class. You would be able to set exactly the amount of memory your application can use before it fails to allocate more memory.</p> <p>Something such as: <code>MyClass* foo = AllocWrapper(new MyClass(arguments or whatever));</code> Then you can have the AllocWrapper allocating/deallocating memory for you.</p>
2,286,013
0
<pre><code>$('#myElement').is(':visible'); </code></pre> <p>Will return <code>true</code> or <code>false</code></p>
18,686,413
0
Get data from Cursor: null pointer exception <p>I've this two classes:</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DatabaseHelper helper = new DatabaseHelper(this); String[] temp = new String[] { "40", "35", "28" }; String[] hum = new String[] { "50%", "30%", "80%" }; for (int i = 0; i &lt; temp.length; i++) { helper.insertRecord(temp[i], hum[i]); } Cursor c = helper.getData(); String res = ""; if(c.moveToFirst()) { while(!c.isAfterLast()) { res+=c.getString(0)+" "+c.getString(1)+"\n"; c.moveToNext(); } c.close(); } TextView tv = (TextView) findViewById(R.id.tv); tv.setText(res); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } public class DatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "database_name"; private static final String TABLE_NAME = "my_table"; private static final String COL_TEMPERATURA = "temperatura"; private static final String COL_UMIDITA = "umidita"; public DatabaseHelper(Context context) { super(context, DB_NAME, null, 33); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME); db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + COL_TEMPERATURA + " TEXT, " + COL_UMIDITA + " TEXT)"); } @Override public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) { // TODO Auto-generated method stub } public void insertRecord(String temperatura, String umidita) { SQLiteDatabase db = this.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(COL_TEMPERATURA, temperatura); cv.put(COL_UMIDITA, umidita); db.insert(TABLE_NAME, null, cv); db.close(); } public Cursor getData() { SQLiteDatabase db = this.getReadableDatabase(); String[] cols = new String[]{COL_TEMPERATURA, COL_UMIDITA}; Cursor res = db.query(TABLE_NAME, cols, null, null, null, null, null); return res; } } </code></pre> <p>but whew i execute my code, i have a nullpointer exception on MainActivity when i call tv.setText(res);</p> <p>why?</p> <p>Log:</p> <pre><code>09-08 19:25:16.249: E/AndroidRuntime(5911): FATAL EXCEPTION: main 09-08 19:25:16.249: E/AndroidRuntime(5911): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.database/com.example.database.MainActivity}: java.lang.NullPointerException 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.ActivityThread.access$600(ActivityThread.java:141) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.os.Handler.dispatchMessage(Handler.java:99) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.os.Looper.loop(Looper.java:137) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.ActivityThread.main(ActivityThread.java:5103) 09-08 19:25:16.249: E/AndroidRuntime(5911): at java.lang.reflect.Method.invokeNative(Native Method) 09-08 19:25:16.249: E/AndroidRuntime(5911): at java.lang.reflect.Method.invoke(Method.java:525) 09-08 19:25:16.249: E/AndroidRuntime(5911): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 09-08 19:25:16.249: E/AndroidRuntime(5911): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 09-08 19:25:16.249: E/AndroidRuntime(5911): at dalvik.system.NativeStart.main(Native Method) 09-08 19:25:16.249: E/AndroidRuntime(5911): Caused by: java.lang.NullPointerException 09-08 19:25:16.249: E/AndroidRuntime(5911): at com.example.database.MainActivity.onCreate(MainActivity.java:31) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.Activity.performCreate(Activity.java:5133) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 09-08 19:25:16.249: E/AndroidRuntime(5911): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 09-08 19:25:16.249: E/AndroidRuntime(5911): ... 11 more </code></pre>
16,591,239
0
Is this the true difference between using PhoneGap and simply opening a WebView in my application? <p>I was lately assigned to create a PhoneGap application for 4 different mobile platforms. After playing around with PhoneGap for a while , i decided it wasnt good to serve my purposes as there were no push-notification plugins for the WP7 and BB platforms.</p> <p>So i went native. I wrote native code for the different platforms that simply does 2 things:</p> <p><strong>1)</strong> <em>implement push notifications</em></p> <p><strong>2)</strong> <em>open an in-app webView</em></p> <p>My plan was that now with the webView i can open my "html-javascript web page" that i would use with the phonegap framework and it would be the same thing..</p> <p><strong>However...</strong> lately i found out that some javascript wont run in the BB (some older versions of OS) . So now i think i understand whats the difference between using PhoneGap and by simple opening a WebView.</p> <p><strong>IF</strong> i was using PhoneGap , the html-javascript code that i would write , would be <em>translated</em> through the framework to <em>native</em> code so it would run in the mobile. Now that i try to run javascript through the Web Browser , it simply wont run if the device doesnt support it.</p> <p>Am i right here? Is this the final big difference between these 2 things?</p>
30,253,046
0
<p>There are a few opportunities for speedup, but my first concern is <em>vector</em>. Where is it initialized? In the code posted, it gets n^2 entries and sorted n times! That seems unintentional. Should it be cleared? Should final be outside the loop?</p> <p>final=sorted(vector, key=lambda vector: vector[2],reverse = True)</p> <p>is functional, but has ugly scoping, better is:</p> <p>final=sorted(vector, key=lambda entry: entry[2], reverse=True)</p> <p>In general, to solve timing issues consider using a <a href="https://docs.python.org/2/library/profile.html" rel="nofollow">profiler</a>. </p>
37,939,273
0
<p>According to the <a href="http://www-12.lotus.com/ldd/doc/lotusscript/lotusscript.nsf/1efb1287fc7c27388525642e0074f2b6/3c567087099f80948525642e0075cddc?OpenDocument" rel="nofollow">Lotus Note documentation</a>, <code>GetItemValue()</code> returns either a String, an array of String, or an array of Doubles, none of them having a <code>HasEmbedded</code> property.</p>
11,900,001
0
Default parameter template vs variadic template : what is the last template parameter? <p>I'm a little confused because both a default parameter template and a variadic template parameter have to be the last parameter of a template. So what is the good official syntax for my function ?</p> <pre><code>template&lt;typename T, class T2 = double, unsigned int... TDIM&gt; myFunction(/* SOMETHING */) </code></pre> <p>or</p> <pre><code>template&lt;typename T, unsigned int... TDIM, class T2 = double&gt; myFunction(/* SOMETHING */) </code></pre>
4,531,499
0
<p>Might want to tell "left" what measure your statement is in (px, %, etc)</p>
17,884,176
0
Apache: Could not initialize random number generator <p>I'm really frustrated, my apache server doesn't start, my error.log is this:</p> <pre><code>[Fri Jul 26 16:26:20.211050 2013] [core:notice] [pid 32240:tid 268] AH00094: Command line: 'c:\\users\\mrvisiont\\desktop\\xampp\\apache\\bin\\httpd.exe -d C:/Users/MrViSiOnT/Desktop/xampp/apache' [Fri Jul 26 16:26:20.213050 2013] [mpm_winnt:notice] [pid 32240:tid 268] AH00418: Parent: Created child process 32112 [Fri Jul 26 16:26:20.225050 2013] [:crit] [pid 32112] (-2146173818)Unknown error: AH00141: Could not initialize random number generator [Fri Jul 26 16:26:20.227051 2013] [mpm_winnt:crit] [pid 32240:tid 268] AH00419: master_main: create child process failed. Exiting. </code></pre> <p>I don't know what is the meaning of "Could not initialize random number generator"</p> <p>Anybody knows what is the issue????</p> <p>EDIT:</p> <p>When I run httpd.exe, error.log is:</p> <pre><code> [Fri Jul 26 16:52:31 2013] [notice] Digest: generating secret for digest authentication ... [Fri Jul 26 16:52:31 2013] [notice] Digest: done [Fri Jul 26 16:52:31 2013] [notice] Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 configured -- resuming normal operations [Fri Jul 26 16:52:31 2013] [notice] Server built: Sep 10 2011 11:34:11 [Fri Jul 26 16:52:31 2013] [notice] Parent: Created child process 16760 no listening sockets available, shutting down Unable to open logs [Fri Jul 26 16:52:31 2013] [crit] (OS 87)El parámetro no es correcto. : master_main: create child process failed. Exiting. </code></pre> <p>EDIT (FYI): Thank you people! When I comment ServerName line from httpd.conf... error.log is:</p> <pre><code> httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::8e3:cc40:2151:c412 for ServerName [Fri Jul 26 17:03:11 2013] [notice] Digest: generating secret for digest authentication ... [Fri Jul 26 17:03:11 2013] [notice] Digest: done [Fri Jul 26 17:03:12 2013] [notice] Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 configured -- resuming normal operations [Fri Jul 26 17:03:12 2013] [notice] Server built: Sep 10 2011 11:34:11 [Fri Jul 26 17:03:12 2013] [notice] Parent: Created child process 13816 httpd.exe: apr_sockaddr_info_get() failed for MRVISIONT-PC httpd.exe: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName no listening sockets available, shutting down Unable to open logs [Fri Jul 26 17:03:12 2013] [crit] (OS 6)Controlador no válido. : master_main: create child process failed. Exiting. </code></pre>
28,853,600
0
<p>You can do this without regex using <code>awk</code> (on this simple example):</p> <pre><code>awk -F":|/" '{print $2}' file 192.1.1.128 192.1.1.11 </code></pre> <hr> <p>To test if its IP contains three <code>.</code>:</p> <pre><code>awk -F":|/" '{n=split($2,a,".");if (n=4) print $2}' file 192.1.1.128 192.1.1.11 </code></pre>