pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
27,364,431
0
<p>You can use <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html#isDirectory%28%29" rel="nofollow"><code>File.isDirectory()</code></a> to test <em>whether the file denoted by this abstract pathname is a directory.</em> You can also use <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html#isFile%28%29" rel="nofollow"><code>File.isFile()</code></a> to test <em>whether the file denoted by this abstract pathname is a <strong>normal</strong> file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria.</em></p> <pre><code>File f = new File(fileName); if (f.isFile()) { // it's a file. } else if (f.isDirectory()) { // it's a directory. } </code></pre>
15,235,011
0
<p>Couple of ideas:</p> <ul> <li><p>If the rows in the text files have a modification timestamp, you could update your script to keep track of when it runs, and then only process the records that have been modified since the last run.</p></li> <li><p>If the rows in the text files have a field that can act as a primary key, you could maintain a fingerprint cache for each row, keyed by that id. Use this to detect when a row changes, and skip unchanged rows. I.e., in the loop that reads the text file, calculate the SHA1 (or whatever) hash of the whole row, and then compare that to the hash from your cache. If they match, the row hasn't changed, so skip it. Otherwise, update/insert the MySQL record and the store the new hash value in the cache. The cache could be a GDBM file, a memcached server, a fingerprint field in your MySQL tables, whatever. This will leave unchanged rows untouched (and thus still cached) on MySQL.</p></li> <li><p>Perform updates inside a transaction to avoid inconsistencies.</p></li> </ul>
4,064,564
0
<p>Not really sure what the issue is here, sounds pretty simple though. I guess I'll add my 2 cents. First, unless youre looking for perform Inserts, Updates, or Deletes for these work times, I think a database is overkill for this.. look at using XML instead.</p> <p>Secondly, ASP.NET offers some pretty simple controls to display data like this. Check out the ASP.NET Repeater Control, which allow you to create a formatted header and footer, and repeate a templated item layout. Its pretty fast and effective, and definately in line for what youre looking for here.</p> <p>Best of luck</p>
3,423,974
0
How to convert char * to a System::string ^ <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/56561/what-is-the-best-way-to-convert-between-char-and-systemstring-in-c-cli">What is the best way to convert between char* and System::String in C++/CLI</a> </p> </blockquote> <p>Hello, I have a function in a c++ project using \clr something like:</p> <pre><code>int WINAPI dmtTest(char *pcertificate) { String^ sCertificate; sCertificate = pcertificate; // how can I assign pcertificate to sCertificate? .... } </code></pre>
40,381,215
0
Laravel 5.3 npm gulp not creating output files <p>I am using Laravel 5.3, node version: 5.7 and npm version: 3.6.</p> <p>When I run the <code>gulp</code> (or even <code>gulp watch</code>) command I get the same output in terminal as I normally get, everything looks like it should, and it even tells me that it has written to the public/css folder <em>(image below)</em>. Navigating to the folder I can see no changes were made to the previous app.css file.<br> When I delete the file, the css directory remains empty after the gulp commands. </p> <p>This is my gulpfile.js</p> <pre><code>const elixir = require('laravel-elixir'); require('laravel-elixir-vue-2'); elixir(mix =&gt; { mix.sass('app.scss') .webpack('app.js'); }); </code></pre> <p>This is the output I get in the terminal (iTerm on mac OSX): <a href="https://i.stack.imgur.com/8kMlg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8kMlg.png" alt="enter image description here"></a></p> <p>But lik I said, the public folder remains empty. I can't tell for sure that I updated node or npm or not.. But I don't think I have. </p> <p>Thanks for the help.</p> <hr> <p><strong>EDIT:</strong> deleting the <code>node-modules</code> folder and running <code>npm install</code> again gives another error.. One I have never seen before: <a href="https://i.stack.imgur.com/ecvG0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ecvG0.png" alt="enter image description here"></a></p>
5,637,642
0
Need help understanding how to version an iOS app <p>In Xcode I have <code>Bundle Version</code> and <code>Bundle Version string, short</code>. There is also a version in iTunes Connect. Just trying to see what I should use for each one and which one iOS uses to determine the version of the app so that a newer version properly replaces and older version.</p>
19,115,225
0
<p>See this example: <a href="http://www.overpie.com/css/articles/css-vertical-fly-out-menu" rel="nofollow">http://www.overpie.com/css/articles/css-vertical-fly-out-menu</a></p> <p>I would recommend not to use line-height, as if you have long text, you will have trouble. </p>
23,674,649
0
How to embed youtube channel with thumbnails with over 4000 videos <p>I am trying to embed a youtube channel onto a website with thumbnails for customer, but it tells me that i can only embed up to 500 videos.</p> <p>The channel has over 4000 videos and need them all embedded!</p> <p>Is this possible?</p> <p>Hope to hear from someone soon!</p> <p>Jordan</p>
24,034,942
0
Windows Azure: importing data from Excel sheet? <p>I have a Windows Azure mobile service with a sql database.</p> <p>I was wondering if it's possible to insert records from an excel sheet to an azure database table.</p> <p>in other words, I have an excel sheet with many data records, I want to export the records to a database table.</p> <p>is there any tool/service/SDK that provides this ?</p>
27,841,834
0
pattern recognition in a time series <p>I understand that the question I am asking seem the be somewhat related to another question which has been asked already <a href="http://dsp.stackexchange.com/questions/966/pattern-recognition-for-temporal-data">here</a> and <a href="http://stackoverflow.com/questions/11752727/pattern-recognition-in-time-series">here</a>. </p> <p>But I feel that this is an entirely different question. (I have also <a href="http://dsp.stackexchange.com/questions/19896/pattern-recognition-in-a-time-series">submitted this question</a> on the dsp.stackexchange)</p> <p>I have a huge (over 100K data points) time series data of the position (x, y coordinates) of an element in space. This element is vibrating randomly, and both amplitude and the frequency of vibration is random. I want to look at the events which are similar and see if there is any pattern in those events, are they periodic or related somehow.</p> <p>I am working on a biological problem and have very little knowledge about signal processing. I can provide more details. Any help would be really appreciated.</p>
39,929,812
0
How to Run Code at iOS 10 Local Notification Runtime <p>I'm trying to schedule a local notification with a different attachement each day, however the code to find the correct daily attachment seems to run at notification creation rather than runtime, how do I set it to run at runtime. </p> <p>//Setup</p> <pre><code>print("Value of Consts: \(Consts.isGrantedNotificationAccess)") if Consts.isGrantedNotificationAccess { let center = UNUserNotificationCenter.current() center.removeAllPendingNotificationRequests() center.removePendingNotificationRequests(withIdentifiers:[dayRequest]) let content = NotificationContent(title: "Daily Reminder", subTitle: " ", body: " ") let name = Helpers.getImageName() guard let url = Helpers.saveImage(name: "\(name).png") else { print("Error not URL") return } let attachment = try? UNNotificationAttachment(identifier: Consts.imageIdentifier, url: url, options: [:]) if let attachment = attachment { content.attachments.append(attachment) } let hour = DatePicker.calendar.component(.hour, from: DatePicker.date) let minute = DatePicker.calendar.component(.minute, from: DatePicker.date) var dateComponents = DateComponents() dateComponents.hour = hour dateComponents.minute = minute let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true) //set the request let request = UNNotificationRequest(identifier: dayRequest, content: content, trigger: trigger) //add the notification UNUserNotificationCenter.current().add(request) { error in UNUserNotificationCenter.current().delegate = self if (error != nil){ //handle here print(error) } } self.dismiss(animated: true, completion: nil) } </code></pre> <p>The Helper.getImageName() returns an image name based on the date, now the current notification shows the same image each day, as the code runs at notification creation, is there any way to make the code run at notification runtime?</p>
38,031,842
0
<p><strong>In short, the less work you do in the <code>onBindViewHolder()</code> method, the better the performance of your list view scrolling.</strong></p> <p>The most efficient implementation would simply take the data from the model that is passed and simply set it to the view holder.</p> <p>Since all of this work in the <code>onBindViewHolder()</code> method is done on the UI thread, offloading any additional work either prior to the binding or offloaded to anthoer thread is beneficial to list view performance.</p> <p><strong>For example</strong>, lets say that you have a list that contains a bunch of tasks as below:</p> <pre><code>class Task { Date dateDue; String title; String description; // getters and setters here } </code></pre> <p>Each task has a title, description and a due date associate with it. As a requirement for your app, if the today's date is before the due date, the row should be green and if passed the due date, it should be red. Also the <code>Task</code> object associated with it requires some special date formatting before setting it to the view.</p> <p>There are two things that will be done in this <code>onBindViewHolder()</code> as each row is rendered onto the screen:</p> <ul> <li>You will need to conditionally check each date and compare it against today's date</li> <li>You will need to apply a date formatter to get the view the date in the required specification:</li> </ul> <p>e.g.</p> <pre><code>class MyRecyclerView.Adapter extends RecyclerView.Adapter { static final TODAYS_DATE = new Date(); static final DATE_FORMAT = new SimpleDateFormat("MM dd, yyyy"); public onBindViewHolder(Task.ViewHolder tvh, int position) { Task task = getItem(position); if (TODAYS_DATE.compareTo(task.dateDue) &gt; 0) { tvh.backgroundView.setColor(Color.GREEN); } else { tvh.backgroundView.setColor(Color.RED); } String dueDateFormatted = DATE_FORMAT.format(task.getDateDue()); tvh.dateTextView.setDate(dueDateFormatted); } } </code></pre> <p>In the above, for every row that is rendered, a date comparison is being made. While we were at it, we even took the liberty to make today's date a constant – object creation is possibly one of the most expensive things you can do in a <code>onBindViewHolder()</code> so any optimization is appreciated. Additionally, the date that is passed in the <code>Task</code> object was not in the proper format so it is formatted that on-the-fly as well.</p> <p>Although this example is <em>trivial</em>, this can quickly balloon into halting the list view scrolling to a crawl. The better way of doing this is to pass an intermediary object, such as a <em>view model</em> that represents the state of the view instead of the actual business model instead.</p> <p>Instead of passing your <code>Task</code> as the model to the adapter, we create an intermediatary model called <code>TaskViewModel</code> that is created and set to the adapter. Now before setting any information is sent to the adapter, all of the work is done before any view rendering is applied. This comes at the cost of longer initialization time prior to sending data to your <code>RecyclerView</code> but at the better trade-off of list view performance.</p> <p>This view model instead could be:</p> <pre><code>public class TaskViewModel { int overdueColor; String dateDue; } </code></pre> <p>Now when tasked to bind the data to the view, we have the actual view state being represented in the view model and our UI thread can continue to be jank free.</p> <pre><code>public onBindViewHolder(Task.ViewHolder tvh, int position) { TaskViewModel taskViewModel = getItem(position); tvh.backgroundView.setColor(taskViewModel.getOverdueColor()); tvh.dateTextView.setDate(taskViewModel.getDateDue()); } </code></pre>
8,220,000
0
<p>You should take a different approach here. Instead of trying to "cancel" the behavior you already applied, why not just use it only in browsers where you need it? Wich means taking it out of your main.css file and only using it like this:</p> <pre><code>&lt;!--[if IE 8]&gt; &lt;style&gt; Here goes all your behavior calls : some_selector { behavior: url(PIE.htc); } &lt;/style&gt; &lt;![endif]--&gt; </code></pre> <p>That way you won't need to overwrite them anywhere else, they will only be applied in IE 8.</p>
18,562,511
0
g++ Internal compiler error in small program <p>I am writing a small program to solve Project Euler <a href="https://projecteuler.net/problem=21" rel="nofollow">Problem 21</a>, and I was testing out the early parts of my code when I ran into an unexplained internal compiler error. I'd appreciate any tips on how to re-write my program to avoid this kind of error.</p> <p>Here's my build command and compiler options:</p> <pre><code>g++ -std=c++11 -O2 -Wall -o "pe_021" "pe_021.cc" </code></pre> <p>Here's the error that I get:</p> <pre><code>Internal compiler error: Error reporting routines re-entered. Compilation failed. </code></pre> <p>Here's my code:</p> <pre><code>#include &lt;array&gt; #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;vector&gt; using namespace std; const unsigned int N = 10000; //look for amicable numbers smaller than N vector&lt;unsigned int&gt; list_of_primes; vector&lt;unsigned int[2]&gt; prime_factorize(unsigned int); int main(int argc, char **argv) { //import a list of primes ifstream ifs ("primes_10000.txt"); for (unsigned int index = 0; index &lt; N; index++) { string prime_number; getline(ifs, prime_number); list_of_primes.push_back(stoi(prime_number)); } ifs.close(); //test prime factorization function by prime factorizing 12 vector&lt;unsigned int[2]&gt; prime_factorization = prime_factorize(12); for(unsigned int (&amp;prime_and_exponent)[2] : prime_factorization) { cout &lt;&lt; prime_and_exponent[0] &lt;&lt; ", " &lt;&lt; prime_and_exponent[1] &lt;&lt; endl; } return 0; } vector&lt;unsigned int[2]&gt; prime_factorize(unsigned int number) { vector&lt;unsigned int[2]&gt; prime_factorization; for(unsigned int index = 1; index &lt; list_of_primes.size(); index++) { if(number % list_of_primes[index] == 0) { unsigned int prime_and_exponent[2] = {list_of_primes[index], 1}; prime_factorization.push_back(prime_and_exponent); number /= list_of_primes[index]; while(number % list_of_primes[index] == 0) { prime_factorization.back()[1]++; number /= list_of_primes[index]; } } if(number == 1) { break; } } return prime_factorization; } </code></pre>
33,610,688
0
Deploying Activiti workflow to OSGI(Felix) <p>I have developed a activiti workflow, I am trying to call the workflow through the code from an OSGI bundle but it gives the dependency errors. What would be the correct way to deploy the workflow into OSGI container?</p>
5,376,186
0
Should browsers automatically fetch images when src is dynamically redefined, w/o ajax? <p>I've noticed that when an image source attribute is dynamically changed (in my case, using jQuery), even if the image has never been called/cached by the browser (i.e. not pre-loaded), the browser still fetches it -- and without ajax. This has been working for me in all 5 major browsers (ie7+).</p> <p>Question: Is this a formally standardized behavior that I could rely on, indefinitely?</p>
40,333,401
0
<p>I copy/pasted your code in my IDE and ran but no problem here! so it's very strange that when you create object B, you get error that object A method (a::helloB()) does'n exist! If you put whole codes (inclusive dbData) i am willing to try it again.. </p>
23,617,667
0
<p>I'm not sure how you're expecting it to work, but I modified your HTML and JS to get something that I think works how you want: </p> <pre><code>&lt;ul id="accordion"&gt; &lt;li&gt; &lt;div style="background-color: rgb(109, 129, 27);" class="expand" title="Click to Expand"&gt;Zoos &lt;ul class="sortCat1" id="zoo"&gt; &lt;li id="1"&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt; &lt;li id="2"&gt;&lt;a href="#"&gt;2&lt;/a&gt;&lt;/li&gt; &lt;li id="3"&gt;&lt;a href="#"&gt;3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div style="background-color: rgb(109, 129, 27);" title="Click to Expand" class="expand"&gt;Attractions &lt;ul class="sortCat2" id="attractions"&gt; &lt;li id="1"&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt; &lt;li id="2"&gt;&lt;a href="#"&gt;2&lt;/a&gt;&lt;/li&gt; &lt;li id="3"&gt;&lt;a href="#"&gt;3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div style="background-color: rgb(109, 129, 27);" title="Click to Expand" class="expand"&gt;Dining &amp;amp; Shopping &lt;ul class="sortCat3" id="dinShop"&gt; &lt;li id="1"&gt;&lt;a href="#"&gt;1&lt;/a&gt;&lt;/li&gt; &lt;li id="2"&gt;&lt;a href="#"&gt;2&lt;/a&gt;&lt;/li&gt; &lt;li id="3"&gt;&lt;a href="#"&gt;3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p></p> <pre><code>$(".expand").each(function() { if($('ul', this).attr('id') != "attractions") { $(this).css({'display': 'none'}); } }); </code></pre>
37,226,802
0
<ol> <li><p>Use repmat in order to concat 3 copies of your matrix horizontally.</p></li> <li><p>Use the Matlab's assignment syntax: A(row,col:col+length(x)-1) in order to copy x into the desired row and col.</p></li> </ol> <p>Code example:</p> <pre><code>outA = repmat(A,1,3); %replicate A outA(2,1:length(x)) = x; %inserts x into the beginning of the 2nd row outA(4,size(outA,2)-length(x)+1:end) = x; %inserts x into the end of the 4th row </code></pre> <p>Results:</p> <pre><code>outA = 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 3.1 4.2 1.1 7.4 5.6 2.2 1.3 3.1 4.2 1.1 7.4 5.6 2.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 </code></pre>
38,391,048
0
<p>Just change this part of code to format table instead just bold text:</p> <pre><code>... var html = "&lt;table&gt;"; html += "&lt;thead&gt;&lt;tr&gt;&lt;th&gt;UID&lt;/th&gt;&lt;th&gt;First Name&lt;/th&gt;&lt;th&gt;Last Name&lt;/th&gt;&lt;th&gt;Email&lt;/th&gt;&lt;th&gt;Username&lt;/th&gt;&lt;th&gt;Password&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;"; html += "&lt;tbody&gt;"; for(var i = 0; i &lt; data.length; i++){ html += "&lt;tr&gt;"; var uid = data[i].uid; var firstname = data[i].firstname; var lastname = data[i].lastname; var email = data[i].email; var username = data[i].username; var password = data[i].password; html += "&lt;td&gt;"+uid+"&lt;/td&gt;&lt;td&gt;"+firstname+"&lt;/td&gt;&lt;td&gt;"+lastname+"&lt;/td&gt;&lt;td&gt;"+email+"&lt;/td&gt;&lt;td&gt;"+username+"&lt;/td&gt;&lt;td&gt;"+password+"&lt;/td&gt;&lt;/tr&gt;"; } html +="&lt;/tbody&gt;&lt;/table&gt;"; ... </code></pre>
5,717,228
0
<p>Check the javadoc for the <code>set</code> method. You'll see the following:</p> <blockquote> <p>Parameters:</p> <p>year - the value used to set the YEAR calendar field.</p> <p>month - the value used to set the MONTH calendar field. Month value is 0-based. e.g., 0 for January.</p> <p>date - the value used to set the DAY_OF_MONTH calendar field.</p> </blockquote> <p>So your code should become the following:</p> <pre><code>private static int getWeekOfYear(int y, int m, int d) { Calendar cal = Calendar.getInstance(); cal.setMinimalDaysInFirstWeek(4); cal.set(y, m - 1, d); // Note the change here return cal.get(Calendar.WEEK_OF_YEAR); } </code></pre>
39,925,758
0
Getting duplicate rows on subquery <p>So this has been bothering me for some time because I feel like in MSSQL this query would run just fine but at my new job I am forced to use Oracle. I have a subselect in a query where I want to find all of the people not assigned to a survey. My query is as follows:</p> <pre><code>Select distinct * From GetAllUsers, getperms Where id not in (getperms.users) and Survey_ID = '1' </code></pre> <p>If there are three users in the getperms table I get three rows for each person in the the GETALLUsers table.</p> <p>I guess I could do some kind of join and that's no problem, it's just really bothering me that this doesn't work when i think that it should.</p>
9,376,341
0
how to tag people in a facebook album via the graph API (php) <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3017861/how-can-i-tag-a-user-in-a-photo-using-the-facebook-graph-api">How can I tag a user in a photo using the Facebook Graph API?</a> </p> </blockquote> <p>As title says, how can i tag people via the Facebook graph API on an existing album?</p>
39,269,948
0
<p>The shell builtin <code>kill</code> or the external one <code>/bin/kill</code> does not take Process ID (or Job ID) via standard input stream. You need to pass them as argument to <code>kill</code>, so:</p> <pre><code>kill -- $(&lt;ff) </code></pre> <p>should do.</p> <p>If you want to kill them one by one and doing something in between, you can create an array with the pids and iterate over them:</p> <pre><code>pids=( $(&lt;file.txt) ) &amp;&amp; for i in "${pids[@]}"; do echo "killing $i"; kill -- "$i"; done </code></pre>
9,553,619
0
<p>A very simple way would be to change the Flash movie in this manner:</p> <p>When the movie loads (in the load listener in AS), add this</p> <pre><code>if(ExternalInterface.available) { ExternalInterface.call(flashReady); } </code></pre> <p>and in the javascript, have a function called flashReady which does the thing it needs to</p> <pre><code>function flashReady() { //Your awesome function body here } </code></pre>
22,497,591
0
<p>That's a huge file to be importing through PHP (which in turn forces resource limits upon phpMyAdmin); if you have command-line access I highly recommend loading it through the <code>mysql</code> command line tool. If you don't, try using the phpMyAdmin <a href="http://docs.phpmyadmin.net/en/latest/config.html#cfg_UploadDir" rel="nofollow">UploadDir function</a> or see these <a href="http://docs.phpmyadmin.net/en/latest/faq.html#i-cannot-upload-big-dump-files-memory-http-or-timeout-problems" rel="nofollow">other suggestions</a>.</p>
35,055,284
0
<p>Closing curly bracket <code>}</code> is misplaced to bottom for function <code>volcano_theme_options()</code>. Check and fix that.</p>
25,148,732
0
<p>I tried your initial way <em>with</em> the following:</p> <pre><code>use strict; use warnings; use Time::Piece; my $time = Time::Piece-&gt;strptime( "07/26/2014 00:23:09", "%m/%d/%Y %H:%M:%S"); print $time; </code></pre>
23,083,876
0
<p>You can attach session with socket and get in <code>connection</code> event. Get the user session in <code>authorization</code>, if you're using express then do this:</p> <pre><code>var sessionStore = new express.session.MemoryStore(); io.set('authorization', function (handshake, accept){ var cookies = require('express/node_modules/cookie').parse(handshake.headers.cookie); var parsed = require('express/node_modules/connect/lib/utils').parseSignedCookies(cookies, 'SESSION_SECRET'); sessionStore.get(parsed.sid, function (error, session){ if (session != null &amp;&amp; session.user != null){ accept(null, true); handshake.session = session; } }); }); </code></pre> <p>And in your connection event you can get it like:</p> <pre><code>socket.handshake.session </code></pre>
12,506,902
0
<p>This is definitely a bug but I found a work around. You aren't going to like this but at least it will get your web app working again. You need to examine the User Agent header and if it contains "iPhone OS 6" then do not use:</p> <pre><code>&lt;meta content="yes" name="apple-mobile-web-app-capable" /&gt; </code></pre> <p>Yes, this means that it won't be a true web app and you will get the Safari header and footer bars. But at least it will make your app work again from the home screen. You can see how this works by going to my site <a href="http://www.nextbus.com">www.nextbus.com</a>.</p> <p>Note that it appears that Google ran into this problem. Try going to <code>maps.google.com</code> and then adding the web app to your homescreen. The geolocation will work for it but you will indeed see the ugly Safari header and footer bars.</p> <p>Please complain loudly to Apple!</p>
23,164,628
0
<p>Your UI elements in Fragment_Main.xml. You get NullPointerException because you set activity_main.xml as layout for MainActivity: <code>setContentView(R.layout.activity_main);</code>. Move the layout from Fragment_Main.xml to activity_main.xml.</p>
25,335,577
0
<p>The function is marked <code>const</code>, so the developer used a rather ugly <code>const_cast</code> to cast the const away in order to call <code>sort</code>.</p> <p><code>ASSERT</code> appears to be a macro (due to it being in capital letters) that most likely calls <a href="http://www.cplusplus.com/reference/cassert/assert/" rel="nofollow">assert</a>, which terminates the program if the expression evaluates to zero.</p> <p>For a summary of what <code>trimmed mean</code> means, refer to this <a href="http://www.d.umn.edu/~yqi/stat3611/trimmed.pdf" rel="nofollow">page</a>.</p> <blockquote> <p>The 10% trimmed mean is the mean computed by excluding the 10% largest and 10% smallest values from the sample and taking the arithmetic mean of the remaining 80% of the sample ...</p> </blockquote>
38,577,775
0
<p>from the bootstrap official site (and, almost, like Eric S. Bullington said.</p> <p><a href="https://getbootstrap.com/components/#navbar-default" rel="nofollow">https://getbootstrap.com/components/#navbar-default</a></p> <p>the example navbar looks like:</p> <pre><code>&lt;nav class="navbar navbar-default"&gt; &lt;div class="container-fluid"&gt; &lt;!-- Brand and toggle get grouped for better mobile display --&gt; &lt;div class="navbar-header"&gt; ...etc </code></pre> <p>to center the nav, that what i've done:</p> <pre><code>&lt;div class="container-fluid" id="nav_center"&gt; </code></pre> <p>css:</p> <pre><code>@media (min-width:768px) { /* don't break navbar on small screen */ #nav_center { width: 700px /* need to found your width according to your entry*/ } } </code></pre> <p>work with class="container" and navbar-right or left, and of course you can replace id by class. :D</p>
18,219,072
0
Using MigLayout, how can I make JPanel appear <p>I have this ridiculously simple code (actually directly copied from the miglayout white paper: <a href="http://www.miglayout.com/whitepaper.html" rel="nofollow">http://www.miglayout.com/whitepaper.html</a>). I added the panel.setVisible(true) at the end. The problem is, with or without that last line, nothing shows up.</p> <pre><code>MigLayout layout = new MigLayout("fillx", "[right]rel[grow,fill]", "[]10[]"); JPanel panel = new JPanel(layout); panel.add(new JLabel("Enter size:"), ""); panel.add(new JTextField(""), "wrap"); panel.add(new JLabel("Enter weight:"), ""); panel.add(new JTextField(""), ""); panel.setVisible(true); </code></pre>
32,209,778
0
Passing information to server-side function in a Google Docs Add On <p>I'm working on a Google Docs Add-On based on Google's <a href="https://developers.google.com/apps-script/quickstart/docs" rel="nofollow">Quickstart tutorial</a>. I'm trying to change the workflow of the Add On in the tutorial to append a new page and then insert a translation on that new page rather than the line-by-line workflow.</p> <p>I have a script working in single documents but I'm having a hard time moving it to the Add On architecture. I think it's something to do with passing selections from client-side JS to the server-side script doing the translation.</p> <p><strong>Here's the translate script</strong></p> <pre><code>function translate(origin, dest, savePrefs) { Logger.log('Starting the script'); if (savePrefs == true) { var userProperties = PropertiesService.getUserProperties(); userProperties.setProperty('originLang', origin); userProperties.setProperty('destLang', dest); Logger.log(origin,dest); } var doc = DocumentApp.getActiveDocument(); var body = doc.getBody(); // Add a page break for the translated material. body.appendPageBreak(); // Get the number of elements in the document var elements = body.getNumChildren(); Logger.log('Got the page elements'); // Use the number to loop through each element in the document. for( var i=0;i&lt;elements;i++) { var element = body.getChild(i).copy(); var type = element.getType(); Logger.log('Element Types were successful. Starting tests.'); // Test each type for a child element and run script based on the result // Images are nested in a paragraph as a child, so the second `if` makes // sure there is no image present before moving to the next paragraph. if( type == DocumentApp.ElementType.PARAGRAPH ){ if(element.asParagraph().getNumChildren() != 0 &amp;&amp; element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_IMAGE) { var img = element.asParagraph().getChild(0).asInlineImage().getBlob(); body.appendImage(img); } else if(element.asParagraph().getNumChildren() !=0 &amp;&amp; element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) { var drawing = element.asParagraph().copy(); body.appendParagraph(drawing); } else { var text = element.asParagraph().getText(); Logger.log(text); var spn = LanguageApp.translate(text, origin, dest); body.appendParagraph(spn); } } else if(type == DocumentApp.ElementType.TABLE) { element.asTable().copy(); body.appendTable(element); } else if(type == DocumentApp.ElementType.LIST_ITEM) { var list = element.asListItem().getText(); body.appendListItem(LanguageApp.translate(list, origin, dest)); } } </code></pre> <p><strong>The client-side JS is:</strong></p> <pre><code>$(function() { $('#run-translation').click(loadPreferences); google.script.run(runTranslation) }); function runTranslation() { this.disabled = true; var origin = $('input[name=origin]:checked').val(); var dest = $('input[name=dest]:checked').val(); var savePrefs = $('#save-prefs').is(':checked'); google.script.run .runTranslation(origin, dest, savePrefs); } </code></pre> <p>If I hard-code the languages to use in translation into the server-side script, it works. But as soon as I try to use variables from the radio buttons, it doesn't run. I don't see any errors in the console and I can't run scripts from the editor to check the logs. How can I debug this code?</p>
32,125,683
0
<p>I was able to create reverse proxies by clicking on <strong>Site</strong>, <strong>URL Rewrite</strong>, <strong>Add Rule</strong> and <strong>Reverse Proxy</strong>. </p>
5,370,594
0
Highly customizable Listview for .Net? <p>do you guys know a .net ListView-Replacement which can be highly customized? I am developing an app which is similar to a "todo" list. I want to be able to customize almost every visual detail of the list so I get something like this:</p> <p><img src="https://i.stack.imgur.com/z9YYd.jpg" alt="ListView"></p> <p>I want also to be able to reorder items by mouse + I need drag&amp;drop. If you don't know any ListView, maybe you know how I could make my own listview like this one from scratch?</p> <p>Thanks for your ideas!</p>
221,519
0
Linq to XML 'Where not in' syntax problem <p>The following Code does not compile</p> <pre><code>Dim BasicGroups As String() = New String() {"Node1", "Node2"} Dim NodesToRemove = From Element In SchemaDoc.Root.&lt;Group&gt; _ Where Element.@Name not in BasicGroups For Each XNode In NodesToRemove XNode.Remove() Next </code></pre> <p>It is supposed to Remove any Immediate child of the rootnode which has an attribute called name whose value is <strong>Not</strong> listed in the BasicGroups StringArray.</p> <p><strong>What is the correct syntax for this task?</strong></p>
27,797,987
0
Exporting am chart on server <p>i am using grails , i need to put <a href="http://www.amcharts.com/demos/simple-column-chart/" rel="nofollow">amchart</a> in my pdf(using iText ) report. chart is created on browser. is there any way . to generate chart as image . so that i put that chart in my pdf.</p>
11,929,092
0
jQuery UI autocomplete filter data <p>I am new to jquery and I was assigned to filter out the list once the item is already selected. There are 3 textboxes that uses the autocomplete. </p> <p>source: apple, orange, mango</p> <p>textbox 1 = apple textbox 2 = apple should be filtered out in the list. it should only display orange and mango.</p> <p>I was able to filter the source but the list still display the item. But the source gets updated once I refresh the page. I have found this question, here's <a href="http://stackoverflow.com/questions/4699307/jquery-ui-autocomplete-refresh-data">a link</a> but in my case instead of adding, i wanted to filter it out.</p> <p>Any help is appreciated.</p> <p>Thanks! Zel </p>
6,791,945
0
<p>Here's a recursive function that will indent:</p> <p>(<strong>Edited</strong>: Indentation wasn't working properly for all subelements, now it does)</p> <pre><code>function arrayPrettyPrint($arr, $level) { foreach($arr as $k =&gt; $v) { for($i = 0; $i &lt; $level; $i++) echo("&amp;nbsp;"); // You can change how you indent here if(!is_array($v)) echo($k . " =&gt; " . $v . "&lt;br/&gt;"); else { echo($k . " =&gt; &lt;br/&gt;"); arrayPrettyPrint($v, $level+1); } } } $arr = array( 1, 2, 3, array( 4, 5, array( 6, 7, array( 8 ))) ); arrayPrettyPrint($arr, 0); </code></pre>
20,672,761
0
<p>if your string is converted to md5 string, you never get it back anymore, but you can try the md5 decrypter on the web but it doesn't 100% work as expected. try to reset with new password, i think it's more secure.</p>
11,478,687
0
<p>You should add the mouse listener to the JScrollPane's view instead of to the scroll pane itself, since the scroll pane consists of only corners and scroll bars.</p> <pre><code>yourJScrollPane.getViewport().getView().addMouseListener(yourMouseListener); </code></pre> <p>This code segment will add your mouse listener to the JScrollPane's one viewport component.</p>
5,386,795
0
How to safely save data to an existing file with C#? <p>How do you safely save data to a file that already exists in C#? I have some data that is serialized to a file and I'm pretty sure is not a good idea to safe directly to the file because if anything goes wrong the file will get corrupted and the previous version will get lost.</p> <p>So this is what I've been doing so far:</p> <pre><code>string tempFile = Path.GetTempFileName(); using (Stream tempFileStream = File.Open(tempFile, FileMode.Truncate)) { SafeXmlSerializer xmlFormatter = new SafeXmlSerializer(typeof(Project)); xmlFormatter.Serialize(tempFileStream, Project); } if (File.Exists(fileName)) File.Delete(fileName); File.Move(tempFile, fileName); if (File.Exists(tempFile)) File.Delete(tempFile); </code></pre> <p>The problem is that when I tried to save to a file that was in my <a href="http://www.dropbox.com">Dropbox</a>, sometimes I got an exception telling me that it cannot save to a file that already exists. Apparently the first <code>File.Delete(fileName);</code> didn't delete the file right away but after a little bit. So I got an exception in the <code>File.Move(tempFile, fileName);</code> because the file existed and then the file got erased and my file got lost. </p> <p>I've used other applications with files in my Dropbox and somehow they manage to not mess it up. When I'm trying to save to a file in my Dropbox folder, sometimes I get a message telling me that the file is being used or stuff like that but I never had a problem with a file being erased.</p> <p>So what would it be the standard / best practice here?</p> <p>OK this is what I came up with after reading all answers:</p> <pre><code>private string GetTempFileName(string dir) { string name = null; int attempts = 0; do { name = "temp_" + Player.Math.RandomDigits(10) + ".hsp"; attempts++; if (attempts &gt; 10) throw new Exception("Could not create temporary file."); } while (File.Exists(Path.Combine(dir, name))); return name; } private void SaveProject(string fileName) { bool originalRenamed = false; string tempNewFile = null; string oldFileTempName = null; try { tempNewFile = GetTempFileName(Path.GetDirectoryName(fileName)); using (Stream tempNewFileStream = File.Open(tempNewFile, FileMode.CreateNew)) { SafeXmlSerializer xmlFormatter = new SafeXmlSerializer(typeof(Project)); xmlFormatter.Serialize(tempNewFileStream, Project); } if (File.Exists(fileName)) { oldFileTempName = GetTempFileName(Path.GetDirectoryName(fileName)); File.Move(fileName, oldFileTempName); originalRenamed = true; } File.Move(tempNewFile, fileName); originalRenamed = false; CurrentProjectPath = fileName; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if(tempNewFile != null) File.Delete(tempNewFile); if (originalRenamed) MessageBox.Show("'" + fileName + "'" + " have been corrupted or deleted in this operation.\n" + "A backup copy have been created at '" + oldFileTempName + "'"); else if (oldFileTempName != null) File.Delete(oldFileTempName); } } </code></pre> <p><code>Player.Math.RandomDigits</code> is just a little function I made that creates an string with n random digits.</p> <p>I don't see how could this mess up the original file unless the OS is going wacko. It's pretty close to Hans's answer except that I first save the file to a temporary file so that, if something goes wrong when serializing, I don't need to rename the file back to it's original name, which can also go wrong. Please! let me know if you find any flaw.</p>
26,388,560
0
<p><code>$apply</code> is necessary to tell angular that changes happened to the scope. Built-in directives and services like <code>ngClick</code> or <code>$http</code> do that internally. If you apply (sic!) changes to the scope and don't use the aforementioned built-in services, then you are responsible for calling <code>$apply</code> yourself.</p> <p>So if <code>show</code> isn't called within an <code>ngClick</code>handler, e.g., then you need to call <code>$apply</code> yourself.</p>
19,714,087
0
Java File Name Printing <p>I am trying to print name of files from two folders, and this code compiles but not giving anything on running it.</p> <p>The main target here is to find common name files in two folders, I have stored file names in two arrays and then i will applying sorting and will find common files.</p> <pre><code> package javaapplication13; import java.io.File; import java.util.*; public class ListFiles1 { public static void main(String[] args) { String path1 = "C:/"; String path2 = "D:/"; File folder1 = new File(path1); File folder2 = new File(path2); String[] f1=folder1.list(); File[] listOfFiles1 = folder1.listFiles(); File[] listOfFiles2 = folder2.listFiles(); ArrayList&lt;String&gt; fileNames1 = new ArrayList&lt;&gt;(); ArrayList&lt;String&gt; fileNames2 = new ArrayList&lt;&gt;(); for (int i = 0; i &lt; listOfFiles1.length; i++) { if (listOfFiles1[i].isFile()) { fileNames1.add(listOfFiles1[i].getName());//wow System.out.println(listOfFiles1[i].getName()); } } for (int i = 0; i &lt; listOfFiles2.length; i++) { if (listOfFiles2[i].isFile()) { fileNames2.add(listOfFiles2[i].getName());//seriously wow } } } } </code></pre>
32,325,286
0
How to group by a column with null values <p>I have a table like this:</p> <pre><code>C1 | C2 -----|---- 23 | 10 null | 10 23 | 10 24 | 10 24 | 10 </code></pre> <p>I want group by C1 and calculate null's C2 value in both 23 and 24's sum(C2)</p> <pre><code>SELECT C1, sum(C2) FROM table GROUP BY C1 </code></pre> <p>query return this table:</p> <pre><code>C1 | C2 -----|---- 23 | 20 null | 10 24 | 20 </code></pre> <p>but I want this:</p> <pre><code>C1 | C2 -----|---- 23 | 30 24 | 30 </code></pre> <p>is it possible to get a result like that?</p>
38,826,053
0
Loading static files in node <p>I have a node application in which I am initializing var app = express() I am initializing some routes by passing this(app) to a function in one of node_modules of my application. addRoutes(app) is a function where I am defining my static folders </p> <pre><code>addRoutes = function (app) { app.set('views', __dirname + '/app'); app.set('view engine', 'html'); app.use(express.static(__dirname )); app.get('/', function (req, res) { res.render('index.html') }) } </code></pre> <p>this addRoutes is present in one of node_modules</p> <p>And my "_dirname" is a typical angular app in which there is a assets folder and all static files are present there but when I go to localhost:3000 none of my static files gets loaded. What am I doing wrong here</p>
8,919,206
0
What is the syntax to a templated recursive function? <p>This is driving me round the bend at the moment. As a homebrew exercise I wanted to template a recursive call in a class. in the .h file I have:</p> <pre><code>template &lt;typename T1&gt; class BinaryTree { public: BinaryTree(T1 element); ~BinaryTree(); BinaryTree* addLeftLeaf(BinaryTree&lt;T1&gt;* node); </code></pre> <p>etc...</p> <p>then in the .cpp</p> <pre><code>template &lt;typename T1&gt; BinaryTree* BinaryTree&lt;T1&gt;::addLeftLeaf(BinaryTree&lt;T1&gt;* node) { return node; } </code></pre> <p>I've tried seemingly loads of ideas but thus far nothing. Just errors like error C2955: 'BinaryTree' : use of class template requires template argument list</p> <p>Any suggestions would be kindly appreciated.</p> <p>Thanks</p> <p>Mark</p>
9,693,359
0
<p>Use a different data structure. I'd suggest trying something like one of the <a href="http://www.boost.org/doc/libs/1_39_0/libs/numeric/ublas/doc/matrix_sparse.htm" rel="nofollow">sparse matrix classes from Boost</a>. They are optimised for storing numeric data in which each row or column contains a significant number of zeroes. Mind you, if the problem you're trying to solve isn't suitable for handling with a sparse data structure, it would be a good idea to set out the nature of the problem you're trying to solve, in greater detail. Take another look at <a href="http://stackoverflow.com/questions/how-to-ask">http://stackoverflow.com/questions/how-to-ask</a> even though I guess you already read that.</p> <p>But before you do that I think you probably have another problem too:</p> <blockquote> <p>access myArray many many times, which is resulting in memory leaks and the program crashing for large calculations</p> </blockquote> <p>It looks to me from what you write there that your code may have some pre-existing bugs. Unless your crashes are simply caused by trying to allocate a 10000000-element array as an <code>auto</code> variable.</p>
38,530,394
0
<p>Update your controller:</p> <pre><code>var controller = ['$scope',function ($scope) { ... $scope.$on('my-tpl-ready', function() { $('#firstId').datepicker({ format: 'dd-mm-yyyy' }); }); }]; </code></pre> <p>Also add this to your template:</p> <pre><code>&lt;div ... ng-init="$emit('my-tpl-ready')"&gt; ... &lt;/div&gt; </code></pre>
28,288,761
0
<p>I feel like the way you are doing it is not that dirty... But the <code>numpy.fill</code> function is a bit more tidy:</p> <pre><code>In [4]: import numpy as np In [5]: x=np.empty(5) In [6]: x.fill(8) In [7]: x Out[7]: array([ 8., 8., 8., 8., 8.]) </code></pre>
4,643,171
0
<p>This should work</p> <pre><code>^(http|https):// </code></pre>
14,200,665
0
<p>I have been searched alot on google about HTML Formating in RDLC but couldn't find any proper answer.</p> <p>I got one idea to render html tag in rdlc while you export locally in pdf.</p> <p>Use below expression in textbox :-</p> <p>=Replace(Replace(Replace(Replace(Fields!<strong>your column name*</strong>.Value,"&quot;",""""),"&amp;","&amp;"),"&lt;","&lt;"),"&gt;",">")</p> <ol> <li>&amp;quot replaced by "(Quotes)</li> <li>&amp;amp replaced by &amp;</li> <li>&amp;lt replaced by &lt;</li> <li>&amp;gt Replaced by ></li> </ol> <p>so if you want replaced any more special charachter then just add more in above expression and it will take care of that.</p> <p>I have taken care almost special charachters so whenever you export these in pdf they would be well formated as html tags.</p> <p>If you still find any problem then let me know.</p> <p>Thanks</p> <p>Mahendra Singh</p>
39,341,239
0
Meteor Js Google Login Cache Issue <p>In my meteorjs application built for both iOS and Android, while logging in with google on mobile or web, the first time I login, it works fine and logs me into the app, but then when I logout of the app and try to re-login with another google account, the popup does not ask me for the username and password, instead it logs me back into the previous account which I initially used. Later, when I remove the browser/app cache, it works fine again for one time only. What should I do to not maintain the cache by google login.</p> <pre><code> Accounts.loginServiceConfiguration.remove({ service: "google" }); Accounts.loginServiceConfiguration.insert({ service: "google", clientId: "abdklabsldaklkahsdlk1238971289312.apps.googleusercontent.com", secret: "acbefghalkdglkaj" }); </code></pre>
17,558,271
1
python layout/functionality questions <p>I am about to start making a python (2.7) app - using wx, but im still having a few theoretical walls infront, making me sceptical about practical success.</p> <p>So below are a few questions: 1) My app will have many widgets (buttons, entries, labels, comboboxes) - where the majority will be added when the user invokes some events (clicking Add button will create additional labels, entries, comboboxes and buttons). My question here is, how can i keep track of this dynamic content, i sure wish to have a delete option aswell. My best guess was lists, but im still not sure how can i handle something like a combobox + im kinda lost on how could i delete a group of widgets.</p> <p>2) which practice of widget placement would be best for a fixed size frame/panels? Would be manual setting of xypos be just fine? Even considering my questions in 1) - mainly interested how to handle layout if something in the middle of frame gets deleted - holes would not be nice.</p> <p>Many thanks</p>
17,196,303
0
<p><a href="http://htmlpurifier.org/" rel="nofollow">HTML Purifier</a> is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications. </p>
37,069,633
0
java.lang.OutOfMemoryError: GC overhead limit exceeded on WSO2 MB <p>I've been recently working on with the <code>WSO2 Message Broker</code> (Ver : 3.1.0 ) in order to publish and consume messages using <code>JMeter</code> as the jms client. So I've got my publisher Java program where I'm publishing the messages from and I'm trying to publish 4000 messages per second. I could provide the snippet if necessary.</p> <p>I'm consuming those messages by running a <code>JMeter</code> command <code>jmeter -n -t C:\Users\ctsadmin\Downloads\wso2MB\apache-jmeter-2.13\bin\GamesSubscriber.jmx -l C:\Users\ctsadmin\Downloads\wso2MB\apache-jmeter-2.13\bin\mytest_results.jtl</code> in headless mode. I kept the <code>VisualVm</code>window opened as well to see the memory consumption for the test. For the first 15 minutes the publishing and consuming has been ok according to the image below, but there after, all of sudden the <code>VisualVm</code> shows a hype and runs out of memory. I'm attaching a screenshot of the <code>VisualVM</code> below.</p> <p><a href="https://i.stack.imgur.com/GNB3Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GNB3Y.png" alt="Screenshot of the CPU usage"></a></p> <p>I've checked the <code>heap dump</code> of the <code>WSO2 MB</code> using <code>JProfiler</code> as well. Have attached a screenshot of it too. <a href="https://i.stack.imgur.com/wipJO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wipJO.png" alt="enter image description here"></a></p> <p>What could be the issue? And what changes should I make? Something like increasing the <code>heap</code> size? Any help would be aprreciated.</p> <p><strong>EDIT</strong>: I'm <a href="https://onedrive.live.com/redir?resid=22E6B19629C9077D!259638&amp;authkey=!AKif8Eu6sBnleiw&amp;ithint=folder%2chprof" rel="nofollow noreferrer">hereby</a> attaching the log file and the heap dump. </p>
32,331,720
0
Getting Error.code = 0 in db.transaction function <p>I am creating a project in Phonegap with Ionic.I am inserting and fetching dynamic content with sqlite and local storage.</p> <p>I created a Dashboard contoller below are my dashboard controller code</p> <pre><code>angular.module('myWallet').controller('dashCtrl', function($scope,$state,$ionicPopup,$ionicHistory,AuthService){ $scope.data = {}; //goBack $scope.myGoBack = function() { $ionicHistory.goBack(); }; //********** error code function ************ function errorDashFunction(err) { alert("Error Code: "+error.code); } //********** Success code function ************ function successDashFunction() { var totalCashInHand = Coming_totalIncome - Coming_totalExpenses; alert(totalCashInHand ); } var current_user_id=window.localStorage.getItem('userid'); var Coming_totalIncome = 0; var Coming_totalExpenses= 0; var Coming_totalCashInHand = 0; //********** Fetching Values from DB ************ db.transaction(function (tx) { tx.executeSql("SELECT SUM(amount) as Totalincome FROM WALLET_INCOMES WHERE user_id ='"+current_user_id+"'", [], function(tx,results){ console.log(results); if(results.rows[0].Totalincome != null) { Coming_totalIncome = results.rows[0].Totalincome; } }); tx.executeSql("SELECT SUM(amount) as Totalexpenses FROM WALLET_EXPENSES WHERE user_id ='"+current_user_id+"'", [], function(tx,results){ if(results.rows[0].Totalexpenses != null) { Coming_totalExpenses = results.rows[0].Totalexpenses; } }); return true; },errorDashFunction,successDashFunction); }) </code></pre> <p>When i run this code on Ripple then it is alerting TotalCashInHand Price. BUT when i am running this code on my mobile then it is always showing Error code "0".</p>
19,674,464
0
Closing database connection when form is crossed in wpf <p>I am opening database connection using global variable in form constructor and i close it in form Exit button .The problem i am facing is if i cross the form it doesn't close database connection .How i can close connection if form is crossed ?</p>
802,490
0
<p>Thread.Join is what you want.</p>
31,269,816
0
List of values in latex <p>I am updating documentation written in latex, and I have to implement kind of box which will contain list of possible values and default value for specified item.</p> <p>Tex files already contain some predefined constructions. </p> <p>There is an entry, defined by <strong>\newcommand</strong>, which takes input parameters and creates a box.<br> It is used in next way:</p> <pre><code>%Input values {Min &amp; Max &amp; Default}: {0 &amp; 1 &amp; 0} </code></pre> <p>In final pdf file this construction transforms to next representation:<br> <img src="https://i.stack.imgur.com/DeadJ.png" alt="enter image description here"></p> <p>As I understood it is implemented in next piece of code: </p> <pre><code>\makebox[\linewidth][r]{ \begin{tabular}{llll} Input values: &amp; \mitalic{Min} &amp; \mitalic{Max} &amp; \mitalic{Default} \\ &amp; #8 \\ &amp; &amp; &amp; \\ \end{tabular} } </code></pre> <p>My goal is to implement something similar with next result: </p> <p><img src="https://i.stack.imgur.com/fJdWW.png" alt="enter image description here"></p> <p>Here number of possible values can be different.</p> <p>I have not had any experience with latex before, so sorry if for some of you it is stupid question.</p> <p><strong>UPDATE (19.08.2015):</strong></p> <p>I have used next construction to achieve my goals (see answers <a href="http://tex.stackexchange.com/questions/254303/how-to-define-a-command-that-takes-more-than-18-arguments">here</a> for more information):</p> <pre><code>\newcommand{\ParseOptMenuItemList}[1] { \def\tmplist{#1}% \@tempcnta=\z@ \@for\tmp:=\tmplist\do{\advance\@tempcnta\@ne \expandafter\let\csname temp\@roman\@tempcnta\endcsname\tmp }% \makebox[\linewidth][r]{% \begin{tabular}{lc} Possible values: \ifthenelse{\equal{\tempi}{}}{}{&amp; \tempi\\} \ifthenelse{\equal{\tempii}{}}{}{&amp; \tempii\\} \ifthenelse{\equal{\tempiii}{}}{}{&amp; \tempiii\\} \ifthenelse{\equal{\tempiv}{}}{}{&amp; \tempiv\\} \ifthenelse{\equal{\tempv}{}}{}{&amp; \tempv\\} \ifthenelse{\equal{\tempvi}{}}{}{&amp; \tempvi\\} \ifthenelse{\equal{\tempvii}{}}{}{&amp; \tempvii\\} \ifthenelse{\equal{\tempviii}{}}{}{&amp; \tempviii\\} \ifthenelse{\equal{\tempix}{}}{}{&amp; \tempix\\} \ifthenelse{\equal{\tempx}{}}{}{&amp; \tempx\\} \ifthenelse{\equal{\tempxi}{}}{}{&amp; \tempxi\\} \ifthenelse{\equal{\tempxii}{}}{}{&amp; \tempxii\\} \ifthenelse{\equal{\tempxiii}{}}{}{&amp; \tempxiii\\} \ifthenelse{\equal{\tempxiv}{}}{}{&amp; \tempxiv\\} \ifthenelse{\equal{\tempxv}{}}{}{&amp; \tempxv\\} \ifthenelse{\equal{\tempxvi}{}}{}{&amp; \tempxvi\\} \ifthenelse{\equal{\tempxvii}{}}{}{&amp; \tempxvii\\} \ifthenelse{\equal{\tempxviii}{}}{}{&amp; \tempxviii\\} Default value: &amp; \tempxix\\ \end{tabular} } } </code></pre>
17,582,591
0
<p>I'm not certain that introducing a <em>last</em> iterator on the second range for <code>is_permutation</code> would make the function any less unwieldy. I think it would make it more confusing.</p> <p>The thing with permutations is that the semantics are in the name itself. To check that one sequence is a permutation of another, you expect the sequence with no <em>last</em> iterator to be at least as long as the first sequence.</p> <p>If that's not the case, then you don't need to call <code>is_permutation</code> because it simply can't be a permutation. If it's longer, you <em>expect</em> that it's not going to iterate past the length of the first sequence - why would it? Well, it doesn't - and that's what you expected, so no faith is lost.</p> <p>C++ does expect programmers to take basic precautions, and makes us responsible for bounds-checking in many cases. Without giving that control to the programmer, the power of the language is diminished. If I'm calling <code>is_permutation</code> then I <em>know</em> that my second iterator is not going to overflow, because I <em>know</em> what a permutation is. I certainly don't want to waste cycles doing pointless bounds-checking.</p> <p>I think the old saying applies: <em>With great power comes great responsibility</em>. That's fair enough, isn't it?</p>
39,479,775
0
<pre><code>def find_price(self, name): if self.dictionary[name]["price"]: return self.dictionary[name]["price"] else: #assuming this is in a class...otherwise use global instead of self return self.find_price(dictionary[name]["child1"])*dictionary[name]["child1_quantity"] + find_price(self.dictionary[name]["child2"])*self.dictionary[name]["child2_quantity"]#.....etc </code></pre> <p>this also assumes that the top level object that you read the data into is a diction where the names also serve as keys in addition to their name fields.</p>
31,881,799
0
<p>"Errors" in Rx can be a a little difficult to grasp at first, because they have a slightly different meaning from what most people expect.</p> <p>From the <a href="https://github.com/ReactiveX/RxJava/wiki/Error-Handling" rel="nofollow">Error Handling documentation</a> (emphasis mine):</p> <blockquote> <p>An Observable typically does not throw exceptions. Instead it notifies any observers that <strong>an unrecoverable error has occurred</strong> by terminating the Observable sequence with an onError notification.</p> </blockquote> <p><code>onError()</code> is supposed to be used when an <code>Observable</code> encounters an <em>unrecoverable</em> error- that is when your <code>Observable</code> cannot continue emitting items. When you are subscribing, you might use something like <code>onErrorResumeNext</code> to try some recovery action, but that should be the end of the source <code>Observable</code>.</p> <p>Instead, you may want to adjust what your <code>Observable</code> emits to support emitting an error item, or include a flag indicating that an error was encountered.</p> <p>If your error truly is unrecoverable, then you may want to revisit your recovery strategy and try a slightly different approach.</p>
30,307,143
0
<p>Split the string using a regex then loop through all elements, parse them to numbers and get the largest. </p> <p>Since <code>String.split()</code> requires you to provide a regex that matches the delimiters, i.e. in your case everything between digits, use the regex <code>\D+</code>, i.e. "a sequence of at least one non-digit character". Note though that <code>\d</code> matches non-ASCII digits as well, hence <code>\D</code> won't match those, so if you only want to parse ASCII digits you should use <code>[^0-9]+</code>.</p> <p>Rough example:</p> <pre><code>String[] elements = input.split("[^0-9]+"); for( String element : elements ) { //skip empty elements, see note if( element.isEmpty() ) { continue; } //parse and compare here } </code></pre> <p>One note: <code>String.split()</code> will not remove empty elements at the beginning of the array (e.g. when your starts with a non-digit character) thus you'd need to skip empty elements in the loop.</p>
36,906,123
0
<p>When the value for <code>scanf("%d",&amp;far);</code> is entered and press enter, the scanf stores the carriage return in the buffer. When it encounters the second scanf in the code <code>scanf("%c",&amp;ch);</code> it takes the carriage return present in the buffer as the input to 'ch'. So it doesn't wait for the user input.</p> <p>Please have a look at the post <a href="http://stackoverflow.com/questions/5240789/scanf-leaves-the-new-line-char-in-buffer">here</a></p> <p>As indicated in one of the reply the solution is to put a space in scanf</p> <pre><code>scanf(" %c",&amp;ch); </code></pre>
24,361,805
0
Should I instantiate MatlabControl from withing Matlab or Java? <p>It is not obvious from here <a href="http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html" rel="nofollow">http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html</a>, how to use <code>MatlabControl</code> class.</p> <p>On one hand it is given an example:</p> <blockquote> <p>First, instantiate a MatlabControl object</p> <pre><code> MatlabControl mc = new MatlabControl(); </code></pre> </blockquote> <p>On the other hand it is said </p> <blockquote> <p>Snag 1: MatlabControl objects must be instantiated from within your Matlab session! (or by other java objects that were instantiated by your matlab session). This is because Matlab runs its own JVM, and you need to run MatlabControl in the same JVM that matlab is using. (this is why you need to make sure that MatlabControl is in your matlab classpath.) More specifically, if your program is defined in "mypackage/MyClass.java", you need to type</p> <p>mypackage.MyClass.main({'param1','param2',...})</p> </blockquote> <p>What is correct? Where to execute </p> <pre><code>MatlabControl mc = new MatlabControl(); </code></pre> <p>?</p> <p>In my java code?</p> <p>Or at matlab command prompt?</p>
10,569,331
0
<p>Pinax is just django with a blend of other django plugins. You have to enable them and set them up individually. To use each individual app within pinax, you have to read that specific app's documentation and set it up appropriately (list of apps and repos which likely contain documentation here: <a href="http://pinaxproject.com/ecosystem/" rel="nofollow">http://pinaxproject.com/ecosystem/</a>)</p> <p>Some people like pinax but I find that its more of a hassel than a solution. In the end pinax doesn't work out of the box. You have to customize everything, but at the same time you position yourself into using a bundle you dont need. I suggest instead starting a project and installing the packages you need individually, and even finding more here: <a href="http://djangopackages.com/" rel="nofollow">http://djangopackages.com/</a>. Especially, if its a big project because then if you bundle/setup everything on your own you will know the ins and outs of it all. </p>
17,440,525
0
Using JDBCRealm to authenticate user with Shiro <p>I am trying to authenticate a servlet running within Tomcat 6 using Shiro.</p> <p>I have the following shiro.ini file:</p> <pre><code>[main] ps = org.apache.shiro.authc.credential.DefaultPasswordService pm = org.apache.shiro.authc.credential.PasswordMatcher pm.passwordService = $ps aa = org.apache.shiro.authc.credential.AllowAllCredentialsMatcher sm = org.apache.shiro.authc.credential.SimpleCredentialsMatcher jof = org.apache.shiro.jndi.JndiObjectFactory jof.resourceName = jdbc/UserDB jof.requiredType = javax.sql.DataSource jof.resourceRef = true realm = org.apache.shiro.realm.jdbc.JdbcRealm realm.permissionsLookupEnabled = true realm.credentialsMatcher = $pm ; Note factories are automatically invoked via getInstance(), ; see org.apache.shiro.authc.config.ReflectionBuilder::resolveReference realm.dataSource = $jof securityManager.realms = $realm [urls] /rest/** = authcBasic /prot/** = authcBasic </code></pre> <p>And the following in my database:</p> <pre><code>mysql&gt; select * from users; +----------+------------------+----------+----------------------------------------------+--------------------------+ | username | email | verified | password | password_salt | +----------+------------------+----------+----------------------------------------------+--------------------------+ | admin | a.muys@********* | 1 | ojSiTecNwRF0MunGRvz3DRSgP7sMF9EAR77Ol/2IAY8= | eHp9XedrIUa5sECfOb+KOA== | +----------+------------------+----------+----------------------------------------------+--------------------------+ 1 row in set (0.00 sec) </code></pre> <p>If I use the <code>SimpleCredentialsManager</code> it authenticates fine against a plaintext password in the users table. Trying to use the <code>PasswordMatcher</code> has been extremely frustrating.</p> <p>The password and password_salt were obtained via the shiro-tools <code>Hasher</code> utility.</p> <p>When I try to authenticate against a basic <code>HelloWorld</code> servlet I use for testing (path=rest/hello, context=/ws), I get the following in the logs:</p> <pre><code>15:35:38.667 [http-8080-2] TRACE org.apache.shiro.util.ClassUtils - Unable to load clazz named [ojSiTecNwRF0MunGRvz3DRSgP7sMF9EAR77Ol/2IAY8=] from class loader [WebappClassLoader context: /ws delegate: false repositories: /WEB-INF/classes/ ----------&gt; Parent Classloader: org.apache.catalina.loader.StandardClassLoader@79ddd026 ] </code></pre> <p>(Full log at <a href="https://gist.github.com/recurse/5915693">https://gist.github.com/recurse/5915693</a> )</p> <p>It appears to be trying to load my hashed password as a classname. Is this a bug, or a configuration error on my part? If it is a bug, how can I work around it? If it is a configuration error, what am I missing?</p>
6,364,718
0
<p>You can try <a href="https://developer.mozilla.org/en/HTML/Element/base" rel="nofollow">using the <code>&lt;base&gt;</code> tag</a>. This will set your Base URL to whatever you need:</p> <pre><code>&lt;base href="http://yourdomain.com/"&gt; &lt;script src="js/remotescript.js"&gt;&lt;/script&gt; </code></pre> <p>Note this means now your <em>local</em> scripts need to be in absolute form:</p> <pre><code>&lt;script src="http://localhost/js/phonegap.js"&gt;&lt;/script&gt; </code></pre> <p>See <a href="http://stackoverflow.com/q/6111684/207894">this other question for more info</a> regarding this note. The guy there suggests to prepend a <em>dot</em> (<code>.</code>) before the <em>local relative URL</em>, though I <strong>didn't test this</strong>:</p> <pre><code>&lt;script src="./js/phonegap.js"&gt;&lt;/script&gt; </code></pre>
11,191,445
0
<p>First off, try to set an action on your form tag. The action defines the page, to which the form will be submitted.</p> <pre><code>&lt;form method="post" action="Test.php"&gt; </code></pre> <p>With this the form should get submitted to Test.php. If it still doesn't do anything, try to print a variable dump (<a href="http://php.net/manual/de/function.var-dump.php" rel="nofollow">manual</a>) with <code>var_dump($POST);</code> on top of the page. You will then see all set values of the post attributes. From there on it should be easy to find the error.</p> <p><strong>EDIT</strong></p> <p>After your comment I realized that you are trying to send the form with AJAX and just reload the content div. You have to do this in two steps. First, send the data of the form to Test.php, and then reload the content div. If stumbled upon this question: <a href="http://stackoverflow.com/questions/1960240/jquery-ajax-submit-form">jQuery AJAX submit form</a>. This may help you how to submit your form. If you want to use a return value, you can try something like this:</p> <pre><code>$.post("Test.php", $("#form").serialize(), function(data) { alert("Returned data: " + data); }); </code></pre> <p>See <a href="http://api.jquery.com/jQuery.post/" rel="nofollow">jQuery.post()</a></p>
5,772,578
0
<p><em>Me</em>: Could you provide a little more information about the IFoo service implementation? Does it have all of its own dependencies satisfied?</p> <p><em>Myself</em>: Hmm, no it doesn't. Turns out I didn't bind its dependencies. Boy, is that error message and stack trace misleading!</p> <hr> <p>So my mistake was that I didn't bind one of the dependencies of the IFoo implementation and so Ninject failed silently and tried to continue on its merry way. Which is really unfortunate because it could lead to some really strange behavior once I deviate from a trivial setup. I guess my next question should be how can I get Ninject to fail as early as possible and provide good messaging about what's wrong? But for now I can at least get on with it.</p>
25,868,562
0
FTP difference between STOR and PUT command <p>We use FTP for dropping the product feeds to our FTP server. I wanted to understand the difference between the STOR and PUT command in FTP. Can you please help me understand this?</p>
37,739,347
0
<p>U just need to check that action name is constant everywhere...i also had same problem i resolved by removing namespace as it is not necessary which i see u have not mentioned and also i had different action name at loginpage.jsp and struts.xml page.. so just see ur action name </p>
28,376,955
0
<p>To answer your questions:</p> <ul> <li>Is X an array when it's passed in?</li> </ul> <p>Yes. It is a <code>DOUBLE PRECISION</code> array having one dimension with the extent <code>NGamma</code>.</p> <ul> <li>Is the X that is declared in the 3rd line different than the parameter X?</li> </ul> <p>First, a word of terminology: In Fortran, X is a dummy argument (that gets associated with the actual argument of the caller). In Fortran, a <code>PARAMETER</code> is quite a different beast: <code>PARAMETER</code>s are named constants in Fortran.</p> <p>So yes, the X that is a dummy argument is the same as in the <code>DIMENSION</code> statement. It gets its type from the <code>IMPLICIT DOUBLE PRECISION</code> statement.</p> <p>Modern ideomatic Fortran would have the declaration as something like</p> <pre><code> DOUBLE PRECISION, DIMENSION(NGamma), INTENT(IN) :: X </code></pre> <p>which would make clear to the reader that this is an array dummy argument which is not permitted to be changed by the function.</p> <p>The <code>GAMMA</code> is declared as an array of the same shape as <code>X</code>. This used to be invalid FORTRAN 77 (but accepted as an extension by many compilers), but is perfectly fine for Fortran 90 or later.</p>
19,602,690
0
<p>here is the deal.. the <code>onItemSelected</code> method is still called when the Spinner has just been created without you selecting any option. A simple workaround for this is to add an extra option in spinner liek "Select" or "None" and have a <code>if-else</code> construct in <code>onItemSelected</code> method just like this:- </p> <pre><code>@Override public void onItemSelected(AdapterView parent, View view, int pos, long id) { if(pos==0) { //do something; } else { Toast.makeText(parent.getContext(), parent.getItemAtPosition(pos).toString(), Toast.LENGTH_SHORT).show(); } } </code></pre>
20,576,121
0
C++Builder is a rapid application development (RAD) environment, originally developed by Borland and as of 2009 owned by Embarcadero Technologies, for writing programs in the C++ programming language targeting Windows and OS X.
32,282,560
0
<p>Here's how to handle this using <code>jQuery</code>:</p> <pre><code>$('#lightswitch').on('click', function() { $('nav').css('background-color', 'green'); }); </code></pre> <p>Best</p>
25,179,131
0
Multiple terms in a facet <p>I'm currently facing a Lucene facet problem.</p> <p>My document looks like:</p> <pre><code>doc1: - title: lorem - facetField: east west doc2: - title: ipsum - facetField: north doc3: - title: dolor - facetField: south doc4: - title: sit - facetField: north west </code></pre> <p>I would like to use facets to narrow down my search results for documents which only contain the text <code>west</code>.</p> <p>As far as I know, the <code>new CategoryPath("categoryFacet", "west")</code> wouldn't find any documents because it does not exactly match a document. Is there a possibility to use something like <em>contains term</em> in facets?</p>
10,830,563
0
Stop the Music in WebView when Screen Time-Out <p>I am programming that allow users can listen music in WebView via the URL web link. But I wonder why when the android phone user screen Time-Out my music in WebView also stop. Do you have any solution to solve this problem?</p> <h1>Here is my code:</h1> <pre><code>public class PlayMusicActivity extends Activity { WebView mWebView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.playlist); mWebView = (WebView) findViewById(R.id.webView1); mWebView.setWebViewClient(new HelloWebViewClient()); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setPluginsEnabled(true); mWebView.getSettings().setAllowFileAccess(true); mWebView.loadUrl("http://www.myweb.com/music.html"); } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; mWebView.canGoBack()) { mWebView.goBack(); return true; } return super.onKeyDown(keyCode, event); } @Override public void onPause() { mWebView.setVisibility(View.GONE); mWebView.destroy(); super.onPause(); } } </code></pre> <p>Appreciate for your help.</p> <p>Best regards, Virak</p>
1,945,777
0
C++ Array vs vector <p>when using C++ vector, time spent is 718 milliseconds, while when I use Array, time is almost 0 milliseconds.</p> <p>Why so much performance difference?</p> <pre><code>int _tmain(int argc, _TCHAR* argv[]) { const int size = 10000; clock_t start, end; start = clock(); vector&lt;int&gt; v(size*size); for(int i = 0; i &lt; size; i++) { for(int j = 0; j &lt; size; j++) { v[i*size+j] = 1; } } end = clock(); cout&lt;&lt; (end - start) &lt;&lt;" milliseconds."&lt;&lt;endl; // 718 milliseconds int f = 0; start = clock(); int arr[size*size]; for(int i = 0; i &lt; size; i++) { for(int j = 0; j &lt; size; j++) { arr[i*size+j] = 1; } } end = clock(); cout&lt;&lt; ( end - start) &lt;&lt;" milliseconds."&lt;&lt;endl; // 0 milliseconds return 0; } </code></pre>
12,131,897
0
<p>use <code>remove_if</code> found under <code>algorithm</code></p> <p>Given a begin and end iterator along with a predicate, you can remove any element that results in the predicate evaluating to true. I'll include both C++03 and C++11 examples.</p> <p>C++03:</p> <pre><code>#include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;iterator&gt; #include &lt;vector&gt; #include &lt;cstdlib&gt; #include &lt;ctime&gt; template &lt;typename T&gt; struct is_equal { T val; is_equal (const T&amp; v) : val (v) { } bool operator() (const T&amp; test) { return (val == test); } }; struct is_odd { bool operator() (int test) { return (test % 2 == 1); } }; template &lt;typename T&gt; std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const std::vector &lt;T&gt;&amp; v) { typedef typename std::vector &lt;T&gt;::const_iterator itr; for (itr i = v.begin (); i != v.end (); ++i) os &lt;&lt; *i &lt;&lt; " "; return os; } int main (int argc, char* argv[]) { srand (time (NULL)); std::vector &lt;int&gt; vec (10); // vector has size of 10 std::generate (vec.begin (), vec.end (), rand); // populate with random numbers std::cout &lt;&lt; vec &lt;&lt; std::endl; vec.erase (std::remove_if (vec.begin (), vec.end (), is_odd ()), // removes all odd elements vec.end ()); std::cout &lt;&lt; vec &lt;&lt; std::endl; return 0; } </code></pre> <p>C++11:</p> <pre><code>#include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;iterator&gt; #include &lt;numeric&gt; #include &lt;vector&gt; #include &lt;cstdlib&gt; template&lt;typename T&gt; std::ostream&amp; operator&lt;&lt; (std::ostream&amp; os, const std::vector &lt;T&gt;&amp; v) { for (auto i : v) os &lt;&lt; i &lt;&lt; " "; return os; } int main(int argc, char* argv[]) { std::vector &lt;int&gt; vec(10); // vector has size of 10 std::iota (vec.begin(), vec.end(), 1); // populate with [1, 2, 3, ...] std::cout &lt;&lt; vec &lt;&lt; std::endl; vec.erase (std::remove_if (vec.begin(), vec.end(), [](int i){ return (i == 3); }), vec.end ()); std::cout &lt;&lt; vec &lt;&lt; std::endl; return 0; } </code></pre> <p>For any questions on using the STL, I personally consult <a href="http://en.cppreference.com/w/" rel="nofollow">http://en.cppreference.com/w/</a> and <a href="http://www.cplusplus.com/reference/" rel="nofollow">http://www.cplusplus.com/reference/</a></p>
7,794,956
0
Make browser to load silverlight page/xap even when server is offline <p>Is it possible to force browser to reload a Silverlight application - basically .aspx and .xap files - even if the server goes down? I.e. not accessible to the browser. Like setting caching forever. I tried different cache-control and expires headers but it doesn't seem to make a difference, it's still either 200 or 304 requests.</p> <p>In other words, I want browser to load .xap once and then never send requests for it again, always loading from cache - never means not even 304s.</p> <p>In even other words, is it possible to make browsers, once they got page and related content, to use them from cache and not contact server at all?</p>
20,152,512
0
<p>s1) Yes, you can set certain properties as being indexed. Some property types do not allow indexing at all. It's preferable to set the indexes programmatically within each model definition.</p> <p>2) Although you can drop the index programmatically (i.e. remove indexed=True), I would not recommend it. It will leave your data store in inconsistent state.</p> <p>3) It's not possible to set index on a structured property, however, you can set a Key relationship between your model and the models in the structured property.</p> <p>See: </p> <ul> <li><p><a href="https://developers.google.com/appengine/docs/python/ndb/entities" rel="nofollow">https://developers.google.com/appengine/docs/python/ndb/entities</a></p></li> <li><p><a href="https://developers.google.com/appengine/docs/python/ndb/properties" rel="nofollow">https://developers.google.com/appengine/docs/python/ndb/properties</a> </p></li> </ul> <blockquote> <p>"You can specify the usual property options for structured properties (except indexed)."</p> </blockquote>
33,945,163
0
<p>You could use the version of the <code>Task</code> <a href="https://msdn.microsoft.com/en-us/library/dd783035%28v=vs.110%29.aspx" rel="nofollow">constructor</a> that takes an <code>Action&lt;Object&gt;</code> parameter so you can pass the required input arguments, including the cancellation token, to the method executed by the task.</p> <p>Example:</p> <pre><code>ref class Test { public: void Loop() { auto tokenSource = gcnew CancellationTokenSource(); auto token = tokenSource-&gt;Token; int i = 0, max = 100; while (i &lt; max) { auto tuple = gcnew tuple_t(i, token); auto newtask = gcnew Task(gcnew Action&lt;Object^&gt;(this, &amp;Test::DoSomething), tuple, token); newtask-&gt;Start(); i++; } } void DoSomething(Object^ state) { auto tuple = static_cast&lt;tuple_t^&gt;(state); int data = tuple-&gt;Item1; CancellationToken token = tuple-&gt;Item2; // ... } private: typedef Tuple&lt;int, CancellationToken&gt; tuple_t; }; </code></pre>
13,801,620
0
<p><code>del /s *.txt</code> will delete all TXT files in all subfolders of current working directory.</p> <p>(But use that command carefully - wrong parent directory and you are throwing away all textfiles on your computer :) )</p>
19,205,353
0
<p>I'm not certain about the solution, but here's something to test: Try adding the attribute 'controls' to the video tag, e.g.:</p> <pre><code>&lt;video id="video_background" preload="auto" controls autoplay loop muted volume="0"&gt; </code></pre> <p>Where I'm going with this is that the 'autoplay' video tag attribute is not always honored by all browsers (it could be annoying, intrusive, and bandwidth-intensive). By asking for controls, you will be able to mouse over the blank video area and press a play button. This will verify whether IE9 and Safari are at least able to play the video.</p>
525,567
0
<p>I've worked on a Drupal project with about 1 million nodes. We added transactional support and it wasn't too hard. You'll need to patch the core of course but this shouldn't be a major concern for an enterprise application with good support and documentation. I was working as the observing pair programmer on the transactional support. I think it took us about a day.</p> <p>Edit:</p> <p>I've been working as a Drupal Developer for a few years now. And recently, I have revised my position on Drupal in relation to best practices and enterprise application. </p> <p>I don't think Drupal is particularly suited to the Enterprise space because:</p> <ul> <li>Drupal's testing framework is too cumbersome (a domain specific language would be great)</li> <li>There are too many contributed modules of poor quality </li> <li>Drupal's content model resides partly in code and partly in the database schema </li> <li>Drupal's developer community have become focused on sexy software rather than quality software</li> <li>Drupal doesn't have mature developer tools (drush is changing that) or a development environment built in.</li> <li>Drupal Development is browser and UI centric.</li> <li>The centralized nature of Drupal.org/projects, CVS and Drupal's policy on Contrib Projects inhibits the evolution of individual software projects </li> </ul> <p>Also: The enterprise Drupal Application I was once working on has now been ported into Rails. </p>
16,734,729
0
<p>Absolutely. For example, MySQL does not have hash and merge joins. Certain query patterns will suffer greatly there.</p> <p>The notion that the RDBMS used does not matter is strange to me. Different databases have very non-uniform performance characteristics. Performance very much varies with workload.</p> <p>If you want to exclude the RDBMS as much as possible from your tests you have to carefully make sure that you are not testing any RDBMS-specific performance features by accident. This is very hard.</p>
22,654,623
0
<p>Use the Neo4jPHP driver from Josh Adell, there are also sample projects listet on </p> <p><a href="http://neo4j.org/develop/php" rel="nofollow">http://neo4j.org/develop/php</a></p> <p>I think there are no built-in ways to access the shell from Neo4jPHP but if you can use its http facilities, you can do something <a href="http://jexp.de/blog/2014/02/on-using-neo4j-shell-with-basic-auth-over-http-on-a-remote-server/" rel="nofollow">like I did here</a>.</p>
1,807,946
0
<p>Utterly, utterly impossible. You won't even be able to open a TCP connection because the other website's server will try to handshake with the client, and fail.</p> <p>An IP address isn't just any old ID, it's the actually <em>address</em> that servers will send any response to. Spoofing it basically only makes sense if you can fit your request into a single IP packet (which rules out TCP and thus HTTP) and are not interested in the response. Even then it can fail because your ISP's routers may have anti-spoofing rules that drop packets with "outside" IP addresses originating from "inside" networks.</p>
20,204,669
0
<p>Use the chunk option <code>fig.show='hold'</code>.</p>
12,557,907
0
Flex Mobile TabbedView Applicatin Hide tabbar in states <p>I am building a tabbed view mobile application in Flash Builder 4.6 and want to have a login screen into it. </p> <p>I have 5 tabs, and on the first view page I have 2 states. </p> <p>1 state for a login, and another state for the actual tab itself. I could make these but would like to hide the tabbar when it is in the login state. </p> <p>I have found some things where you can turn it off by clicking on buttons, but how about just turning it of in the first view page (login state). </p> <p>I tried this : </p> <pre><code>&lt;s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" textAlign="center" title="Daily Settings" creationComplete="view2_creationCompleteHandler(event)"&gt; ... protected function view2_creationCompleteHandler(event:FlexEvent):void { // TODO Auto-generated method stub this.tabBarVisible = false; } </code></pre> <p>but strangely it will only dissapear on certain moments and not the whole time... </p>
30,885,030
0
<p><strong>This avoid's unnecessary assignments of values and variable declarations</strong> </p> <p>1) Focus(param1,param2)</p> <pre><code>function Focus(Locatie,Bonregel) { if (Locatie.value == "" &amp;&amp; Bonregel.value == ""){ Locatie.focus(); } else if (Locatie.value == "") { Locatie.focus } else if (Bonregel.value == "") { Bonregel.focus(); } } </code></pre> <p>2) Send(param1,param2,param3)</p> <pre><code>function Send(keycode, locatie, bonregel) { //Assign value directly document.getElementById("form_keycode").value = keycode; document.getElementById("form_locatie").value=locatie; document.getElementById("form_bonregel").value=bonregel; //submit data from myform document.myform.submit(); } </code></pre> <p>3) Check()</p> <pre><code>function Check() { // check alle data vooor verzenden // Keycode 13 -&gt; ENTER // Keycode 125 -&gt; Green key on device if (event.keyCode == 125) { Send(125, document.getElementById("locatie").value, document.getElementById("bonregel").value); } else if (event.keyCode == 13) { delay(Send(13,document.getElementById("locatie").value,document.getElementById("bonregel").value), "Send", 500); } else { Focus(document.getElementById("locatie"),document.getElementById("bonregel")); } } </code></pre>
4,161,824
0
<p>I don't know much about Ocracoke, but why don't you look into Visual Studio?</p>
39,482,190
0
<p>My technique for this is to write a shell script that does the job, and then run it via <code>find</code>. For example, your actions could be written into a script <code>munger.sh</code>:</p> <pre><code>#!/bin/sh for file in "$@" do output="output_dir/$(basename "$file")" sed -e 's:foo:bar:g' "$file" &gt; "$output" done </code></pre> <p>The <code>find</code> command becomes:</p> <pre><code>find input_dir -name "PATTERN" -exec sh munger.sh {} + </code></pre> <p>This runs the script with the file names as arguments, bundling conveniently large number of file names into a single invocation of the shell script. If you're not going to need it again, you can simply remove <code>munger.sh</code> when you're done.</p> <p>Yes, you can do all sorts of contortions to execute the command the way you want (perhaps using <code>find … -exec bash -c "the script to be executed" arg0 {} +</code>) but it is often harder than writing a relatively simple script and using it and throwing it away. There tend to be fewer problems with quoting, for example, when you run an explicit script than when you try to write the script on the command line. If you find yourself fighting with single quotes, double quotes and backslashes (or back-quotes), then it is time to use a simple script as shown.</p>
22,268,305
0
<p>If your project can manage it, it could be better to <a href="http://www.javascriptkit.com/javatutors/dom2.shtml" rel="nofollow">create DOM Elements and append them to the tree</a>. </p> <p>The big problem with efficiency would be that setting <code>.innerHTML</code> property would first remove all the nodes and only then parse the html and append it to the DOM. </p> <p>It's obvious that you should avoid removing and the re-appending identical elements, so if you're sure the <code>"Example"</code> elements would always remain on the page, your way of setting them seems to be a nice optimazation.</p> <p>If you want to optimize it even further, you could parse the html you want to append to nodes and have a function that checks which ones should be appended and which one shouldn't. But be aware that accessing the DOM is costly. Read more about the <a href="http://www.phpied.com/dom-access-optimization/" rel="nofollow">ECMA-DOM bridge</a>.</p> <p><strong>Edit:</strong> In some cases it might be better to let the browser do the html parsing and injecting through <code>innerHTML</code>. It depends on the amount of HTML you're inserting and the amount you're deleting. See <em>@Nelson Menezes</em>'s comments about innerHTML vs. append.</p>
39,281,776
0
<blockquote> <p>Issue 1: Accessing web GUI of dockerized Spring Cloud Dataflow</p> </blockquote> <p>We might need little more details around this. Assuming this is the local-server, perhaps you could share the docker scripts/image, so we could try it out.</p> <blockquote> <p>Issue 2: Routing by JSON Header</p> </blockquote> <p>The <a href="https://github.com/spring-cloud/spring-cloud-stream-app-starters/tree/master/router/spring-cloud-starter-stream-sink-router" rel="nofollow"><code>router-sink</code></a> application would come handy for this type of use-cases. This application routes the payload to named destinations based on certain conditions, so you'd have the opportunity to route the payload with respective <code>ingest-query</code> to Cassandra. </p> <p>stream 1:</p> <pre><code>stream create test --definition "file | router --expression=header.contains('a')?':foo':':bar’" </code></pre> <p>stream 2:</p> <pre><code>stream create baz --definition ":foo &gt; cassandra --ingest-query=\"query1\"" </code></pre> <p>stream 3:</p> <pre><code>stream create wiz --definition ":bar &gt; cassandra --ingest-query=\"query2\"" </code></pre> <p>(<em>where: <code>foo</code> and <code>bar</code> are named destinations</em>)</p>
26,559,529
0
<pre><code>&lt;video id="video" controls preload="metadata"&gt; &lt;source src="video/sintel-short.mp4" type="video/mp4"&gt; &lt;source src="video/sintel-short.webm" type="video/webm"&gt; &lt;track label="English" kind="captions" srclang="en" src="captions/vtt/sintel-en.vtt" default&gt; &lt;track label="Deutsch" kind="captions" srclang="de" src="captions/vtt/sintel-de.vtt"&gt; &lt;track label="Español" kind="captions" srclang="es" src="captions/vtt/sintel-es.vtt"&gt; &lt;/video&gt; </code></pre>