pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
38,028,012
0
<p>If you assign <code>this</code> reference to a member variable, you have a recursion. Yes, it doesn't matter how many <code>s</code>'s you'll add, because they are always the same object, which is <code>this</code> object. It's the same as if you wrote:</p> <pre><code>this.this.this.this.this.this.x++; </code></pre> <p>Function <code>f()</code> returns reference to <code>this</code> object after doing some other operations on it. It's a common design pattern in Java, called <a href="http://www.tutorialspoint.com/design_pattern/builder_pattern.htm" rel="nofollow">builder</a>. Adding ability to do <code>a4.f().g();</code> to a class is called <a href="http://stackoverflow.com/a/21180314/5922757">method chaining</a>. In other words, <code>f()</code> is <code>this</code> object at the end of the call, just like <code>s</code> is, so you can do:</p> <pre><code>a1.f().f().f().f().f().f(); </code></pre> <p>And it means you just called <code>f()</code> function from <code>a1</code> object 6 times.</p>
338,945
0
What are some reasons I might be receiving this "Symbol not defined" error in Visual Studio 2005 (screenshot included) <p>When debugging my VS2005 project, I get the following error when I attempt to step into the function that returns the <em>vScenarioDescriptions</em> local variable it's struggling with...</p> <p><em><img src="http://people.ict.usc.edu/~crotchett/images/symbolnotdefined.JPG" alt="image no longer available"></em></p> <p>As I continue to walk through the code and step into functions, it appears I'm getting this error other local variables as well. Any ideas?</p> <p>Thanks in advance for your help!</p>
22,225,908
0
<p>You're getting an exception from the DirectoryInfo object, so you need to use try / catch:</p> <pre><code>function Get-HugeDirStats ($directory) { function go($dir, $stats) { try { foreach ($f in $dir.GetFiles()) { $stats.Count++ $stats.Size += $f.Length } foreach ($d in $dir.GetDirectories()) { go $d $stats } } catch [Exception] { # Do something here if you need to } } $statistics = New-Object PsObject -Property @{Count = 0; Size = [long]0 } go (new-object IO.DirectoryInfo $directory) $statistics $statistics } </code></pre> <p>If you're getting errors from any powershell cmdlets, you can use <code>-ErrorAction SilentlyContinue</code> on the cmdlet to prevent errors printing to the screen.</p>
21,868,051
0
Laravel 4 - ErrorException Undefined variable <p>Trying to bind model to the form to call update function, but model is not found. </p> <pre><code>{{ Form::model($upload, array('url' =&gt; array('uploads/update', $upload-&gt;id), 'files' =&gt; true, 'method' =&gt; 'PATCH')) }} </code></pre> <p>Controller to get edit view </p> <pre><code>public function getEdit($id) { $upload = $this-&gt;upload-&gt;find($id); if (is_null($upload)) { return Redirect::to('uploads/alluploads'); } $this-&gt;layout-&gt;content = View::make('uploads.edit', compact('uploads')); } </code></pre> <p>Controller to do the update</p> <pre><code>public function patchUpdate($id) { $input = array_except(Input::all(), '_method'); $v = Validator::make($input, Upload::$rules); if ($v-&gt;passes()) { $upload = $this-&gt;upload-&gt;find($id); $upload-&gt;update($input); return Redirect::to('uploads/show', $id); } return Redirect::to('uploads/edit', $id) -&gt;withInput() -&gt;withErrors($v) } </code></pre> <p>error i get </p> <pre><code>ErrorException Undefined variable: upload (View: /www/authtest/app/views/uploads/edit.blade.php) </code></pre>
9,247,315
0
<p>Your best bet is probably <a href="http://www.sqlite.org/" rel="nofollow">SQLite</a>, a database engine. From Apple's <a href="https://developer.apple.com/technologies/ios/data-management.html" rel="nofollow">iOS Data Management</a> page:</p> <blockquote> <p>iOS includes the popular SQLite library, a lightweight yet powerful relational database engine that is easily embedded into an application. Used in countless applications across many platforms, SQLite is considered a de facto industry standard for lightweight embedded SQL database programming. Unlike the object-oriented Core Data framework, SQLite uses a procedural, SQL-focused API to manipulate the data tables directly.</p> </blockquote>
39,179,728
0
<p><code>uib-accordion-group</code> provides you with a parameter <code>is-open</code>. You can just feed in a truthy value for newly created elements and they will be automatically opened.</p> <p>See the documentation for reference: <a href="https://angular-ui.github.io/bootstrap/#/accordion" rel="nofollow">https://angular-ui.github.io/bootstrap/#/accordion</a></p>
29,850,405
0
<p>There is the <code>bool</code> function in <code>Data.Bool</code>:</p> <pre><code>import Data.Bool bool b a (x == y) </code></pre>
2,686,454
0
How to rollback in EF4 for Unit Test TearDown? <p>In my research about rolling back transactions in EF4, it seems everybody refers to <a href="http://blogs.msdn.com/alexj/archive/2009/01/11/savechanges-false.aspx" rel="nofollow noreferrer">this blog post</a> or offers a similar explanation. In my scenario, I'm wanting to do this in a unit testing scenario where I want to rollback practically everything I do within my unit testing context to keep from updating the data in the database (yeah, we'll increment counters but that's okay). In order to do this, is it best to follow the following plan? Am I missing some concept or anything else major with this (aside from my <code>SetupMyTest</code> and <code>PerformMyTest</code> functions won't really exist that way)?</p> <pre><code>[TestMethod] public void Foo { using (var ts = new TransactionScope()) { // Arrange SetupMyTest(context); // Act PerformMyTest(context); var numberOfChanges = context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave); // if there's an issue, chances are that an exception has been thrown by now. // Assert Assert.IsTrue(numberOfChanges &gt; 0, "Failed to _____"); // transaction will rollback because we do not ever call Complete on it } } </code></pre>
15,739,734
0
<p>You can use javascript's <code>substr()</code> and <code>.lastIndexOf()</code>:</p> <pre><code>var url = '/Home/LoadData?page=2&amp;activeTab=House'; // window.location.href; var activeTab = url.substr(url.lastIndexOf('=')+1); // outputs House </code></pre> <h3><a href="http://jsfiddle.net/gjkrZ/" rel="nofollow">Find in FIDDLE</a></h3>
18,971,283
0
breeze js apostraphe causing query to fail <p>I'm using the breeze-mongo node module and when performing a query for an entity name which has an apostrophe the server is throwing an exception.</p> <p>Query example:</p> <pre><code>EntityQuery.from('People') .where('name', '==', "brian's") </code></pre> <blockquote> <p>Error: Unable to parse filterExpr: name eq 'brian's' at parse (/node/api/node_modules/breeze-mongodb/mongoQuery.js:108:19) at MongoQuery._parseUrl (/node/api/node_modules/breeze-mongodb/mongoQuery.js:29:26) at new MongoQuery (/node/api/node_modules/breeze-mongodb/mongoQuery.js:21:10) at getVideos (/node/api/api.js:102:19) at callbacks (/node/api/node_modules/express/lib/router/index.js:161:37) at param (/node/api/node_modules/express/lib/router/index.js:135:11) at pass (/node/api/node_modules/express/lib/router/index.js:142:5) at Router._dispatch (/node/api/node_modules/express/lib/router/index.js:170:5) at Object.router (/node/api/node_modules/express/lib/router/index.js:33:10) at next (/node/api/node_modules/express/node_modules/connect/lib/proto.js:190:15)</p> </blockquote> <p>Are apostrophes not supported?</p>
17,752,918
0
<p>Here is an example of how to delete a solr index with curl:</p> <p><a href="https://gist.github.com/nz/673027" rel="nofollow">https://gist.github.com/nz/673027</a></p> <p>For windows, check this out:</p> <p><a href="http://stackoverflow.com/questions/17106996/how-to-post-xml-data-with-curl-using-cmd-in-windows-7">How to post XML data with cURL using cmd in windows 7?</a></p>
40,363,669
0
Contextual type 'AnyObject' cannot be used with dictionary literal multi level dictionary <p>I'm running into an issue with creating a multi-level dictionary in Swift and have followed some of the suggestions presented here:</p> <pre><code>var userDict:[String:AnyObject]? = ["SystemId": "TestCompany", "UserDetails" : ["firstName": userDetail.name, "userAddress" : "addressLine1" userDetail.userAdd1]] </code></pre> <p>The use of <code>[String:AnyObject]?</code> works for the first level of the Dict, but Swift is throwing the same error at the next level Dict, <code>UserDetail[]</code>. Any suggestions would be greatly appreciated</p>
36,032,002
0
Crystal Report not supporting to style attribute of Paragraph tag <p>Crystal Report is not supporting the style attribute of the paragraph tag. Why this is happening? Just freaked out with this problem since yesterday. Here is my HTML code which is I am putting on the Crystal Report:</p> <pre><code>paragraph tag"&lt;p&gt;".Style attribute inside it like - " style="text-align:justify" Text is to test Text is to test Text is to test Text is to testText is to testText is to test close paragraph tag"&lt;/p&gt;" </code></pre> <p>But this is not adjusting in report. Text is going to left side only.</p> <p>Is there any solution?? Please help. I will be so much thankful for that.. regards - Devdan</p>
40,528,566
1
How to aggregate values over a bigger than RAM gzip'ed csv file? <p>For starters I am new to bioinformatics and especially to programming, but I have built a script that will go through a so-called VCF file (only the individuals are included, one clumn = one individual), and uses a search string to find out for every variant (line) whether the individual is homozygous or heterozygous.</p> <p>This script works, at least on small subsets, but I know it stores everything in memory. I would like to do this on very large zipped files (of even whole genomes), but I do not know how to transform this script into a script that does everything line by line (because I want to count through whole columns I just do not see how to solve that).</p> <p>So the output is 5 things per individual (total variants, number homozygote, number heterozygote, and proportions of homo- and heterozygotes). See the code below:</p> <pre><code>#!usr/bin/env python import re import gzip subset_cols = 'subset_cols_chr18.vcf.gz' #nuc_div = 'nuc_div_chr18.txt' gz_infile = gzip.GzipFile(subset_cols, "r") #gz_outfile = gzip.GzipFile(nuc_div, "w") # make a dictionary of the header line for easy retrieval of elements later on headers = gz_infile.readline().rstrip().split('\t') print headers column_dict = {} for header in headers: column_dict[header] = [] for line in gz_infile: columns = line.rstrip().split('\t') for i in range(len(columns)): c_header=headers[i] column_dict[c_header].append(columns[i]) #print column_dict for key in column_dict: number_homozygotes = 0 number_heterozygotes = 0 for values in column_dict[key]: SearchStr = '(\d)/(\d):\d+,\d+:\d+:\d+:\d+,\d+,\d+' #this search string contains the regexp (this regexp was tested) Result = re.search(SearchStr,values) if Result: #here, it will skip the missing genoytypes ./. variant_one = int(Result.group(1)) variant_two = int(Result.group(2)) if variant_one == 0 and variant_two == 0: continue elif variant_one == variant_two: #count +1 in case variant one and two are equal (so 0/0, 1/1, etc.) number_homozygotes += 1 elif variant_one != variant_two: #count +1 in case variant one is not equal to variant two (so 1/0, 0/1, etc.) number_heterozygotes += 1 print "%s homozygotes %s" % (number_homozygotes, key) print "%s heterozygotes %s" % (number_heterozygotes,key) variants = number_homozygotes + number_heterozygotes print "%s variants" % variants prop_homozygotes = (1.0*number_homozygotes/variants)*100 prop_heterozygotes = (1.0*number_heterozygotes/variants)*100 print "%s %% homozygous %s" % (prop_homozygotes, key) print "%s %% heterozygous %s" % (prop_heterozygotes, key) </code></pre> <p>Any help will be much appreciated so I can go on investigating large datasets, thank you :)</p> <p>The VCF file by the way looks something like this: INDIVIDUAL_1 INDIVIDUAL_2 INDIVIDUAL_3 0/0:9,0:9:24:0,24,221 1/0:5,4:9:25:25,0,26 1/1:0,13:13:33:347,33,0</p> <p>This is then the header line with the individual ID names (I have in total 33 individuals with more complicated ID tags, I simplified here) and then I have a lot of these information lines with the same specific pattern. I am only interested in the first part with the slash so hence the regular epxression.</p>
20,651,236
0
Sync branches in git <p>I'm sure this is a simple one but I haven't been able to find the answer online, even after much Googling.</p> <p>I have Git installed on my machine, for which I followed the tutorial on the Github site. Following this made my machine master. Now, I need to work on a different branch. So I created a new branch on the site. Problem: this new branch isn't showing up in the Bash window, and when I try to switch to it, it isn't recognized. A coworker created his branch and it isn't on my machine either. </p> <p>How can I synchronize the list of branches on the site with my machine?</p> <p>Thanks!</p>
38,319,615
0
can we create compact table(excel-like) from normal table using javascript? <p>need to know that how can i form excel-like layout table from normal table.</p> <p>Child node should come under parent node in next row with indentation.</p> <p><img src="https://i.stack.imgur.com/173kk.png" alt="Excel-Like"></p>
10,420,003
0
<p>Give this a try:</p> <pre><code>select max(s.sNum) result from s2tmap st join s on st.sId = s.sId where st.tId = '000' and not exists ( select * from temp where temp.newId = st.sId) </code></pre> <p>Here is the <a href="http://sqlfiddle.com/#!5/26124/9" rel="nofollow">fiddle</a> to play with.</p> <p>Another option, probably less efficient would be:</p> <pre><code>select max(s.sNum) result from s2tmap st join s on st.sId = s.sId where st.tId = '000' and st.sId not in ( select newId from temp) </code></pre>
29,171,879
0
<p>Yes, this is possible. The syntax is a bit different, however.</p> <pre><code>if key in myDict: if innerKey in myDict[key]: myDict[key][innerKey] += 1 else: myDict[key][innerKey] = 0 </code></pre>
31,604,287
0
Script not working in wordpress <p>I would like to move the following page</p> <p><a href="http://cliponexpress.com/customize-your-clipon.html" rel="nofollow">http://cliponexpress.com/customize-your-clipon.html</a></p> <p>Into this wordpress page</p> <p><a href="http://cliponexpress.com/customizeit/" rel="nofollow">http://cliponexpress.com/customizeit/</a></p> <p>The script below changes the images when the thumbnails are clicked. it works fine on the html page, however I can't get it to work on wordpress, no matter where I place it (tried header, footer and within the page itself).</p> <p>Any idea what I'm doing wrong?</p> <p>Here is the script:</p> <pre><code>&lt;script type="text/javascript"&gt; $('a.thumbnail').click(function() { var src = $(this).attr('href'); var output = src.split('/').pop().split('.').shift(); $("#os1").val(output); $("#os1_text").text(output); if (src != $('img#lens').attr('src').replace(/\?(.*)/, '')) { $('img#lens').stop().animate({ opacity: '0' }, function() { $(this).attr('src', src + '?' + Math.floor(Math.random() * (10 * 100))); }).load(function() { $(this).stop().animate({ opacity: '1' }); }); } return false; }); $('a.thumbnail2').click(function() { var src = $(this).attr('href'); var output = src.split('/').pop().split('.').shift(); $("#os0").val(output); $("#os0_text").text(output); if (src != $('img#chassis').attr('src').replace(/\?(.*)/, '')) { $('img#chassis').stop().animate({ opacity: '0' }, function() { $(this).attr('src', src + '?' + Math.floor(Math.random() * (10 * 100))); }).load(function() { $(this).stop().animate({ opacity: '1' }); }); } return false; }); </code></pre> <p></p> <p>Thank you.</p>
37,334,888
0
Reduce Transparency setting in OS X makes white text in NSButton in popover disappear <p>I'm working on an OS X app that involves popovers with web views in them. The web views have <code>drawsBackground</code> set to <code>NO</code>. Sometimes there are buttons in these popovers, on top of the web views. These buttons have custom background colors and have their text colors set via <code>NSAttributedString</code>. But when the Reduce Transparency setting is on in System Preferences, the white text disappears. If the text is any other color, it shows up - even clear (though faintly).</p> <p><a href="https://github.com/tomhamming/nsbutton_title_disappear" rel="nofollow">See here</a> for an example project on GitHub demonstrating the problem.</p> <p>What is going on here?</p> <p><b>Update:</b> I talked to an engineer at WWDC 2016 about this, and he confirmed it was a bug. I filed a radar. He did manage to fix it in my code by setting the appearance of the button in question to <code>NSAppearanceNameAqua</code>.</p>
8,436,066
0
<p>Check out <code>clojure.contrib.repl-utils</code>, and <code>show</code> in particular.</p> <p><a href="http://richhickey.github.com/clojure-contrib/repl-utils-api.html#clojure.contrib.repl-utils/show" rel="nofollow">http://richhickey.github.com/clojure-contrib/repl-utils-api.html#clojure.contrib.repl-utils/show</a></p> <p>These are utilities for you to introspect objects and classes in the REPL, but the code is a good example of how to explore classes programatically.</p>
6,651,537
0
<p>For detecting CTRL + F:</p> <pre><code>event.ctrlKey == true &amp;&amp; event.keyCode == Keyboard.F </code></pre> <p>where 'event' is of course a KeyBoardEvent.</p> <p>As for the F3 question: the code you wrote will work as long as the flash application has focus. The F3 key command will then also not be routed to the browser. So what you need to do, is make sure that your application has focus when the user hits F3. How you solve this will depend on your JavaScript implementation. You could use ExternalInterface to tell the browser that the app is ready and than focus on the app. Or in Javascript you could catch the keyboard event, prevent its default behavior, and then call the function on the Flash app (again through ExternalInterface).</p> <p>To get you started, here's a little JQuery snippet for preventing the default F3 behaviour:</p> <pre><code>$('body').keyup(function(event) { if (event.keyCode == '114') event.preventDefault(); } </code></pre>
18,350,101
0
What is the best practise to maintain authenticated user details in an ASP.NET Intranet MVC application <p>I am developing an Intranet.NET MVC application. I need to store user details like location, ID Number etc associated with each authenticated users. </p> <p>In .NET Webform applications we used to save the logged in user's details in session. But what is the best practise in .NET MVC application ?</p>
13,431,881
0
<p>Its purely a CSS thing.It depends upon the DOM where are you trying to show the out put.. You can put them in separate DOM and apply margin or float and display as like you want..</p> <pre><code>&lt;div style = "float:left"&gt;&lt;?php wpfp_link();?&gt;&lt;/div&gt; &lt;div style = "float:right"&gt;&lt;?php the_views(); ?&gt;&lt;/div&gt; </code></pre>
36,503,536
1
Send Video over TCP using OpenCV and sockets in Raspberry Pi <p>I have been trying to send live video frame from my client (Raspberry Pi) to a server hosted on Laptop. Both these devices are connected to the same network.</p> <p>Server.py</p> <pre><code>import socket import sys import cv2 import pickle import numpy as np import struct HOST = '192.168.1.3' PORT = 8083 s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) print 'Socket created' s.bind((HOST, PORT)) print 'Socket bind complete' s.listen(10) print 'Socket now listening' conn, addr = s.accept() data = "" payload_size = struct.calcsize("L") while True: while len(data) &lt; payload_size: data += conn.recv(4096) packed_msg_size = data[:payload_size] data = data[payload_size:] msg_size = struct.unpack("L", packed_msg_size)[0] while len(data) &lt; msg_size: data += conn.recv(4096) frame_data = data[:msg_size] data = data[msg_size:] frame=pickle.loads(frame_data) print frame.size # cv2.imshow('frame', frame) # cv2.waitKey(10) </code></pre> <p>Client.py</p> <pre><code>import cv2 import numpy as np import socket import sys import pickle import struct cap = cv2.VideoCapture(0) clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) clientsocket.connect(('192.168.1.3', 8081)) while True: ret,frame = cap.read() data = pickle.dumps(frame) clientsocket.sendall(struct.pack("L", len(data)) + data) </code></pre> <p><strong>My server on laptop is not receiving any data</strong>. But when I run this client and server on same devices (e.g. server and client on laptop) then it is working properly.</p> <p>I am able to send data from raspberry to laptop (tested for echo application).</p> <p>Can anyone help me with this ?</p>
29,208,500
0
<p>Thanks to you both, you were indeed correct Ken, I had read this similar post a lot of times, and somehow didnt understand the answer within: </p> <p><a href="http://stackoverflow.com/questions/3188816/calling-object-methods-internally-in-dojo">Calling object methods internally in dojo</a></p> <p>After reading what you have posted, I have somehow understood the answer linked above and now understand what my problem was! Thanks to all.</p> <p>I fixed it by altering my code in the main application as follows:</p> <pre><code>var appInterface = new Interface(); on(registry.byId("graphBtn"),"click", appInterface.toggleGraphWindow); </code></pre> <p>changed to:</p> <pre><code>var appInterface = new Interface(); var graphToggle = dojo.hitch(appInterface, "toggleGraphWindow"); on(registry.byId("graphBtn"),"click", graphToggle); </code></pre> <p>I believe the reason for the error, was that the "this" object at runtime, was actually the "graphBtn" instead of the appInterface.</p>
28,751,931
0
How to mutually exclude two (or more) boolean flags using json shema? <pre><code>{ flag1: true, flag2: false } -&gt; ok { flag1: false, flag2: true } -&gt; ok { flag1: true } -&gt; ok { flag2: true } -&gt; ok { flag1: false, flag2: false } -&gt; ok { } -&gt; ok { flag1: false } -&gt; ok { flag2: false } -&gt; ok { flag1: true, flag2: true } -&gt; NO! </code></pre> <p>I want validation to fail only if both <code>flag1</code> and <code>flag2</code> are equal <code>true</code>.</p>
30,757,178
0
<p>I hit a similar issue and solved it using version 1.1.4 of <a href="https://github.com/google/google-api-php-client" rel="nofollow">google-api-php-client</a></p> <p>Assuming the following code is used to redirect a user to the Google authentication page:</p> <pre><code> $client = new Google_Client(); $client-&gt;setAuthConfigFile('/path/to/config/file/here'); $client-&gt;setRedirectUri('https://redirect/url/here'); $client-&gt;setAccessType('offline'); //optional $client-&gt;setScopes(['profile']); //or email $auth_url = $client-&gt;createAuthUrl(); header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL)); exit(); </code></pre> <p>Assuming a valid authentication code is returned to the <code>redirect_url</code>, the following will generate a token from the authentication code as well as provide basic profile information:</p> <pre><code> //assuming a successful authentication code is returned $authentication_code = 'code-returned-by-google'; $client = new Google_Client(); //.... configure $client object $client-&gt;authenticate($authentication_code); $token_data = $client-&gt;getAccessToken(); //get user email address $google_oauth =new Google_Service_Oauth2($client); $google_account_email = $google_oauth-&gt;userinfo-&gt;get()-&gt;email; //$google_ouath-&gt;userinfo-&gt;get()-&gt;familyName; //$google_ouath-&gt;userinfo-&gt;get()-&gt;givenName; //$google_ouath-&gt;userinfo-&gt;get()-&gt;name; </code></pre> <p>However, location is not returned. <a href="https://support.google.com/youtube/answer/1637615?hl=en-GB" rel="nofollow">New YouTube accounts don't have YouTube specific usernames</a> </p>
7,608,511
0
Java POI : How to read Excel cell value and not the formula computing it ? <p>I am using Apache POI Api to getting values from an Excel file. Everything is working great except with cells containing formulas. In fact, the cell.getStringCellValue() is returning the formula used in the cell and not the value of the cell. </p> <p>I tried to use evaluateFormulaCell() method but it's not working because I am using GETPIVOTDATA Excel formula and this formula is not implemented in the API:</p> <pre><code>Exception in thread "main" org.apache.poi.ss.formula.eval.NotImplementedException: Error evaluating cell Landscape!K11 at org.apache.poi.ss.formula.WorkbookEvaluator.addExceptionInfo(WorkbookEvaluator.java:321) at org.apache.poi.ss.formula.WorkbookEvaluator.evaluateAny(WorkbookEvaluator.java:288) at org.apache.poi.ss.formula.WorkbookEvaluator.evaluate(WorkbookEvaluator.java:221) at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCellValue(HSSFFormulaEvaluator.java:320) at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateFormulaCell(HSSFFormulaEvaluator.java:213) at fromExcelToJava.ExcelSheetReader.unAutreTest(ExcelSheetReader.java:193) at fromExcelToJava.ExcelSheetReader.main(ExcelSheetReader.java:224) Caused by: org.apache.poi.ss.formula.eval.NotImplementedException: GETPIVOTDATA at org.apache.poi.hssf.record.formula.functions.NotImplementedFunction.evaluate(NotImplementedFunction.java:42) </code></pre> <p>I hope you can help me on this.</p> <p>Thank you guys.</p>
34,298,113
0
<p>Download the akka for eclipse from below location </p> <p><a href="http://downloads.typesafe.com/akka/akka_2.11-2.4.1.zip?_ga=1.167921254.618585520.1450199987" rel="nofollow">http://downloads.typesafe.com/akka/akka_2.11-2.4.1.zip?_ga=1.167921254.618585520.1450199987</a></p> <p>extract the zip </p> <p>add dependencies from the lib folder into project</p>
4,192,812
0
Parsing pair of floats <p>Given a string like: <code>"0.123, 0.456"</code> what is the simplest way to parse the two float values into two variables <code>a</code> and <code>b</code>?</p>
38,678,120
0
<p>What you are referring in Java is called <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/innerclasses.html" rel="nofollow">anonymous inner class</a> - you are actually declaring a one-time derived class inline.</p> <p><strong>Unfortunately</strong> Swift doesn't have this feature.</p> <p><strong>But</strong> you can consider passing a closure to the instance.</p> <p>Lets say that your Card class have a var <code>getCardFunction</code>:</p> <pre><code>Class Card { var getCardFunction : () -&gt; Int } </code></pre> <p>Now you can pass the function you desire after initialising:</p> <pre><code>var card = Card() card.getCardFunction = { return 6 } </code></pre> <p><strong><em>Note</em></strong>: you can even have a default value for the <code>getCardFunction</code> function:</p> <pre><code>Class Card { var getCardFunction : () -&gt; Int = { return 3 } } </code></pre>
16,443,877
0
<p>I had the same trouble, went to see whether the suggested fix from <a href="https://svn.boost.org/trac/boost/ticket/4209" rel="nofollow">Boost Ticket #4209</a> worked, which didn't. I could see the total number of the elements, but not the content.</p> <p>So, the choices are, to switch to VS2012, for which there is a <a href="https://cppvisualizers.codeplex.com/" rel="nofollow">Plug-In</a>, or invest in figuring out the format in VS2010 and fixing the existing suggested code. </p> <p>Or, and that's what I did, use std::tr1::unordered_set / map instead. There is a visualizer for it in Visual Studio. And, later on, after debugging, if you wish, switch back to boost.</p>
3,654,257
0
<p>You need to retain a copy of the AdMob AdViewController as Admob no longer does this itself.</p> <p>In your viewcontroller.h add something like</p> <pre><code>IBOutlet AdViewController *localAdViewController; </code></pre> <p>inside the @interface section, and add</p> <pre><code>@property (nonatomic, retain) AdViewController *localAdViewController; </code></pre> <p>afterwards.</p> <p>Then add a link in IB from File's owner to your localAdViewController in AdViewController.</p> <p>Should work fine then on.</p>
40,175,236
0
SSL not working between Linux and Windows <p>I have gone through loads of material present on internet for SSL. I followed the steps and created self signed certificate on server (linux) using keytool. Server keystore was already having an entry as ( CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown), my new certificate was second entry as ( CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server ). Then I exported the certificate(.cer) using keytool and copied same on my client(windows). I then imported server generated certificate to client trustore. Now when I try to communicate using SSL it fails everytime. I turned on SSL debug on client. Below is the log</p> <pre><code>adding as trusted cert: Subject: CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server Issuer: CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server Algorithm: RSA; Serial number: 0x3bd2165e Valid from Fri Oct 21 13:08:11 IST 2016 until Thu Jan 19 13:08:11 IST 2017 adding as trusted cert: Subject: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Issuer: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Algorithm: RSA; Serial number: 0x46dac56d Valid from Fri Oct 21 13:20:47 IST 2016 until Thu Jan 19 13:20:47 IST 2017 *** found key for : Client chain [0] = [ [ Version: V3 Subject: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5 Key: Sun RSA public key, 2048 bits modulus: 19643942881710234591525118408612815215632338692166465250629734200981703093763200559775845583913404371567241804832487728799610532434766533695993759141114319525441958126364976642955560446067359829730544145500409447935888670367709958247941184557182316292540918805424085096889405623367353240389104083404287642633808982388623942568195322780929142023222276129235672938020453213230922184807911898395818264624343113898437136096266829934433793735074739359988881755805184514603338282021635155460130597302085016075305135792447640646817495498043975883348791446660517781531653507565586938242488813328480016900010365926159926261191 public exponent: 65537 Validity: [From: Fri Oct 21 13:20:47 IST 2016, To: Thu Jan 19 13:20:47 IST 2017] Issuer: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client SerialNumber: [ 46dac56d] Certificate Extensions: 1 [1]: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: 72 B5 E3 14 98 BD 53 F3 69 33 96 A5 71 F5 99 2B r.....S.i3..q..+ 0010: 22 0F B9 F6 "... ] ] ] Algorithm: [SHA1withRSA] Signature: 0000: 21 16 B3 C9 5D BC EB 71 35 78 95 8E BF 30 72 AC !...]..q5x...0r. 0010: D1 42 AA B7 C1 8B 23 FD 67 DF 6F 36 85 E8 C6 05 .B....#.g.o6.... 0020: A4 7B E7 A5 B5 3A FC 0C 88 29 3D C3 CD C2 88 8D .....:...)=..... 0030: 86 3A BF 14 85 93 01 75 5E 6E 01 87 44 A9 0A 21 .:.....u^n..D..! 0040: A2 F0 C3 05 9C 40 7B 89 61 DB 84 28 73 89 0F 3A .....@..a..(s..: 0050: B7 96 E8 63 30 29 8A B5 11 4C D2 7E A8 17 6F 0F ...c0)...L....o. 0060: 4E C7 4A AD E0 A8 6E 68 CE 72 FE DD DE F7 1C 84 N.J...nh.r...... 0070: 20 C9 C4 CA F1 6A 3B C0 F9 A8 DD 03 0B EF 04 03 ....j;......... 0080: 40 BA 37 F6 B6 9C BE FF A9 E6 0E BF E6 32 B8 B3 @.7..........2.. 0090: 0A EB 0F F7 EA 23 93 D1 17 D7 6E 94 0C 98 4C 90 .....#....n...L. 00A0: 40 21 DE 39 09 A9 16 2A 97 DD 2D E5 C0 FC FE 2E @!.9...*..-..... 00B0: AE 36 0C 04 6D A8 8F 1D B8 2B 99 54 7C AD 4F 8C .6..m....+.T..O. 00C0: 01 9C C2 07 77 81 A7 6C 07 2D A3 75 1D 4E E4 16 ....w..l.-.u.N.. 00D0: 7E D0 BD E4 79 0F B6 9C C8 62 2E D6 E1 AC 35 58 ....y....b....5X 00E0: 22 B2 8C 4B FE 9A 06 C4 53 C1 8F 45 EA 61 3A 7F "..K....S..E.a:. 00F0: 3C D1 15 0D A8 27 3E 0F AB F5 8F DA 78 05 5F AE &lt;....'&gt;.....x._. ] *** trigger seeding of SecureRandom done seeding SecureRandom keyStore is : D:\\Development\\Workspace\\Eclipse\\testSSL\\Sample\\.keystore keyStore type is : jks keyStore provider is : init keystore init keymanager of type SunX509 *** found key for : Client chain [0] = [ [ Version: V3 Subject: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5 Key: Sun RSA public key, 2048 bits modulus: 19643942881710234591525118408612815215632338692166465250629734200981703093763200559775845583913404371567241804832487728799610532434766533695993759141114319525441958126364976642955560446067359829730544145500409447935888670367709958247941184557182316292540918805424085096889405623367353240389104083404287642633808982388623942568195322780929142023222276129235672938020453213230922184807911898395818264624343113898437136096266829934433793735074739359988881755805184514603338282021635155460130597302085016075305135792447640646817495498043975883348791446660517781531653507565586938242488813328480016900010365926159926261191 public exponent: 65537 Validity: [From: Fri Oct 21 13:20:47 IST 2016, To: Thu Jan 19 13:20:47 IST 2017] Issuer: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client SerialNumber: [ 46dac56d] Certificate Extensions: 1 [1]: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: 72 B5 E3 14 98 BD 53 F3 69 33 96 A5 71 F5 99 2B r.....S.i3..q..+ 0010: 22 0F B9 F6 "... ] ] ] Algorithm: [SHA1withRSA] Signature: 0000: 21 16 B3 C9 5D BC EB 71 35 78 95 8E BF 30 72 AC !...]..q5x...0r. 0010: D1 42 AA B7 C1 8B 23 FD 67 DF 6F 36 85 E8 C6 05 .B....#.g.o6.... 0020: A4 7B E7 A5 B5 3A FC 0C 88 29 3D C3 CD C2 88 8D .....:...)=..... 0030: 86 3A BF 14 85 93 01 75 5E 6E 01 87 44 A9 0A 21 .:.....u^n..D..! 0040: A2 F0 C3 05 9C 40 7B 89 61 DB 84 28 73 89 0F 3A .....@..a..(s..: 0050: B7 96 E8 63 30 29 8A B5 11 4C D2 7E A8 17 6F 0F ...c0)...L....o. 0060: 4E C7 4A AD E0 A8 6E 68 CE 72 FE DD DE F7 1C 84 N.J...nh.r...... 0070: 20 C9 C4 CA F1 6A 3B C0 F9 A8 DD 03 0B EF 04 03 ....j;......... 0080: 40 BA 37 F6 B6 9C BE FF A9 E6 0E BF E6 32 B8 B3 @.7..........2.. 0090: 0A EB 0F F7 EA 23 93 D1 17 D7 6E 94 0C 98 4C 90 .....#....n...L. 00A0: 40 21 DE 39 09 A9 16 2A 97 DD 2D E5 C0 FC FE 2E @!.9...*..-..... 00B0: AE 36 0C 04 6D A8 8F 1D B8 2B 99 54 7C AD 4F 8C .6..m....+.T..O. 00C0: 01 9C C2 07 77 81 A7 6C 07 2D A3 75 1D 4E E4 16 ....w..l.-.u.N.. 00D0: 7E D0 BD E4 79 0F B6 9C C8 62 2E D6 E1 AC 35 58 ....y....b....5X 00E0: 22 B2 8C 4B FE 9A 06 C4 53 C1 8F 45 EA 61 3A 7F "..K....S..E.a:. 00F0: 3C D1 15 0D A8 27 3E 0F AB F5 8F DA 78 05 5F AE &lt;....'&gt;.....x._. ] *** trustStore is: D:\Development\Workspace\Eclipse\testSSL\Sample\.keystore trustStore type is : jks trustStore provider is : init truststore adding as trusted cert: Subject: CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server Issuer: CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server Algorithm: RSA; Serial number: 0x3bd2165e Valid from Fri Oct 21 13:08:11 IST 2016 until Thu Jan 19 13:08:11 IST 2017 adding as trusted cert: Subject: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Issuer: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Algorithm: RSA; Serial number: 0x46dac56d Valid from Fri Oct 21 13:20:47 IST 2016 until Thu Jan 19 13:20:47 IST 2017 trigger seeding of SecureRandom done seeding SecureRandom Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 Ignoring unavailable cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256 Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_GCM_SHA256 Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_GCM_SHA384 Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 Ignoring unavailable cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 Ignoring unavailable cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 Ignoring unavailable cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 Allow unsafe renegotiation: false Allow legacy hello messages: true Is initial handshake: true Is secure renegotiation: false main, setSoTimeout(0) called %% No cached client session *** ClientHello, TLSv1 RandomCookie: GMT: 1476980696 bytes = { 63, 74, 124, 176, 200, 133, 175, 107, 173, 166, 115, 188, 94, 103, 2, 237, 54, 77, 30, 244, 166, 94, 22, 118, 220, 68, 182, 101 } Session ID: {} Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_MD5, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] Compression Methods: { 0 } Extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, secp256k1} Extension ec_point_formats, formats: [uncompressed] *** main, WRITE: TLSv1 Handshake, length = 149 main, READ: TLSv1 Handshake, length = 893 *** ServerHello, TLSv1 RandomCookie: GMT: 1476980313 bytes = { 231, 179, 63, 173, 107, 35, 84, 125, 43, 218, 134, 171, 63, 175, 41, 97, 49, 69, 68, 114, 75, 255, 22, 5, 125, 125, 124, 228 } Session ID: {88, 9, 238, 89, 11, 220, 101, 208, 32, 106, 9, 30, 220, 143, 218, 47, 199, 2, 7, 90, 179, 24, 198, 139, 59, 34, 141, 169, 98, 186, 165, 87} Cipher Suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA Compression Method: 0 Extension renegotiation_info, renegotiated_connection: &lt;empty&gt; *** %% Initialized: [Session-1, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA] ** TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA *** Certificate chain chain [0] = [ [ Version: V3 Subject: CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown Signature Algorithm: SHA1withRSA, OID = 1.2.840.113549.1.1.5 Key: Sun RSA public key, 1024 bits modulus: 95112623927847376021742911976482809760928286563374389538614118188348331948203986176617263611529390313893505980510111828145989572854367203125102386298954935692697121151897799979668903275037476471253143679337867450398842776382716002256891170241471053163351903550915614869043680655531661128282766400131123099323 public exponent: 65537 Validity: [From: Wed Jan 02 01:20:42 IST 2013, To: Sat Jan 06 01:20:42 IST 2018] Issuer: CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown SerialNumber: [ 50e33e12] ] Algorithm: [SHA1withRSA] Signature: 0000: 3F 48 66 AE 51 1D 5C 0C E9 0D 88 DD CD 48 84 B7 ?Hf.Q.\......H.. 0010: 9A B3 70 79 C9 43 0E 4D B1 1E 10 5B 7A EB DC 6B ..py.C.M...[z..k 0020: 9B 15 E4 9E 9C 94 39 1C E7 CF 0E 2C D0 A8 A0 1D ......9....,.... 0030: A1 A4 E4 63 A0 37 AA 98 72 31 77 56 16 31 49 B9 ...c.7..r1wV.1I. 0040: 8D BD A1 D7 53 BF 82 69 9C C7 B6 2A F0 FA A2 2D ....S..i...*...- 0050: C2 34 25 23 9C DA B6 74 D5 E0 CC 27 45 A9 8C 41 .4%#...t...'E..A 0060: 23 8B 33 A8 92 72 46 77 E0 10 E7 C6 38 9D 1D A8 #.3..rFw....8... 0070: E5 B2 B3 B5 58 99 B3 BD 1C E3 B0 39 54 F2 EB 46 ....X......9T..F ] *** CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server X.509 adding as trusted cert: Subject: CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server Issuer: CN=Server, OU=Server, O=Server, L=Server, ST=Server, C=Server Algorithm: RSA; Serial number: 0x3bd2165e Valid from Fri Oct 21 13:08:11 IST 2016 until Thu Jan 19 13:08:11 IST 2017 adding as trusted cert: Subject: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Issuer: CN=Client, OU=Client, O=Client, L=Client, ST=Client, C=Client Algorithm: RSA; Serial number: 0x46dac56d Valid from Fri Oct 21 13:20:47 IST 2016 until Thu Jan 19 13:20:47 IST 2017 %% Invalidated: [Session-1, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA] main, SEND TLSv1 ALERT: fatal, description = certificate_unknown main, WRITE: TLSv1 Alert, length = 2 main, called closeSocket() main, handling exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target main, IOException in getSession(): javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target main, called close() main, called closeInternal(true) main, called close() main, called closeInternal(true) </code></pre> <p>When I checked logs carefully I noticed Server is sending only first certificate in chain of certificates to client i.e,. ( CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown ), my newly created certificate is not present. Am I doing something wrong? </p>
9,699,338
0
<p>Hum... Norwegian is included in UTF8.</p> <p>You surely have an encoding problem. It's strange, i never face that with localisables...</p> <p>However, becareful, you have a syntax error in your english localisable : you must finish every line with <strong>;</strong></p> <pre><code>"of"="of"; </code></pre>
9,482,952
0
<p>You need to make sure all of your assemblies are compiling for the correct architecture. Try changing the architecture for x86 if reinstalling the COM component doesn't work.</p>
17,660,504
0
GXT get value of TextArea without focus loss <p>I have a GXT 3 TextArea on which I catch copy-paste events. On this event, I would like to get the text that is inside the textarea.</p> <p><strong>Problem</strong> : the textarea still has the focus so the value is not updated. Hence, <code>getValue()</code> returns an empty string...</p> <p>I tried to call <code>getValue()</code> <code>getCurrentValue()</code> <code>flush()</code> <code>validate()</code>. </p> <p>I also tried to extend <code>TextArea</code> to have access to <code>blur()</code> method and call it before getting the value : it makes no difference.</p> <p>Any solution? (even solution with GWT components would be appreciated).</p>
33,355,290
0
<p>The API and all client libraries in turn will return actual objects when they are queried for. However, when referencing an object in the API you do so with just the object's ID. </p> <p>Therefore, in your code above, <code>workspace</code> holds the actual workspace object. In order to use that in a query you must use <code>workspace: workspace.id</code>. </p> <p>You can see a working example of <code>.find_by_workspace()</code> <a href="https://github.com/Asana/ruby-asana/blob/master/examples/personal_access_token.rb" rel="nofollow">here</a>:</p> <pre><code>puts "My Workspaces:" client.workspaces.find_all.each do |workspace| puts "\t* #{workspace.name} - tags:" client.tags.find_by_workspace(workspace: workspace.id).each do |tag| puts "\t\t- #{tag.name}" end end </code></pre>
19,975,386
0
<p>Threads do not work, abstain from that approach.</p> <p>Creating several threads fails, as you have noticed, because only one thread has a current OpenGL context. In principle, you <em>could</em> make the context current in each worker thread before calling <code>glReadPixels</code>, but this will require extra synchronization from your side (otherwise, a thread could be preempted in between making the context current and reading back!), and <code>(wgl|glx)MakeCurrent</code> is a terribly slow function that will seriously stall OpenGL. In the end, you'll be doing <em>more work</em> to get something much <em>slower</em>.</p> <p>There is no way to make <code>glReadPixels</code> any faster<sup>1</sup>, but you can decouple the time it takes (i.e. the readback runs asynchronously), so it does not block your application and effectively <em>appears</em> to run "faster".<br> You want to use a <a href="http://www.songho.ca/opengl/gl_pbo.html#pack">Pixel buffer object</a> for that. Be sure to get the buffer flags correct.</p> <p>Note that mapping the buffer to access its contents will <em>still</em> block if the complete contents hasn't finished transferring, so it will <em>still</em> not be any faster. To account for that, you either have to read the previous frame, or use a fence object which you can query to be sure that it's done.<br> Or, simpler but less reliable, you can insert "some other work" in between <code>glReadPixels</code> and accessing the data. This will not guarantee that the transfer has finished by the time you access the data, so it may still block. However, it <em>may</em> just work, and it will <em>likely</em> block for a shorter time (thus run "faster").</p> <p><hr /> <sup>1</sup> There are plenty of ways of making it <em>slower</em>, e.g. if you ask OpenGL to do some weird conversions or if you use wrong buffer flags. However, generally, there's no way to make it faster since its speed depends on all previous draw commands having finished before the transfer can even start, and the data being transferred over the PCIe bus (which has a fixed time overhead plus a finite bandwidth).<br> The only viable way of making readbacks "faster" is hiding this latency. It's of course still not faster, but you don't get to feel it.</p>
31,219,272
0
Selector in Method over riding <p>In the case of method over riding in objective c how selector knows that which method needs to call via selector?</p> <p>As we dont pass any arguments in slector section...</p> <p>Ex: in <code>tmp.m</code> file There is 2 methods with different arguments</p> <pre><code>-(void)details { } -(void)details:(NSDictionary *)result { } </code></pre> <p>And when m call another method with the use of selector as:</p> <pre><code>[mc detailstrac:[[NSUserDefaults standardUserDefaults] valueForKey:@"userID"] tracid:self.trac_id selector:@selector(details:)]; </code></pre> <p>How selector knows to call which method !</p> <p>I have checked that</p> <pre><code>-(void)details:(NSDictionary *)result { } </code></pre> <p>this method is called every time then what about </p> <pre><code>-(void)details { } </code></pre> <p><strong>this ?</strong></p>
9,455,032
0
<p>You can't: floating point numbers aren't exact values, only estimations, by definition. You are supposed to get such deviations.</p>
35,525,200
0
My getter and setter functions for Tic Tac Toe are not working <p>Hello I am learning C++ and I need help with my programming code. I am trying to make my private char variable accessible by the local functions inside the class so that I may display it inside Int main(). Everytime I run the compiler it gives me the error ("invalid types 'char[int]'for array subscripts").Also if any one knows how to pass variables inside a class so that I may be able to have the board display the user move;That would be greatly appreciated. P.S I know that done = 0. that was just for me to test the board output.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; class CheckerBoard{ public: void initBoard() { for(int y=0; y&lt;3; y++) { for(int x=0; x&lt;6; x++) { if((x%2)==0) { _board[y][x]='-'; } else { _board[y][x]= '|'; }} } } void printBoard(){ for(int y=0; y&lt;3; y++) { for(int x=0; x&lt;6; x++) { cout&lt;&lt; _board[y][x]; } cout&lt;&lt;endl; } } void setBoard(char board){ _board[3][6]=board;} char getBoard(){ return _board[3][6]; } private: char _board[3][6]; }; int main() {int done=1; int x; int y; while(done==0){ char player1Symbol; char player2Symbol; string player1Name; string player2Name; cout &lt;&lt; "Welcome to Tic Tac Toe Lite" &lt;&lt; endl; cout&lt;&lt;"What is your Name player one?"&lt;&lt;endl; cin&gt;&gt;player1Name; cout&lt;&lt;"What symbol would you like?"&lt;&lt;endl; cin&gt;&gt;player1Symbol; cout&lt;&lt;"What is your name player two?"&lt;&lt;endl; cin&gt;&gt;player2Name; cout&lt;&lt;"What symbol would you like?"&lt;&lt;endl; cin&gt;&gt;player2Symbol; cout&lt;&lt;"Ok player one pick an X coordinate"; cin&gt;&gt;x; cout&lt;&lt;"Now pick an Y coordinate"; cin&gt;&gt;y; if(x&gt;0&amp;&amp;y&gt;0){ board[y][x]=player1Symbol; } CheckerBoard checkerBoard; checkerBoard.initBoard(); checkerBoard.printBoard(); } } CheckerBoard checkerBoard; checkerBoard.initBoard(); checkerBoard.printBoard(); return 0; } </code></pre>
30,950,216
1
Unit testing Python Flask Stream <p>Does anybody have any experience/pointers on testing a Flask Content Streaming resource? My application uses Redis Pub/Sub, when receiving a message in a channel it streams the text 'data: {"value":42}' The implementation is following Flask docs at: <a href="http://flask.pocoo.org/docs/0.10/patterns/streaming/" rel="nofollow">docs</a> and my unit tests are done following Flask docs too. The messages to Redis pub/sub are sent by a second resource (POST).</p> <p>I'm creating a thread to listen to the stream while I POST on the main application to the resource that publishes to Redis.</p> <p>Although the connection assertions pass (I receive OK 200 and a mimetype 'text/event-stream') the data object is empty.</p> <p>My unit test is like this:</p> <pre><code>def test_04_receiving_events(self): headers = [('Content-Type', 'application/json')] data = json.dumps({"value": 42}) headers.append(('Content-Length', len(data))) def get_stream(): rv_stream = self.app.get('stream/data') rv_stream_object = json.loads(rv_stream.data) #error (empty) self.assertEqual(rv_stream.status_code, 200) self.assertEqual(rv_stream.mimetype, 'text/event-stream') self.assertEqual(rv_stream_object, "data: {'value': 42}") t.stop() threads = [] t = Thread(target=get_stream) threads.append(t) t.start() time.sleep(1) rv_post = self.app.post('/sensor', headers=headers, data=data) threads_done = False while not threads_done: threads_done = True for t in threads: if t.is_alive(): threads_done = False time.sleep(1) </code></pre> <p>The app resource is:</p> <pre><code>@app.route('/stream/data') def stream(): def generate(): pubsub = db.pubsub() pubsub.subscribe('interesting') for event in pubsub.listen(): if event['type'] == 'message': yield 'data: {"value":%s}\n\n' % event['data'] return Response(stream_with_context(generate()), direct_passthrough=True, mimetype='text/event-stream') </code></pre> <p>Any pointers or examples of how to test a Content Stream in Flask? Google seems to not help much on this one, unless I'm searching the wrong keywords.</p> <p>Thanks in advance.</p>
8,338,593
0
How to get the selected radio button value from five radio buttons in android? <p>I need to get the selected radio button value out of 5 radio buttons. I have done like :</p> <p><strong>Radio button values from db:</strong></p> <pre><code>op1=(RadioButton)findViewById(R.id.option1); op2=(RadioButton)findViewById(R.id.option2); op3=(RadioButton)findViewById(R.id.option3); op4=(RadioButton)findViewById(R.id.option4); op5=(RadioButton)findViewById(R.id.option5); System.out.println("after lv users "); op1.setText(listItem.getOption1()); op2.setText(listItem.getOption2()); op3.setText(listItem.getOption3()); op4.setText(listItem.getOption4()); op5.setText(listItem.getOption5()); </code></pre> <p><strong>RadioButton check action:</strong></p> <pre><code>radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup rg, int checkedId) { for(int i=0; i&lt;radioGroup.getChildCount(); i++) { System.out.print("radiogroup child counts"); System.out.print(radioGroup.getChildCount()); op1 = (RadioButton) radioGroup.getChildAt(i); if(op1.isSelected()== true) { System.out.println("radio i value"); System.out.print("option"+i); //String text = btn.getText(); // do something with text } } } }); </code></pre> <p>But it is not working.It is showing error as <code>NullPointerException</code> at line </p> <pre><code>op1.setText(listItem.getOption1()); </code></pre> <p>Where I went wrong?</p> <p>Help me regarding this.</p>
14,904,263
0
<p><code>HasColumnType("datetime")</code> specifies the column type, not the temporary parameter types that are used in the SQL statements. You can't control those and it's not necessary. If you have a .NET <code>DateTime</code> in your application with some decimal places filled and want to store that in a <code>datetime</code> type in SQL Server the value will (and can only) be stored as a rounded value. It doesn't matter if the rounding happens on client side before the SQL is sent to the database server or if the rounding happens on the database server itself. The result will be the same: A rounded stored value with a loss of precision.</p>
24,128,315
0
<p>I recommend the following:</p> <pre><code>require 'yaml' data = YAML.load_file '&lt;filename&gt;' data.sort_by{|hash| hash[:key1]} </code></pre> <p>Your file looks quite a bit like JSON data, but includes a few minor formatting differences that make using a JSON parser impossible. Thankfully the data is perfectly valid YAML, so Ruby's YAML parser can read it just fine.</p>
13,537,482
0
Open Elfinder 2.X from input field <p>In my CMS I used Elfinder 1.X, which was integrated into CKEditor and I could open an other instance by clicking an input as well. Now I updated Elfinder to 2.0 and the input doesn't want to work anymore. </p> <p>Here's the code I had:</p> <pre><code>function load_elfinder($id) { $('&lt;div /&gt;').elfinder({ url : 'lib/modules/elfinder/connectors/php/connector.php', lang : 'hu', dialog : { width : 900, modal : false }, editorCallback : function(url) { document.getElementById($id).value = url; } }) } </code></pre> <p>And then: $(".news_index").on('click',function(){ load_elfinder('news_index'); });</p> <p>Now this function doesn't work. With CKEditor it works perfectly. What could be the problem? </p>
38,930,779
0
How to create email form PHP (HTML5) <p>I'm a little bit new with with php and i just want to ask how can i make the the "Send Message" button send the inputted information on the form i created to my email.</p> <p>Here's the code:</p> <pre><code> &lt;section id="three"&gt; &lt;h2&gt;Email Me!&lt;/h2&gt; &lt;p&gt;You will receive a reply within 24-48 hours.&lt;/p&gt; &lt;div class="row"&gt; &lt;div class="8u 12u$(small)"&gt; &lt;form method="post" action="MAILTO:sample@email.com"&gt; &lt;div class="row uniform 50%"&gt; &lt;div class="6u 12u$(xsmall)"&gt;&lt;input type="text" name="name" id="name" placeholder="Name" /&gt;&lt;/div&gt; &lt;div class="6u$ 12u$(xsmall)"&gt;&lt;input type="email" name="email" id="email" placeholder="Email" /&gt;&lt;/div&gt; &lt;div class="12u$"&gt;&lt;textarea name="message" id="message" placeholder="Message" rows="4"&gt;&lt;/textarea&gt;&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;ul class="actions"&gt; &lt;li&gt;&lt;input type="submit" value="Send Message" /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="4u$ 12u$(small)"&gt; &lt;ul class="labeled-icons"&gt; &lt;li&gt; &lt;h3 class="icon fa-home"&gt;&lt;span class="label"&gt;Address&lt;/span&gt;&lt;/h3&gt; 1234 Somewhere Rd.&lt;br /&gt; Nashville, TN 00000&lt;br /&gt; United States &lt;/li&gt; &lt;li&gt; &lt;h3 class="icon fa-mobile"&gt;&lt;span class="label"&gt;Phone&lt;/span&gt;&lt;/h3&gt; 000-000-0000 &lt;/li&gt; &lt;li&gt; &lt;h3 class="icon fa-envelope-o"&gt;&lt;span class="label"&gt;Email&lt;/span&gt;&lt;/h3&gt; &lt;a href="#"&gt;hello@untitled.tld&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; </code></pre> <p>Thanks!</p>
10,122,569
0
<p>Relations are defined by predicates in Prolog. There is no built-in (but you could do it for example by using term expansion) syntactic way to define predicates inside predicates in program text, and there seems little reason to do so. You can simply write separate predicates and refer to them. You <em>can</em> of course have nested terms, that is terms as subterms of other terms. </p> <p>What do you mean with</p> <pre><code>relation(CctypeInt,[0-{2,3,4}, 1-{2,3,4}, 2-{2}],Ru1),!. </code></pre> <p>? This is a clause that states something about the predicate (,)/2 , which I doubt was the intention. On the other hand, you can of course build and use a Prolog term like</p> <pre><code>relation(cctypeint,relation(ru_1,...,ru_n)) </code></pre> <p>in your programs to represent your data.</p>
18,397,644
0
FXG ScaleGrid on BitmapImage not working <p>Does anyone encounter this? FXG ScaleGrid seem to be not working on BitmapImage. Below are my code:</p> <pre><code>&lt;Graphic version="2.0" xmlns="http://ns.adobe.com/fxg/2008" scaleGridTop="6" scaleGridLeft="6" scaleGridRight="94" scaleGridBottom="54" &gt; &lt;Rect width="100" height="60" radiusX="4" radiusY="4" &gt; &lt;fill&gt; &lt;LinearGradient rotation="90" &gt; &lt;GradientEntry color="#00649f" /&gt; &lt;GradientEntry color="#005080" /&gt; &lt;/LinearGradient&gt; &lt;/fill&gt; &lt;stroke&gt; &lt;LinearGradientStroke rotation="90" &gt; &lt;GradientEntry color="#0079c1" /&gt; &lt;GradientEntry color="#004b77" /&gt; &lt;/LinearGradientStroke&gt; &lt;/stroke&gt; &lt;/Rect&gt; &lt;!-- Use BitmapImage for InnerGlow, since ScaleGrid will not work on filter --&gt; &lt;BitmapImage x="0" y="0" source="@Embed('skins/mobi/assets240/InnerGlow240.png')" scaleX="1" scaleY="1" fillMode="scale" width="100" height="60" /&gt; &lt;/Graphic&gt; </code></pre> <p>When I scale it, the <b>Rect</b> portion has no problem in scaling, but the <b>BitmapImage</b> didn't scale according to the scaleGrid set, is there anything that I have done it wrongly?</p> <p>Thanks!</p> <p>Joel</p>
26,121,708
0
<p>This should do what you want:</p> <pre><code>select si.Rollnumber, max(case when si.Property = 'Name' then si.Value end) as Name, max(case when si.Property = 'Year' then si.Value end) as Year, max(case when si.Property = 'City' then si.Value end) as City from StudentInfo si group by si.Rollnumber; </code></pre>
19,327,731
0
How to find the vertical and horizontal distance from the center of a rectangle <p>For my current Java project I have to compute the horizontal and vertical distance from the center of a rectangle. I tried using the formula from a previous project to find such a distance. Here is my code:</p> <pre><code> // Calculations; centerCoordinate = 0 formula = Math.sqrt(Math.pow(userXCoordinate - centerCoordinate, 2) + Math.pow(userYCoordinate - centerCoordinate, 2)); </code></pre> <p>My professor gave the hint that a point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to 10 / 2 and its vertical distance to (0, 0) is less than or equal to 5 / 2. I tried using 5 for horizontal distance and 2.5 for vertical distance and setting variables to these numbers. I then made an if-else loop saying if the result of the formula was less than or equal to the variables the coordinates were in the rectangle otherwise they were outside. This returned a wrong answer; what could I do differently? </p>
13,065,225
0
display multiple row for one record in jqgrid <p>hi i want to display the multiple row for single record in jqgrid. For example if a grid has 10 columns such as c1,c2,c3...c10 and values such as va1,va2,va3....,va10 and vb1,vb2,vb3....,vb10 and so on. it should display as,</p> <p>---------------------- ->Headers</p> <h2>|c1|c2|c3|c4|c5|</h2> <h2>|c6|c7|c8|c9|c10|</h2> <p>---------------------- ->value1</p> <h2>|va1|va2|va3|va4|va5|</h2> <h2>|va6|va7|va8|va9|va10|</h2> <p>---------------------- ->value2</p> <h2>|vb1|vb2|vb3|vb4|vb5|</h2> <h2>|vb6|vb7|vb8|vb9|vb10|</h2> <hr> <p>. ->value3 . .</p> <p>please help me</p> <p>Thanks, Jay</p>
13,823,707
0
Creating a list of most popular posts of the past week - Wordpress <p>I have created a widget for my Wordpress platform that displays the most popular posts of the week. However, there is an issue with it. It counts the most popular posts from <strong>Monday</strong>, not the past 7 days. For instance, this means that on Tuesday, it will only include posts from Tuesday and Monday.</p> <p>Here is my widget code:</p> <pre><code>&lt;?php class PopularWidget extends WP_Widget { function PopularWidget(){ $widget_ops = array('description' =&gt; 'Displays Popular Posts'); $control_ops = array('width' =&gt; 400, 'height' =&gt; 300); parent::WP_Widget(false,$name='ET Popular Widget',$widget_ops,$control_ops); } /* Displays the Widget in the front-end */ function widget($args, $instance){ extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? 'Popular This Week' : $instance['title']); $postsNum = empty($instance['postsNum']) ? '' : $instance['postsNum']; $show_thisweek = isset($instance['thisweek']) ? (bool) $instance['thisweek'] : false; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?&gt; &lt;?php $additional_query = $show_thisweek ? '&amp;year=' . date('Y') . '&amp;w=' . date('W') : ''; query_posts( 'post_type=post&amp;posts_per_page='.$postsNum.'&amp;orderby=comment_count&amp;order=DESC' . $additional_query ); ?&gt; &lt;div class="widget-aligned"&gt; &lt;h3 class="box-title"&gt;Popular Articles&lt;/h3&gt; &lt;div class="blog-entry"&gt; &lt;ol&gt; &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt; &lt;li&gt;&lt;h4 class="title"&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h4&gt;&lt;/li&gt; &lt;?php endwhile; endif; wp_reset_query(); ?&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- end widget-aligned --&gt; &lt;div style="clear:both;"&gt;&lt;/div&gt; &lt;?php echo $after_widget; } /*Saves the settings. */ function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = stripslashes($new_instance['title']); $instance['postsNum'] = stripslashes($new_instance['postsNum']); $instance['thisweek'] = 0; if ( isset($new_instance['thisweek']) ) $instance['thisweek'] = 1; return $instance; } /*Creates the form for the widget in the back-end. */ function form($instance){ //Defaults $instance = wp_parse_args( (array) $instance, array('title'=&gt;'Popular Posts', 'postsNum'=&gt;'','thisweek'=&gt;false) ); $title = htmlspecialchars($instance['title']); $postsNum = htmlspecialchars($instance['postsNum']); # Title echo '&lt;p&gt;&lt;label for="' . $this-&gt;get_field_id('title') . '"&gt;' . 'Title:' . '&lt;/label&gt;&lt;input class="widefat" id="' . $this-&gt;get_field_id('title') . '" name="' . $this-&gt;get_field_name('title') . '" type="text" value="' . $title . '" /&gt;&lt;/p&gt;'; # Number of posts echo '&lt;p&gt;&lt;label for="' . $this-&gt;get_field_id('postsNum') . '"&gt;' . 'Number of posts:' . '&lt;/label&gt;&lt;input class="widefat" id="' . $this-&gt;get_field_id('postsNum') . '" name="' . $this-&gt;get_field_name('postsNum') . '" type="text" value="' . $postsNum . '" /&gt;&lt;/p&gt;'; ?&gt; &lt;input class="checkbox" type="checkbox" &lt;?php checked($instance['thisweek'], 1) ?&gt; id="&lt;?php echo $this-&gt;get_field_id('thisweek'); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('thisweek'); ?&gt;" /&gt; &lt;label for="&lt;?php echo $this-&gt;get_field_id('thisweek'); ?&gt;"&gt;&lt;?php esc_html_e('Popular this week','Aggregate'); ?&gt;&lt;/label&gt; &lt;?php } }// end AboutMeWidget class function PopularWidgetInit() { register_widget('PopularWidget'); } add_action('widgets_init', 'PopularWidgetInit'); ?&gt; </code></pre> <p>How can I change this script so that it will count the past 7 days rather than posts from last Monday?</p>
37,470,417
0
Use json-simple (Java, Eclipse) to convert a txt file to JSON file, some special characters does not shown properly in JSON file <p>I am using json-simple to parse a txt file to JSON file. The data I need contains some special characters (emoticon) such as "(●⁰౪⁰●)(//●⁰౪⁰●)//" and " "˭̡̞(◞⁎˃ᆺ˂)◞<em>✰". The result JSON file is not recoginize some characters in it, for instance it will convert the second emoticon into "˭̡̞(◞\u204E˃ᆺ˂)◞</em>✰" I know that \204E is the UTF code for lower * but I do not know how to correctly make it write properly into JSON file. I have tried to encode my input txt file in UTF_8 but it does not work as well. I was wondering if anyone has a good idea for how to solve the issue, Thanks. </p>
29,940,766
0
<pre><code>var Book = {"Titles":[ { "Book3" : "BULLETIN 3" } , { "Book1" : "BULLETIN 1" } , { "Book2" : "BULLETIN 2" } ]} var findbystr = function(str) { var return_val; Book.Titles.forEach(function(data){ if(typeof data[str] != 'undefined') { return_val = data[str]; } }, str) return return_val; } book = findbystr('Book1'); console.log(book); </code></pre>
16,865,164
0
<p>Chrome (or any other browser) doesn't support HTAs at all. Actually HTAs are run by mshta.exe, and IE is used as a rendering &amp; scripting engine.</p> <p>When HTA is run with IE9 (<code>&lt;meta http-equiv="x-ua-compatible" content="IE=9"&gt;</code>) there are some issues with <code>&lt;HTA: application&gt;</code>, like some mess with <code>icon</code> and window borders.</p> <p>With IE10 (<code>&lt;meta http-equiv="x-ua-compatible" content="IE=edge"&gt;</code>) it seems, that HTA properties are ignored totally, even <code>singleInstance="yes"</code> doesn't work. If you take a look at a runtime source, you can see the <code>&lt;HTA: application&gt;</code> tag is moved to the <code>body</code>, where it has not the expected influence.</p> <p>All above written about IE is related to the actual HTA properties only, all HTML, scripts and privilegs work well. With IE10 even better and faster than ever before, and you can use real JavaScript instead of JScript.</p> <p>To utilize all available features, you need to add document type and <code>x-ua-compatible</code> to your pages:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta http-equiv="x-ua-compatible" content="IE=edge"&gt; ... </code></pre>
4,346,901
0
Suggestion for solving fragile pattern matching <p>I often need to match a tuple of values that should have the same constructor. The catchall <code>_,_</code> always winds-up at the end. This of course is fragile, any additional constructor added to the type will compile perfectly fine. My current thoughts are to have matches that connect the first but not second argument. But, is there any other options?</p> <p>For example,</p> <pre><code>type data = | States of int array | Chars of (char list) array let median a b = match a,b with | States xs, States ys -&gt; assert( (Array.length xs) = (Array.length ys) ); States (Array.init (Array.length xs) (fun i -&gt; xs.(i) lor ys.(i))) | Chars xs, Chars ys -&gt; assert( (Array.length xs) = (Array.length ys) ); let union c1 c2 = (List.filter (fun x -&gt; not (List.mem x c2)) c1) @ c2 in Chars (Array.init (Array.length xs) (fun i -&gt; union xs.(i) ys.(i))) (* inconsistent pairs of matching *) | Chars _, _ | States _, _ -&gt; assert false </code></pre>
15,846,265
0
Using break; in Struts1 <logic:iterate> <p>I am using Struts 1.2 for my Web Application. I am iterating through a garments collection and searching whether any of the garments price is greater than $1000 or not. If any of them satisfies the condition then no need to iterate through the remaining garments collection, simple break and come out of the iterator.</p> <p>For comparing the price, I am using , it is present inside the .</p> <p>I am not able to break out from the once the garment price condition is satisfied (i.e. >$1000).</p> <p>Kindly let me know how to break the iteration in struts 1.2.</p> <p>Regards,</p>
6,185,983
0
<p>The second argument to <a href="http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/search_002dforward.html" rel="nofollow"><code>search-forward</code></a> bounds the search, so to search for a string on the current line, go to the start of the line, and use the end of the line as your bound:</p> <pre><code>(beginning-of-line) (search-forward myword (line-end-position)) </code></pre> <p>If you don't want to move point, then use <a href="http://www.gnu.org/software/emacs/elisp/html_node/Excursions.html" rel="nofollow"><code>save-excursion</code></a> to preserve it:</p> <pre><code>(save-excursion (beginning-of-line) (search-forward myword (line-end-position))) </code></pre>
22,576,505
0
<p>Use the <code>replace</code> method:</p> <pre><code>function cap(str) { return str.replace(/([a-z])/, function (match, value) { return value.toUpperCase(); }) } </code></pre> <p><a href="http://jsfiddle.net/tewathia/LuF2e/" rel="nofollow">DEMO</a></p> <p><strong>Edit</strong>: In case you have a string containing multiple (space-separated) words, try something like:</p> <pre><code>function cap(str) { return str.split(' ').map(function (e) { return e.replace(/([a-z])/, function (match, value) { return value.toUpperCase(); }) }).join(' '); } </code></pre> <p>This would convert <code>"50newyork paris84 london"</code> to <code>"50Newyork Paris84 London"</code></p> <p><a href="http://jsfiddle.net/tewathia/LuF2e/1/" rel="nofollow">DEMO</a></p>
8,116,829
0
JSF 2.0 has Bean Validation (JSR 303) and also its own Validation Framework <p>JSF 2.0 has offered <code>Bean Validation</code> (JSR 303) and its own <code>Validation framework</code>, given the choices, i am confused with which one to choose from. </p> <p>It seems that with JSF's validation framework, i may specify constraints at the XHTML view layer. i.e. max length. While using Bean Validation, i would specify the constraints via annotations (@) in the bean.</p> <p>I see the JSF Validation framework as more of a plug-gable attempt, while the bean validation JSR as an elegant solution, can anyone comment on this?</p> <p>May i check if anyone has used one over another and why, or if anyone has used both together?</p>
17,511,761
0
<p>This one works for me very well. <code>(https?|ftp)://(www\d?|[a-zA-Z0-9]+)?\.[a-zA-Z0-9-]+(\:|\.)([a-zA-Z0-9.]+|(\d+)?)([/?:].*)?</code></p>
39,684,521
0
<p>Update your compateString method as follows:</p> <p>u need to compare each step of the id alone.</p> <pre><code>public static int compareString(String str1, String str2){ String subString = str1.substring(str1.indexOf("##")+3, str1.length()); String subString1 = str2.substring(str2.indexOf("##")+3, str2.length()); String[] array1 = subString.split("-"); String[] array2 = subString1.split("-"); for(int i=0;i&lt; array1.length &amp;&amp; i&lt; array2.length;i++) { BigInteger b1 = new BigInteger(array1[i]); BigInteger b2 = new BigInteger(array2[i]); if(b1.compareTo(b2) &gt;0) //b1 is larger than b2 return 1; if(b1.compareTo(b2) &lt;0) return -1; } if(array1.length == array2.length)//both numbers are equal return 0; if(array1.length &gt; array2.length) return 1; return -1; } </code></pre>
16,873,967
0
.htaccess URL rewrite works, but address bar then shows 'dirty' URL <ul> <li>User clicks link (from their email): <code>http://www.site.com/edit/wih293f73y</code></li> <li>Browser window opens and gets them to the correct page.</li> <li>But now the browser's address bar shows: <code>http://www.site.com/editor.php?editCode=wih293f73y</code></li> </ul> <p><strong>Extra info:</strong></p> <ul> <li>My rewrite rule is:<code>RewriteRule ^edit/([A-Za-z0-9-]+)/?$ editor.php?editCode=$1 [NC,L]</code></li> <li>This problem ONLY occurs when the user has clicked a link. It works perfectly when you just type the pretty url into the address bar.</li> <li>This problem <strong>ONLY occurs for links that include the <code>www.</code></strong> - the link <code>http://site.com/edit/wih293f73y</code> works like a charm.</li> <li>My .htaccess file includes the following code (from HTML5 boilerplate, which I wasn't aware of previously):</li> </ul> <blockquote> <pre><code># Rewrite www.example.com → example.com &lt;IfModule mod_rewrite.c&gt; RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] &lt;/IfModule&gt; </code></pre> </blockquote> <p>If it's important, this occurs after my other rewrite rules.</p>
37,984,296
0
<p>In the documentation, there is nowhere mentioned that it's possible to launch a Simulation directly from an Object's main method. For a very good reason: it's not!</p>
11,244,025
0
<p><code>Process.Start</code> will attempt to open the file in the computer it is running (the server).</p> <p>This is unlikely to be what you want. You should be uploading the file to the browser and let it decide (using <code>Response.WriteFile</code>, for instance).</p>
10,099,325
0
<p>Here is my list <em>(updated for 1.0)</em>:</p> <pre><code>// sending to sender-client only socket.emit('message', "this is a test"); // sending to all clients, include sender io.emit('message', "this is a test"); // sending to all clients except sender socket.broadcast.emit('message', "this is a test"); // sending to all clients in 'game' room(channel) except sender socket.broadcast.to('game').emit('message', 'nice game'); // sending to all clients in 'game' room(channel), include sender io.in('game').emit('message', 'cool game'); // sending to sender client, only if they are in 'game' room(channel) socket.to('game').emit('message', 'enjoy the game'); // sending to all clients in namespace 'myNamespace', include sender io.of('myNamespace').emit('message', 'gg'); // sending to individual socketid socket.broadcast.to(socketid).emit('message', 'for your eyes only'); </code></pre>
2,802,273
0
<ul> <li>Read the <a href="http://floating-point-gui.de/basic/" rel="nofollow noreferrer">Floating-Point Guide</a></li> <li><em>Never</em> use <code>double</code> or <code>float</code> for money amounts</li> <li>Use <code>BigDecimal</code> instead, that's exactly what it's for</li> </ul>
4,589,800
0
<p>join is faster</p> <pre><code>SELECT COUNT(comments.uid) FROM comments JOIN user_relationships ON user_relationships.requestee_id = comments.uid WHERE user_relationships.requester_id = $some_id </code></pre>
19,127,847
0
<p>Just use <a href="http://php.net/manual/en/function.print-r.php">print_r</a> :</p> <pre><code>echo '&lt;pre&gt;'; print_r ($myArray); echo '&lt;/pre&gt;'; </code></pre> <p>It will display information about your variable in a way that's readable by humans. can be used with arrays and objects.</p>
28,719,778
0
How to add PATH more than one values in Environment variable? <blockquote> <p>Is this correct way of adding PATH to env setup</p> </blockquote> <pre><code>C:\Program Files\Java\jdk1.7.0_71\bin;C:\Workspace\BS4SVN\BS4SVN-v.1.33.0\ant\bin;D:\Softwares\apache-maven-3.2.3\bin </code></pre>
10,316,217
0
How to see output in Amazon EMR/S3? <p>I am new to Amazon Services and tried to run the application in Amazon EMR.</p> <p>For that I have followed the steps as:</p> <p>1) Created the Hive Scripts which contains --> create table, load data statement in Hive with some file and select * from command.</p> <p>2) Created the S3 Bucket. And I load the object into it as: Hive Script, File to load into the table.</p> <p>3) Then Created the Job Flow (Using Sample Hive Program). Given the input, ouput, and script path (like s3n://bucketname/script.q, s3n://bucketname/input.txt, s3n://bucketname/out/). Didn't create out directory. I think it will get created automatically.</p> <p>4) Then Job Flow start to run and after some time I saw the states as STARTING, BOOTSTRAPING, RUNNING, and SHUT DOWN.</p> <p>5) While running SHUT DOWN state, it get terminated automatically showing FAILES status for SHUT DOWN.</p> <p>Then on the S3, I didn't see the out directory. How to see the output? I saw directory like daemons, nodes, etc......</p> <p>And also how to see the data from HDFS in Amazon EMR?</p>
19,045,469
0
javascript: null variable in function changes its value? <p>Can a null variable in a function become not null? When f enters in function chainF it somehow changes its value? It isn't null anymore.</p> <pre><code>function TestF(){} TestF.prototype = { i: 0, f: null, chainF: function(g){ if(this.f == null) console.log('f is null'); var newF = function(){ if(this.f == null) console.log('f is null'); g(); }; this.f = newF; return this; } } t = new TestF(); t.chainF(function(){console.log('g')}).f(); </code></pre> <p>Output: f is null (only once) g</p>
40,066,740
0
<p>There might be other problems in your snippet, so far I've noticed you're using <code>std::map</code> which is unusual data-structure for this purpose as <code>std::map</code> will overwrite previous <code>nodeId</code> with same <code>weight</code>. You can use <code>std::multimap</code> but you will need some more <code>std::iterator</code> and stuffs for looping on key-value pairs. Use <code>std::priority_queue</code> which will allow you to keep the code precise.</p> <p>Here is a simple snippet solution with <code>std::priority_queue</code> which calculate shortest distance from source to destination node. You can modify or write similarly for your problems:</p> <pre><code>#define Max 20010 // MAX is the maximum nodeID possible vector &lt;pair&lt;int, int&gt;&gt; adj[Max]; // adj[u] contains the adjacent nodes of node u int dis[Max]; // dis[i] is the distance from source to node i priority_queue &lt;pair&lt;int, int&gt;, vector&lt;pair&lt;int, int&gt; &gt;, greater&lt;pair&lt;int, int&gt; &gt; &gt; Q; int dijkstra(int src, int des) { memset(dis, MAX, sizeof dis); Q = priority_queue &lt;pair&lt;int, int&gt;, vector&lt;pair&lt;int, int&gt; &gt;, greater&lt;pair&lt;int, int&gt; &gt; &gt; (); dis[src] = 0; Q.push({dis[src] , src}); while(!Q.empty()) { int u = Q.top().second; Q.pop(); if(u == des) { return dis[des]; } for(int i = 0; i &lt; (int)adj[u].size(); ++i) { int v = adj[u][i].first; int cost = adj[u][i].second; if(dis[v] &gt; dis[u] + cost) { dis[v] = dis[u] + cost; Q.push({dis[v], v)}); } } } return -1; // no path found } </code></pre>
37,636,328
0
<p>Your function is not "returning" anything. It prints a value to stdout, and each invocation will do that.</p> <p>If you want to simulate a function return with this mechanism, you need to capture and resend the value:</p> <p>Bash functions return an exit status, and this works as you might expect (as long as you expect 0 to be success). If you don't specify otherwise, the return value is that of the last command. So the following would work:</p> <pre><code>tryn() { if (($1 == 0)); then return 2; fi "$@" || tryn $(($1-1)) "$@" } if tryn 2 ping $host; then # success fi </code></pre>
24,074,250
0
<pre><code>SKShapeNode *pathNode = [[SKShapeNode alloc] init]; pathNode.path = [self buildEnemyShipMovementPath:enemy]; pathNode.strokeColor = [SKColor redColor]; pathNode.lineWidth = 0.5f; pathNode.alpha = 0.4; pathNode.glowWidth = 5.f; [self addChild:pathNode] </code></pre>
8,369,922
0
<ul> <li><p>Doing it the way you describe will not do any harm.</p></li> <li><p>You can move the <code>.git</code> directory into the tree you want to commit instead of moving the tree to the repository.</p></li> <li><p>You can use the <code>--work-tree</code> option or <code>GIT_WORK_TREE</code> environment variable to act as if you did that:</p> <pre><code>git add --work-tree=CurrentProduction -A; git commit ... </code></pre> <p>Note that it is not necessary to specify it for commands after <code>add</code> since <code>add</code> copies content into the index, <code>commit</code> uses the index, and the index is in <code>.git</code>.</p></li> </ul> <p>As a separate issue, note that your procedure will make the <code>develop</code> initial commit a child of the <code>master</code> initial commit. That is probably the right thing for this case; I just want to make sure you're aware it's not symmetric.</p>
5,430,663
0
Adding observer to NSNotificationCenter second time causes EXC_BAD_ACCESS <p>Hypothetical scenario:</p> <p>In my <code>viewDidLoad</code> method I am adding view controller as an observer for custom notification (say, notification <code>MyFooNotification</code>). Later in the process when view is loaded the notification gets posted and controller processes it. When I leave the controller with it's view I DO NOT remove the observer (intentionally) in <code>viewDidUnload</code>. Next time when opening the view, the observer gets added again, but now when the observed notification gets posted - I get <code>EXC_BAD_ACCESS</code>.</p> <p>Can anyone explain why this is happenning.</p> <p>P.S. I do know that I should remove it in <code>viewDidUnload</code> I'm just curious about the lower level details.</p>
9,373,371
0
<p>In magento admin in </p> <pre><code>Catalog-&gt;Manage categories </code></pre> <p>Select category and choose preffered store view. There you should edit and save "URL key" parameter. </p> <p>In case it still shows old url - clean cache and make url rewrite reindex.</p>
2,452,577
0
<p><code>route</code> is part of the <code>bottle</code> module. </p> <p>The following should fix the problem</p> <pre><code>import bottle ... @bottle.route('/hello') def hello(): return "Hello World!" ... </code></pre>
4,784,699
0
<p>the whole thing can be changed to something like this for better readability...</p> <pre><code>&lt;?php $myradiooptions = array( "grid1" =&gt; "Grid View (default)", "list1" =&gt; "List View (1 column)", "list2" =&gt; "List View (2 column)" ); $value = array( "name" =&gt; "Category Layout", "desc" =&gt; "description goes here", "id" =&gt; "my_category_layout", "type" =&gt; "radio", "options" =&gt; $myradiooptions ); foreach($value as $key =&gt; $val) { $formHTML = "&lt;label class='left' for='{$value['id']}'&gt;".$value['name']."&lt;/label&gt;"; if(is_array($val)) { $count = 1; foreach($val as $k =&gt; $v) { $formHTML .= "&lt;input type='radio' name='{$v['id']}' id='$count' value='$v' /&gt;&lt;label style='color:#666; margin:0 20px 0 5px;' for='$count'&gt;$v&lt;/label&gt;"; $count ++; } } $formHTML .= "&lt;label class='description' style='margin-top:-5px;'&gt;".$value['desc']."&lt;/label&gt;"; } //switch, case "radio": ?&gt; &lt;li class="section"&gt; &lt;?php print $formHTML; ?&gt; &lt;/li&gt; </code></pre>
2,303,322
0
Custom form elements script <p>I am looking for a customized Form elements like RadioButton, Checkbox and Selectbox script. What do you suggest. (widthout using any framework please!)</p> <p>Thanks in advance.</p>
12,864,176
0
<p>You can do that with the date function. </p> <p><a href="http://php.net/manual/en/function.date.php" rel="nofollow">http://php.net/manual/en/function.date.php</a></p>
27,724,447
0
<p>...better is declare the name as varible ,and ask before if thereis a apostrophe in the string:</p> <p>e.g.:</p> <p>DIM YourName string</p> <p>YourName = "Daniel O'Neal"</p> <pre><code> If InStr(YourName, "'") Then SELECT * FROM tblStudents WHERE [name] Like """ Your Name """ ; else SELECT * FROM tblStudents WHERE [name] Like '" Your Name "' ; endif </code></pre>
10,737,728
0
NSPoint in NSBezierPath <p>I was wondering if there is any way to find out if an NSPoint is inside an NSBezierPath. Like:</p> <pre><code>NSPointInRect(aPoint,aRect) </code></pre> <p>But with a BezierPath.</p> <p>Thanks in advance, Ben</p>
26,192,170
0
Can I transfer my phone numbers from ringcentral into twilio? <p>I want to twilio and clicked on ask community and it brought me here.</p> <p>So, my question is, how can I transfer my phone numbers in Ring Central into Twilio?</p> <p>I called Ring Central, they said I can do it, but I have to start it at the other end with the company I want to transfer them to. But I don't know how to start it.</p> <p>Can someone please tell me?</p> <p>I have to do it fast because my billing at ring central is coming due in a few days.</p> <p>Thanks, Richard</p>
23,787,948
0
<p>Ignoring the fact that <code>eval</code> is probably super dangerous to use here (unless the data in <code>somefile</code> is controlled by you and only you), there are a few issues to fix in your example code.</p> <p>In your <code>for</code> loop, <code>alert_list</code> needs to be <code>$alert_list</code>.</p> <p>Also, as pointed out by @choroba, you should be using <code>!=</code> instead of <code>-ne</code> since your input isn't always an integer.</p> <p>Finally, while debugging, you can add <code>set -x</code> to the top of your script, or add <code>-x</code> to the end of your shebang line to enable verbose output (helps to determine how bash is expanding your variables).</p> <p>This works for me:</p> <pre><code>#!/bin/bash -x data=2.2 version=1 al_ap_version=('ap_version' '[[ $data != $version ]]') alert_list='al_ap_version' for alert in $alert_list; do condition=$(eval echo \${$alert[1]}) if eval "$condition"; then echo "alert" fi done </code></pre>
27,657,784
0
How to extract the result of a query from JSON inside a custom javascript function in OrientDB <p>I created a custom javascript function in the OrientDB Studio. The function takes a rid as an argument and performs a select query from that rid.</p> <pre><code>var graph = orient.getGraph(); var res = graph.command( "sql", "select outE('Rel').inV('B').size() as lower_num from " + rid ); </code></pre> <p>So, the result of this query is a number. Depending on the value of this number the function should do different things. I wonder how to extract and use that value from the res variable inside the function. All my attempts have failed so far.. If I return the res variable from the function, the result looks like this: </p> <pre><code>[ { "@type": "d", "@rid": "#-2:1", "@version": 0, "lower_num": 2 } ] </code></pre> <p>So, I tried the following <code>( res[0]['lower_num'] == 2 ); ( res['lower_num'] == 2 )</code> and nothing worked.. They always returned false. Any ideas?</p>
15,388,670
0
popup with bootstrap <p>how can i create a popup with MVC bootstrap?</p> <p>I have this code, when I click on "generate password" calls to a function (it´s in my controller Admin) and it returns me a string. How can i display the string in a popup window??</p> <pre><code>&lt;div class="editor-field" title="User Password"&gt; &lt;a class="btn btn-primary btn-small" href="#" onclick="location.href='@Url.Action("GeneratePsw", "Admin", null)'; return false;"&gt; &lt;i class="icon-lock icon-white"&gt;&lt;/i&gt; Generate password &lt;/a&gt; &lt;/div&gt; </code></pre>
27,343,787
0
<ol> <li>You should show us code of <code>scrap_and_save_product</code> function.</li> <li>Try to make more memory-efficient queries with large data. Details described <a href="http://www.poeschko.com/2012/02/memory-efficient-django-queries/" rel="nofollow">here</a>. Hope these helps!</li> </ol>
32,129,237
0
<p>Let's start by getting some terminology out of the way</p> <ul> <li>A <em>channel</em> is a monaural stream of samples. The term does not necessarily imply that the samples are contiguous in the data stream. </li> <li>A <em>frame</em> is a set of co-incident samples. For stereo audio (e.g. L &amp; R channels) a frame contains two samples.</li> <li>A <em>packet</em> is 1 or more frames, and is typically the minimun number of frames that can be processed by a system at once. For PCM Audio, a packet often contains 1 frame, but for compressed audio it will be larger. </li> <li><em>Interleaving</em> is a term typically used for stereo audio, in which the data stream consists of consecutive frames of audio. The stream therefore looks like L1R1L2R2L3R3......LnRn</li> </ul> <p>Both big and little endian audio formats exist, and depend on the use-case. However, it's generally ever an issue when exchanging data between systems - you'll always use native byte-order when processing or interfacing with operating system audio components. </p> <p>You don't say whether you're using a little or big endian system, but I suspect it's probably the former. In which case you need to byte-reverse the samples.</p> <p>Although not set in stone, when using floating point samples are usually in the range <code>-1.0&lt;x&lt;+1.0</code>, so you want to divide the samples by <code>1&lt;&lt;15</code>. When 16-bit linear types are used, they are typically signed.</p> <p>Taking care of byte-swapping and format conversions:</p> <pre><code>int s = (int) interleavedData[2 * i]; short revS = (short) (((s &amp; 0xff) &lt;&lt; 8) | ((s &gt;&gt; 8) &amp; 0xff)) left[i] = ((float) revS) / 32767.0f; </code></pre>
8,086,193
0
How to iterate over a formset in django? <p>This is my views.py: </p> <pre><code># Create your views here. def codepost(request): if request.method == 'POST': form=CodeFormSet(request.POST) if form.is_valid(): datan = "" for forms in form.ordered_forms: data = forms.cleaned_data['code'] datan = datan + data return render_to_response('submissiondone.html', {'data':datan}) else: form = CodeFormSet() data1=QuestionBase.objects.get(pk=1) #form.append(data1.text) #data1 = mform.text csrfContext = RequestContext(request) return render_to_response('quesdisp.html', {'form': form}) </code></pre> <p>This gives an addition ORDER field which I don't want. So, how do I iterate over a formset? If I remove the can_order = true from the formset, then it is not recognizing "code" as a valid input. </p> <p>Thus, how do I iterate over this? </p> <p>Edit: This is the formest part of my forms.py:</p> <pre><code>from django import forms from django.forms.formsets import formset_factory class CodeForm(forms.Form): code = forms.CharField(widget = forms.Textarea) CodeFormSet = formset_factory(CodeForm, extra = 5, ) </code></pre>
18,789,390
0
<p>Try like this:</p> <pre><code>action = getattr(me,command['action']) action(**{'a': 'Apple', 'b': 'Banana', 'args':['one','two','three','four'], 'foo':'spam', 'clowns':'bad', 'chickens':'good' }) </code></pre>
30,355,298
0
<p>did you try</p> <pre><code>meteor run --test </code></pre> <p>command? This is what <a href="https://github.com/meteor-velocity/velocity-ci" rel="nofollow">velocity-cli</a> creators are telling to do now.</p>
10,725,430
0
<p>As far as i know, there is no way to downgrade officially. apple does not allow to downgrade your iOS.</p>
28,800,715
0
<p>Try this updated regex:</p> <pre><code>(?&lt;=href\=\")[^&lt;]*?(?=\"&gt;\[link\]) </code></pre> <p>See <a href="https://www.regex101.com/r/pZ1gK9/1" rel="nofollow">demo</a>. The problem is that the dot matches too many characters and in order to get the right 'href' you need to just restrict the regex to <code>[^&lt;]*?</code>.</p>
28,452,436
0
How to add onclick dynamically in Jquery? <p>I have the following code:</p> <pre><code> obj2 = JSON.parse(ajax.responseText); for (var i = 0; i &lt;= obj2.length - 1; i++) { var row = table.insertRow(1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); var cell4 = row.insertCell(3); var cell5 = row.insertCell(4); var cell6 = row.insertCell(5); var cell7 = row.insertCell(6); var cell8 = row.insertCell(7); cell1.innerHTML = obj2[i].qid; cell2.innerHTML = obj2[i].question; cell3.innerHTML = obj2[i].answer1; cell4.innerHTML = obj2[i].answer2; cell5.innerHTML = obj2[i].answer3; cell6.innerHTML = obj2[i].answer4; $(function(){ var btn = document.createElement("BUTTON"); var t = document.createTextNode("Delete "+cell1.innerHTML); //this works well btn.appendChild(t); btn.className="menu_buttons"; $(btn).on('click' ,function(){ delete_(cell1.innerHTML);//this assigns the value of the last iteration to each button }); cell8.appendChild(btn); }); } </code></pre> <p>I'm iterating over a json array and I want to assign the same function (with different parameter, depending on an id from the array) to each button, and as I mentioned in the comment, it overwrites each button with the same parameter. What's wrong?</p>
5,814,130
0
<p>i have found the answer to my question. the solution was there lying in my question but at first i was not able to find it. solution was very simple when i wrote i want to use</p> <pre><code>UiApplication.getUiApplication().getActiveScreen() </code></pre> <p>that was almost the right way and i was proceeding in right direction but the thing that i was missing was " I was not casting the screen (that i have just retrieved form the stack top ) to its type only thing i should have done is "should have casted screen to its type.like this</p> <pre><code>UiApplication.getUiApplication().posScreen(this) (MyScreen1) UiApplication.getUiApplication().getActiveScreen() </code></pre> <p>now i am able to access all the fields on the retrieved screen (MyScreen1)</p> <p>things to keep in mind </p> <ol> <li>make sure u cast the screen to its type only otherwise bb will give u resource not found error</li> </ol> <p>Benifits of using screen on Stack</p> <ol> <li>u can use already created screen from the stack no need to create new one</li> <li>if u will create new screen it will be stacked in memory and will consume more and more memory even if its of no use ( make habit to pop the screen if it is of no use instead of leaving it on stack))</li> <li>no need to create any static variable since u will be able to set all the field right away from other screen</li> </ol>