pid
int64
2.28k
41.1M
label
int64
0
1
text
stringlengths
1
28.3k
13,716,194
0
SnapView in Windows 8 app <p>I want to add SnapView and want to handle all screen resolutions in my blank grid app in Windows 8 , how to achieve that ?</p>
11,087,997
0
<p>If you are using Jackson, You could look at the JacksonJAXBAnnotations here <a href="http://wiki.fasterxml.com/JacksonJAXBAnnotations" rel="nofollow">http://wiki.fasterxml.com/JacksonJAXBAnnotations</a></p>
22,826,338
0
Not able to enter user input on second run of while loop <p>I'm writing a small payroll program with 2 classes (Payroll/contains main, and Employee). The program should continue to ask for user input until the user enters <em>stop</em> as an employee's name. I was able to get the program to terminate after entering <em>stop</em> as the first employee's name; however, when I input an actual name (for example Jim), the program runs through the while loop once fine. The problem is that when the while loop runs again it does not allow any user input for the employee name. It jumps directly to the next line, which is asking for hours worked. Here is my code from the Employee class.</p> <p>package payroll;</p> <p>import java.util.Scanner;</p> <p>public class Employee {</p> <pre><code>// class variables private String employeeName; private double hoursWorked; private double payRate; private double weeklyPay; // Employee class constructor public Employee() { } // get value of class variable employeeName from user public void getInfo() { String name = ""; // initialized as empty string for use in while loop String term = "stop"; // terminating condition for while loop double hours; // employee hours worked double rate; // employee pay rate Scanner input = new Scanner(System.in); while (!name.equals(term)) { // will continue as long as name does not equal "stop" System.out.print("Enter the employee's name or stop if finished: "); name = input.nextLine(); // assigns the value input for name employeeName = name; if (employeeName.equals(term)) break; // terminate while loop if user enters "stop" System.out.print("How many hours did " + employeeName + " work? "); hours = input.nextDouble(); // assigns the value input for hours hoursWorked = hours; // assigns hours to Employee class variable hoursWorked if (hours &lt; 0) { // control statement to make sure hours is not a negative number System.out.print("Hours cannot be a negative number.\n"); System.out.print("How many hours did " + employeeName + " work? "); hours = input.nextDouble(); // assigns the value input for hours hoursWorked = hours; // assigns hours to Employee class variable hoursWorked } System.out.print("Enter " + employeeName + "'s pay rate: "); rate = input.nextDouble(); // assigns the value input for rate payRate = rate; // assigns rate to Employee class variable payRate if (rate &lt; 0) { System.out.print("Rate cannot be a negative number.\n"); System.out.print("Enter " + employeeName + "'s pay rate: "); rate = input.nextDouble(); // assigns the value input for rate payRate = rate; // assigns rate to Employee class variable payRate } // calculates employee pay form calcPay method calcPay(); // outputs message to console displayMessage(); } } </code></pre> <p>public void calcPay() {</p> <pre><code> weeklyPay = setHours() * setRate(); } </code></pre> <p>public void displayMessage() {</p> <pre><code> System.out.printf("%s%s%.2f \n", employeeName, "'s weekly pay is $", weeklyPay); } </code></pre> <p>This is what my output looks like:</p> <p>Enter the employee's name or stop if finished: Tim</p> <p>How many hours did Tim work? 40</p> <p>Enter Tim's pay rate: 20.50</p> <p>Tim's weekly pay is $820.00</p> <p>Enter the employee's name or stop if finished: How many hours did work? </p> <p>I can't understand why I am not enter a new employee's name.</p>
36,359,801
0
Sprockets::FileNotFound couldn't find file 'bootstrap' with type 'text/css' <p>So this is the error I am getting in my browser when I try to run the rails server:</p> <pre><code> [couldn't find file 'bootstrap' with type 'text/css'] </code></pre> <p>I have this in my gemfile:</p> <pre><code> gem 'bootstrap-sass', '~&gt; 3.3.5.1' </code></pre> <p>And this is my application.css.scss file: </p> <pre><code> *= require bootstrap *= require_tree . *= require_self */ @import "bootstrap"; </code></pre> <p>Does anyone know how to get this up and running?? </p>
9,641,810
0
Running ant as administrator...through Eclipse <p>I just inherited a project that uses Tomcat to serve JSPs, but Apache httpd to server Javascript...</p> <p>The Ant build for this project creates and deletes directories inside the <code>C:\Program Files\Apache Software Foundation\Apache2.2\</code> directory, which is an "admin" directory in Windows 7 land.</p> <p>When I try to run this Ant build inside of Eclipse, the build fails because it is unable to create the necessary directories because its getting permission/access denied errors.</p> <p>Is there any way to configure Ant (run arguments, etc.) to run as administrator from inside Eclipse? Thanks in advance.</p>
4,141,373
0
WIQL - is it possible to get checkin differences using WIQL? <p>This is in VSTS 2010</p> <p>Question: Using WIQL, is it possible to get the list of file differences due to checkins </p> <p>1) for a given date range</p> <p>2) for a given folder </p>
34,811,268
0
No img-responsive in Bootstrap 4 <p>I just downloaded the source code for Bootstrap 4 alpha 2 and can't find the class <code>img-responsive</code> in it. It exists in Bootstrap 3 source code and I can find it with Notepad++ but in Bootstrap 4s <code>bootstrap.css</code> in <code>dist</code> folder it doesn't exist.</p> <p>What happend to it??</p>
35,059,263
0
Salesforce API - How to retrieve 'frequent actions' <p>I'm very new to Salesforce and have a specific task to carry out. </p> <p>I'd like to retrieve the most frequent tasks that have happened in a salesforce application and display them within a Drupal application. I've read through some of the documentation and came accross:</p> <p>KnowledgeArticleViewStat Provides statistics on the number of views for the specified article across all article types. This object is read-only and available in API version 20 and later. <a href="https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_knowledgearticleviewstat.htm" rel="nofollow">https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_knowledgearticleviewstat.htm</a></p> <p>Basically, there are many application users and I'd like to show a summary of their most viewed items/pages.</p> <p>Is this the root I should go down or is there a more generic object/query I can use to return further usage information?</p> <p>Many thanks in advance for your help.</p>
8,071,609
0
<p>You are definitely obtaining the instance of the "ervice" from the bean factory when you call the methods, right? The bean factory needs to set up a proxy which implements the transactional logic around each method call. I was under the impression this only worked when "outsiders" invoke methods via the proxy, and doesn't necessarily work when one method calls another, as that method is a direct call inside the implementation object and does not go via the AOP proxy.</p>
27,043,600
0
<p>If you just need the time part of your <code>Date</code> object and you can't use Java 8 and don't want to use any third party framework, then use <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html" rel="nofollow"><code>Calendar</code></a>:</p> <pre><code>Calendar c = Calendar.getInstance(); c.setTime(yourDate); c.set(Calendar.YEAR, 0); c.set(Calendar.MONTH, 0); c.set(Calendar.DAY, 0); Date timeOnly = c.getTime(); </code></pre>
20,073,814
0
<p>You're going to need a bit more than that, to get this accomplished ;) First of all, Slick requires a DB session, so that needs to be handled somewhere. Meaning a Slick Table <code>getAll</code> won't work by itself.</p> <p>I would do something like this (sorry, typing this up without an IDE, so it may not compile):</p> <pre><code>case class Person(...) object People extends Table[Person](PeopleDAO.table) { def * = ... } trait DAO[T] { val table: String def getAll: Seq[T] } object PeopleDAO extends DAO[Person] { override val table = "people" def getAll = { DB withSession { implicit session =&gt; Query(People).list } } } object Controller { def getTable(tableName: String) = Action { val dao: DAO[_] = tableName.toLowerCase match { case PeopleDAO.table =&gt; PeopleDAO case _ =&gt; throw new IllegalArgumentException("Not a valid table.") } Ok(Json.toJson(dao.getAll)) } } </code></pre>
10,060,842
0
<h2>What is MSVCP90.dll</h2> <p>MSVCP90.dll is Multithreaded, dynamic Visual Studio 2008 C Runtime Library. Generally your application should package MSVCP90.dll unless you are sure that the target machine have the matching CRT. You can use any of the packaging software to package the necessary DLLs and your software and distribute it.</p> <h2>Purpose of MSVCP90.dll</h2> <p>You may be wondering why you need this weird dll? Well CRT is nothing new to python. All application that is based on C heavily relies on C library functions. All the implementations of the standard C Library functions like (malloc, strcpy ..) to name a few is implemented in these libraries. There are different kinds and the specific <a href="http://msdn.microsoft.com/en-us/library/abx4dbyh%28VS.100%29.aspx" rel="nofollow noreferrer">MSDN website</a> have more details on it. <img src="https://i.stack.imgur.com/A7VSs.png" alt="enter image description here"></p> <h2>Distributing MSVCP90.dll</h2> <p>When distributing CRT, you should understand that depending upon what CRT you have used the version number which is suffixed with the name of the CRT varies. For example MSVCP90.DLL is the CRT from Visual Studio 2008. A single machine can contain multiple CRTs either in the system folder on in application installation path. </p> <p>If you are planning to package your application, you need to re-verify, which CRT version your application uses. Packaging wrong CRT or using one can cause undesired and undefined effect. Generally speaking the CRT your Python Installation uses, should be the same CRT you should package.</p> <h2>Determining the correct MSVCRT</h2> <p>As there are different CRT builds with different versions, it is difficult to ascertain, which CRT should be packaged. If you have a running application (executable), you can use <a href="http://www.dependencywalker.com/" rel="nofollow noreferrer">dependencywalker</a> to determine the correct version. Right click on any of the DLLs and click on properties and it will show you the location from which this DLL is being picked. <img src="https://i.stack.imgur.com/8tYzD.png" alt="enter image description here"></p> <h2>Packaging your application.</h2> <p>You can try using <a href="http://www.pyinstaller.org/" rel="nofollow noreferrer">PyInstaller</a> to package your application. It would be a convenient way to get the DLL into the target machine.</p>
7,265,378
0
Does [GKLocalPlayer localPlayer] ever return valid info on first call? <p>What is the point of calling...</p> <pre><code>GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; </code></pre> <p>As far as I can tell, this always returns an object will all fields set to nil, regardless of the start of the currently signed in player. It's not until you call...</p> <pre><code>[localPlayer authenticateWithCompletionHandler:^(NSError *error) </code></pre> <p>...that you get a player. Is this call only to get an object to then call authenticateWithCompletionHandler: from?</p> <p>Is it safe to assume that on this very first call, it will never have valid player information? I was assuming that it had the player info for the player logged into Game Center on the device, but that isn't the case (that would be too handy).</p> <p>What should the game do during the time waiting for a valid playerID? On a bad connection, players could have completed achievements and even get a score. I know you're supposed to save information until a connection is made, but without a playerID, I can't save it tagged for a specific player like you would do during a simple failure to send a score.</p> <p>In my above example, player A start the game, get a score and quit the game before they were ever authenticated. Then Player B logs on and starts the game and gets the score from player A.</p> <p>If I save the last playerID and just use that, you get into the situation of player B starting a game after player A and all scores go to player A, or are lost for player A when player B starts.</p> <p>Or is it just not worth worrying about stuff like this because it's &lt;1% likely to ever happen?</p> <p>Or am I just missing the simple solution to all this stuff?</p> <p>Game Center is just a complete mess of edge cases. Apple could have done a much better job on this API.</p>
15,170,669
0
<p>Here View reference your Button's View. So you need to create object for parent layout an then</p> <pre><code>layout.setBackgroundColor(Color.GREEN); </code></pre>
17,771,028
0
<p>Try this:</p> <pre><code>typedef char board[10][10]; </code></pre> <p>Then you can define new array as this:</p> <pre><code>board double_array = {"hello", "world"}; </code></pre> <p>It's the same with:</p> <pre><code>char double_array[10][10] = {"hello", "world"}; </code></pre>
15,579,877
0
<p>You can go directly to your project's plist and modify it.</p>
8,185,870
0
Using boost::tuple in tr1::hash <p>I want to define <code>std::tr1::hash&lt;boost::tuple&lt;A,B,C&gt; &gt;</code>. But I get an error that doesn't appear when I give a complete instantation. Here's the code</p> <pre><code>namespace std{ namespace tr1{ template&lt;typename A, typename B, typename C&gt; struct hash&lt;boost::tuple&lt;A,B,C&gt; &gt;{ size_t operator()(const boost::tuple&lt;A,B,C&gt; &amp;t) const{ size_t seed = 0; boost::hash_combine(seed, t.get&lt;0&gt;()); boost::hash_combine(seed, t.get&lt;1&gt;()); boost::hash_combine(seed, t.get&lt;2&gt;()); return seed; } }; template&lt;&gt; struct hash&lt;boost::tuple&lt;int,int,int&gt; &gt;{ size_t operator()(const boost::tuple&lt;int,int,int&gt; &amp;t) const{ size_t seed = 0; boost::hash_combine(seed, t.get&lt;0&gt;()); boost::hash_combine(seed, t.get&lt;1&gt;()); boost::hash_combine(seed, t.get&lt;2&gt;()); return seed; } }; } } </code></pre> <p>The first piece gives this error</p> <pre><code>unordered.hpp: In member function 'size_t std::tr1::hash&lt;boost::tuples::tuple&lt;A, B, C, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt;::operator()(const boost::tuples::tuple&lt;A, B, C, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt;&amp;) const': unordered.hpp:12: error: expected primary-expression before ')' token unordered.hpp:13: error: expected primary-expression before ')' token unordered.hpp:14: error: expected primary-expression before ')' token </code></pre> <p>and the second compiles just fine. What's wrong with the first template? I'm using gcc 4.3.4.</p>
35,314,496
0
<p>I guess the <code>word_list</code>(try to rename the variable to <code>word_dict</code>, I think that is more appropriate) has lots of items, </p> <pre><code>for index, data in enumerate(sentence): for key, value in word_list.iteritems(): if key in data: sentence[index]=data.replace(key, word_list[key]) </code></pre> <p>working example from <code>ipython</code></p> <pre><code>In [1]: word_list = { "hello" : "1", "bye" : "2"} In [2]: sentence = ['hello you, hows things', 'hello, good thanks'] In [3]: for index, data in enumerate(sentence): ...: for key, value in word_list.iteritems(): ...: if key in data: ...: sentence[index]=data.replace(key, word_list[key]) ...: In [4]: sentence Out[4]: ['1 you, hows things', '1, good thanks'] </code></pre>
14,649,163
0
Distinct Query? <p>I have a table that contains a Column with client names. It has about 10-15 distinct clients that appear multiple times in the column. Is there a way that I can run a query that will list all the distinct clients and do the count for each client so that it shows how many times each client appears in the column? I know that in SQL you can use as to assign temporary column, but I'm new to LINQ and have no idea if this is possible.</p> <p>Any help would be great, thanks.</p>
32,260,341
0
<p>You might be using the <strong>3.x</strong> version of jstree which does not take the rel attribute into account. If you are using the 3.x version, more information can be found at this link : <a href="https://github.com/vakata/jstree/issues/473" rel="nofollow">https://github.com/vakata/jstree/issues/473</a></p>
36,648,138
0
<p>The same behaviour as with <code>$.Deferred</code> in <code>jQuery</code> you can archive in <code>Java 8</code> with a class called <code>CompletableFuture</code>. This class provides the API for working with <code>Promises</code>. In order to create async code you can use one of it's <code>static</code> creational methods like <code>#runAsync</code>, <code>#supplyAsync</code>. Then applying some computation of results with <code>#thenApply</code>.</p>
13,755,681
0
<p><code>git add .</code> will add any files in the current directory and any sub-directories. I would imagine that you could also do <code>git add .\relative\path\to\file</code> as well. If the file still resists, force a change (add a new line somewhere in the file where it won't hurt anything) and try again. Sometimes the diff that git runs doesn't detect that the file has changed.</p>
24,617,842
0
<p>Here's a quick and easy way, so long as your background is a solid color.</p> <p>HTML:</p> <pre><code>&lt;p class="myCopy"&gt; &lt;span&gt;My Text goes here&lt;/span&gt; &lt;/p&gt; </code></pre> <p>CSS:</p> <pre><code>.myCopy { display: block; height: 10px; border-bottom: solid 1px #000; text-align: center; } .myCopy span { display: inline-block; background-color: #fff; padding: 0 10px; } </code></pre> <p>Adjust the height value of .myCopy to move the line up and down. Change the background color of the inner span to match the primary background color.</p> <p>EDIT: here's a fiddle - <a href="http://jsfiddle.net/znVEL/" rel="nofollow">FIDDLE!!!</a></p>
24,447,866
0
HTTP Requests going to wrong VirtualHost apache2 <p>Hoping someone can lend me a hand here as this has been bugging me for a few days now.</p> <p>I have a apache config file, it does both standard HTTP server work as well as reverse proxy for pages within the network. </p> <p>If i create a new DNS A record for the IP address of the apache server it will automatically send the request to the camera1.domainname.com virtual host and then forward me 192.168.2.160. </p> <p>What i want it to to do is send it to the folder /var/www/bad_url.</p> <p>Any suggestions here would be great as im pretty sure im going to start loosing hair.</p> <pre><code>NameVirtualHost * </code></pre> <p></p> <pre><code>ErrorLog ${APACHE_LOG_DIR}/error_baduri.log CustomLog ${APACHE_LOG_DIR}/access_baduri.log combined DocumentRoot /var/www/bad_url </code></pre> <p></p> <p></p> <pre><code>ProxyPreserveHost On ErrorLog ${APACHE_LOG_DIR}/error_cam1.log CustomLog ${APACHE_LOG_DIR}/access_cam1.log combined LogLevel debug ProxyPass / http://192.168.2.160/ ProxyPassReverse / http://192.168.2.160/ ServerAlias camera1.domainname.com </code></pre> <p></p> <p></p> <pre><code>ProxyPreserveHost On ErrorLog ${APACHE_LOG_DIR}/error_mediaserver.log CustomLog ${APACHE_LOG_DIR}/access_mediaserver.log combined LogLevel debug ProxyPass / http://192.168.2.207/ ProxyPassReverse / http://192.168.2.207/ ServerAlias mediaserver.domainname.com </code></pre> <p></p> <p></p> <pre><code>ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ServerAlias ubuntu1 ubuntu1.domainname.com 192.168.2.208 DocumentRoot /var/www/html </code></pre> <p></p> <p>All the above is in file 'etc/apache2/sites-enabled/default.conf'. There are no other config files in that folder.</p> <p>Im running Ubuntu</p>
2,162,907
0
<p>You could.</p> <ul> <li>Poll mouse coords until it's within a certain radius of your app.</li> <li>Position an invisible, always-on-top form above the docked app and have it fire a MouseEnter event.</li> </ul> <p>That's all I can think of really. Either.</p>
36,136,227
0
Visual c# Read DataGridView data and show in PictureBox <p>im sorry fot being a newbie on this language. Here's my simple situation.</p> <p>I have a DataGrid where i put my inventory items in this way:</p> <pre><code> public void UpdateInventoryListUI() { dGridInvetory.RowHeadersVisible = false; dGridInvetory.ColumnCount = 2; dGridInvetory.Columns[0].Name = "Name"; dGridInvetory.Columns[0].Width = 112; dGridInvetory.Columns[1].Name = "Quantity"; dGridInvetory.Rows.Clear(); foreach (InventoryItem inventoryItem in mainForm1._player.Inventory) { if (inventoryItem.Quantity &gt; 0) { dGridInventory.Rows.Add(new[] { inventoryItem.Details.Name, oggettoInventory.Quantity.ToString() }); } } } </code></pre> <p>Ok it works fine and show me my items. Now i want to create an event that when i select with mouse the Row (entire Row - so the name and the quantity) it shows me in the picture box the image of that item. I need to know how to read the STRING like below:</p> <pre><code> private void dGridInventory_MouseClick(object sender, MouseEventArgs e) { if(// the string "Name" on row is == "Mask_DPS"){ picBoxMask.Image = Properties.Resources.MASK_DPS; labelInfo.Text = "This is a dps Mask!"; } if((// the string "Name" on row is == "Mask_TANK"){ picBoxMask.Image = Properties.Resources.MASK_TANK; labelInfo.Text = "This is a tank mask!; //...and so on! } </code></pre> <p>Can you help me please? Just wanna click on the Row and compare the string in the Row. If is the same then show me the image in my picture box.</p> <p>Thank all and sry for my bad english.</p>
36,102,524
0
Passport.js multiple local strategies and req.user <p>The client for my web-app wants to <em>totally</em> separate regular users and admins, hence I'm trying to implement two local strategies for <code>passport.js</code>:</p> <pre><code>passport.use('local', new LocalStrategy({ usernameField: 'email' }, function(email, password, done) { User.findOne({ email: email }, function(err, user) { if (err) return done(err); if (!user) return done(null, false, { message: 'Wrong email or password.' }); if (!user.validPassword(password)) return done(null, false, { message: 'Wrong email or password.' }); done(null, user); }); })); passport.use('admin', new LocalStrategy({ usernameField: 'email' }, function(email, password, done) { Admin.findOne({ email: email }, function(err, admin) { if (err) return done(err); if (!admin) return done(null, false, { message: 'Wrong email or password.' }); if (!admin.validPassword(password)) return done(null, false, { message: 'Wrong email or password.' }); done(null, admin); }); })); passport.serializeUser(function(user, done) { done(null, user.id); }); passport.deserializeUser(function(id, done) { Admin.findById(id, function(err, admin) { if (err) return done(err); if (admin) return done(null, admin); User.findById(id, function(err, user) { done(err, user); }); }); }); </code></pre> <p>And then in my API admin router:</p> <pre><code>router.post('/', function(req, res, next) { if (typeof req.body.email === 'undefined') return res.json({ success: false, message: 'Email not supplied.' }); if (!validator.isEmail(req.body.email)) return res.json({ success: false, message: 'Wrong email format.' }); if (typeof req.body.password === 'undefined') return res.json({ success: false, message: 'Password not supplied.' }); if (req.body.password.length === 0) return res.json({ success: false, message: 'Password not supplied.' }); passport.authenticate('admin', function(err, admin, info) { if (!admin) return res.json({ success: false, message: info.message }); req.logIn(admin, function(err) { if (err) return res.json({ success: false, message: 'Server error.', reason: err }); console.log('user:'); console.log(req.user); // both users and admins go here console.log('admin:'); console.log(req.admin); // undefined res.json({ success: true }); }); })(req, res, next); }); </code></pre> <p>In fact, I was following the answer here: <a href="http://stackoverflow.com/a/21898892/1830420">http://stackoverflow.com/a/21898892/1830420</a>, and Matthew Payne gets two session variables: <code>req.user</code> and <code>req.sponsor</code>. In my case, even if an admin authenticates, it gets written to <code>req.user</code>. Now, trying to implement my client's desire of totally separating users and admins, I want to get <code>req.user</code> and <code>req.admin</code>, but every time it gets written to <code>req.user</code>. I thought changing LocalStrategy name would help, but <code>passport.js</code> seems to ignore both the strategy name <em>and</em> model name.</p> <p>Any help is very much appreciated.</p> <p>P.S. I know I can have everyone in <code>User</code> model and write some middleware to protect certain routes based on roles, but then again, unfortunately, I don't get to choose here.</p>
6,335,860
0
<p>The sort of thing you want to do could probably be done more easily using a class factory function like the following. At least for me, it makes it more straightforward to keep straight the various levels at which I'm trying to operate.</p> <pre><code>def listOf(base, types={}, **features): key = (base,) + tuple(features.items()) if key in types: return types[key] else: if not isinstance(base, type): raise TypeError("require element type, got '%s'" % base) class C(list): def __init__(self, iterable=[]): for item in iterable: try: # try to convert to desired type self.append(self._base(item)) except ValueError: raise TypeError("value '%s' not convertible to %s" % (item, self._base.__name__)) # similar methods to type-check other list mutations C.__name__ = "listOf(%s)" % base.__name__ C._base = base C.__dict__.update(features) types[key] = C return C </code></pre> <p>Note that I'm using a <code>dict</code> as a cache here so that you get the same class object for a given combination of element type and features. This makes <code>listOf(int) is listOf(int)</code> always <code>True</code>.</p>
37,823,979
0
<p>I moved my tblk file to the desktop and then it was able to add it. For some reason, when the file is in the Downloads folder, it won't add it</p>
27,164,964
0
<p>Simple do this</p> <pre><code>outerObj = Object[1]; System.out.println(outerObj[0]); </code></pre>
27,093,982
0
<p>I struggeld for many hours on this. This is my loop to register command line vars. Example : Register.bat /param1:value1 /param2:value2</p> <p>What is does, is loop all the commandline params, and that set the variable with the proper name to the value.</p> <p>After that, you can just use set value=!param1! set value2=!param2!</p> <p>regardless the sequence the params are given. (so called named parameters). Note the !&lt;>!, instead of the %&lt;>%.</p> <pre><code>SETLOCAL ENABLEDELAYEDEXPANSION FOR %%P IN (%*) DO ( call :processParam %%P ) goto:End :processParam [%1 - param] @echo "processparam : %1" FOR /F "tokens=1,2 delims=:" %%G IN ("%1") DO ( @echo a,b %%G %%H set nameWithSlash=%%G set name=!nameWithSlash:~1! @echo n=!name! set value=%%H set !name!=!value! ) goto :eof :End </code></pre>
28,185,238
0
<p>Tokuriku, thanks so much, you we're not quite right but it got me to the eventual answer, here it is </p> <pre><code>import SpriteKit class GameScene: SKScene { var circleTouch: UITouch? override func didMoveToView(view: SKView) { /* Setup your scene here */ let circle = SKShapeNode(circleOfRadius: 40.0) circle.fillColor = UIColor.blackColor() circle.position = CGPoint(x: size.width * 0.5, y: size.height * 0.2) circle.name = "userCircle" addChild(circle) } override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { for touch in touches { if nodeAtPoint(touch.locationInNode(self)).name == "userCircle" { circleTouch = touch as? UITouch } } } override func touchesMoved(touches: NSSet, withEvent event: UIEvent) { for touch in touches { if circleTouch != nil { if touch as UITouch == circleTouch! { let location = touch.locationInNode(self) let touchedNode = nodeAtPoint(location) touchedNode.position = location } } } } override func touchesEnded(touches: NSSet, withEvent event: UIEvent) { for touch in touches { if circleTouch != nil { if touch as UITouch == circleTouch! { circleTouch = nil } } } } </code></pre>
13,392,907
0
How to implement secure FTP connection on iOS <p>Apple provide a CFNetwork guide, where described how to work with FTP. I interested to work with SFTP. Everywhere chilkat ftp library is suggested, but he has a too big feature list, that is unnecessary to pay. Are there any way to connect to SFTP only for download, upload and viewing directory lists?</p>
28,613,694
0
<p>You can use relative imports</p> <pre><code># inside subdirectory/script.py from .. import important_file </code></pre> <p>but really the best solution is to add it to your <code>PYTHONPATH</code> and do</p> <pre><code>import proj.important_file </code></pre>
14,649,010
0
<p>You could extend a custom class from EditText with a method that will store the current text into a private member variable. In your Activity's onResume() method you would then call this method. Whenever you want to reset the EditText's text to its original text, you would then call another simple method that will set the current text to the text stored before.</p> <pre><code>public class MyEditText extends EditText { private String mStoredText; public MyEditText(Context context) { super(context); } public MyEditText(Context context, AttributeSet attrs) { super(context, attrs); } public void storeText() { mStoredText = getText().toString(); } public void restoreText() { setText(mStoredText); } } </code></pre>
15,920,353
0
<p><strong>Have connection string format as:</strong></p> <pre><code>String DBConnection = "Data Source=27.0.0.1;;Initial Catalog=Darkride;User ID=userIDText;Password=PasswordText"; </code></pre>
33,071,993
0
defer events when table is being populated <p>I'm creating a simple dropdown plugin where the values of the dropdown were in tabular manner.</p> <p>what I want is to halt the event while my table is being loaded.</p> <p>here's my code.</p> <pre><code> //appendTableForThePanel $('#appendHere').append('&lt;table class="table table-hover table-condensed"&gt;&lt;/table&gt;'); $('#appendHere').find('table').append('&lt;thead&gt;&lt;/thead&gt;'); $('#appendHere').find('table').append('&lt;tbody&gt;&lt;/tbody&gt;'); $('#appendHere').find('table').find('thead').append('&lt;tr&gt;&lt;/tr&gt;'); for(appendCountHeader = 0; appendCountHeader &lt; tableHeader.length; appendCountHeader++ ){ $('#appendHere').find('table').find('thead').find('tr').append('&lt;th&gt;'+tableHeader[appendCountHeader]+'&lt;/th&gt;'); } //count tbody tbody_tr var tbody_tr = tbody.length / tableHeader.length; //count how many column / row var tbody_td = tbody.length / tbody_tr; //append tbody tr tdcontent for(var i = 0; i &lt; tbody.length; i += tbody_td) { $newRow = $("&lt;tr&gt;"); for(var j = 0; j &lt; tbody_td; j++) { $newRow.append( $("&lt;td&gt;").html(tbody[i + j]) ); } $("#appendHere").find('table').find('tbody').append($newRow); } $('body').on('click', '#appendHere table tbody tr', function() { // alert($(this).find('td:nth-child(1)').html() + ' : ' + $(this).find('td:nth-child(2)').html()); $($element.selector).val($(this).find('td:nth-child(2)').html()); $('#appendHere').hide(); }); // **I want to deferred below functions when the table is appending** $($element.selector).blur(function(){ setTimeout(function(){ $('#appendHere').hide(); }, 200); }); $($element.selector).on('click', function(){ $('#appendHere').show(); }); $($element.selector).keyup(function(){ }); </code></pre> <p>I know it is possible but I can't grasp the idea of deferring a function.</p> <p>thanks in advance.</p>
31,321,807
0
Route is not triggerd with Attribute Routing and FromUri <p>I want to trigger the below route with this url:</p> <pre><code>http://localhost:66777/api/productdetails?articlegroup=1&amp;producedat=2012-01-01 </code></pre> <p>What is wrong with my - I guess - Route attribute?</p> <pre><code>[Route("api/productdetails/{articlegroup:int}/{producedat:datetime}")] [HttpGet] public async Task&lt;IHttpActionResult&gt; GetProductDetails([FromUri] ProductDetailsRequestDTO dto) { //... } public class ProductDetailsRequestDTO { public int ArticleGroup { get; set; } public DateTime ProducedAt { get; set; } } </code></pre>
27,161,929
0
<p>You should get a debugger working. It would provide you with the answer to your question within seconds, and it's essential for trying to track down these kinds of problems. What seems very mystifying and unclear, when you're trying to interpret the output, will seem very easy when you're stepping through it, and you can see everything.</p> <p>This will probably lead to pipe() not doing what you expect, you'll check errno, and presumably get a useful answer.</p> <p>The commenter's advise about avoiding doing stuff in signal handlers is good, as it's not portable. However, most modern OSs are quite permissive, so I'm not sure if that's your problem in this case.</p>
30,259,019
0
<p>Install Terminal Emulator from Play Store, open the application and type:</p> <p><code>getprop ro.build.version.release</code> you will get something like: <code>4.4.4</code> for KitKat.</p> <p>or <code>getprop ro.build.version.sdk</code> for getting the sdk version which will return <code>19</code></p>
19,507,638
0
<p>There's no need to strip the square brackets. Simply call <code>json_decode()</code> on the data and retrieve your information.</p> <p><strong>Note:</strong> the data in the form you have it decodes to an array of objects, with just one object, so you need to provide an array subscript:</p> <pre><code>$json = json_decode("My JSON Data...here"); echo $json[0]-&gt;address; </code></pre> <p>See <a href="http://phpfiddle.org/main/code/r4g-552" rel="nofollow">this fiddle</a></p> <p><strong>2nd Note:</strong> the data as you have posted it has embedded newlines which caused a problem with <code>json_decode()</code>. If you have those in your original data you'll need to strip them before decoding. I edited them out in the fiddle.</p>
2,210,128
0
<p>You are using the wrong tools. </p> <p>In .NET 4.0 they introduced the Task Parallel Library. This allows you to do things like use multiple thead pools as well as have parent-child relationships between work items.</p> <p>Start with the Task class, which replaces ThreadPool.QueueUserWorkItem.</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.threading.tasks.task(VS.100).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.threading.tasks.task(VS.100).aspx</a></p> <p><strong>EDIT</strong></p> <p>Example of creating your own thread pool using Task and TaskScheduler.</p> <p><a href="http://msdn.microsoft.com/en-us/library/dd997413(VS.100).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dd997413(VS.100).aspx</a></p>
20,270,559
0
<p>Firstly you don't need to convert <code>decimal</code> to <code>decimal</code>, secondly <code>Text</code> is a <code>string</code> property, so you need to turn <code>result</code> into a <code>string</code>, so replace:</p> <pre><code>txt_WeightGrams.Text = Convert.ToDecimal(result); </code></pre> <p>with this:</p> <pre><code>txt_WeightGrams.Text = result.ToString(); </code></pre>
39,764,591
0
<p>I was using inside a loop and was cloning the same reference object, so deleting the same var.</p> <p>Sorry for my mistake and thank you for showing me that the code runs correctly.</p> <p>ie: you can add all -1 that you want. Sorry again</p>
4,745,461
0
SQLNamedQuery in Spring hibernate Error <p>Following is the my code.</p> <pre><code>&lt;sql-query name="findPreviousQuestionnarieId"&gt; &lt;return-scalar column="questionId" type="long" /&gt; &lt;![CDATA[select max(B.Questionnaire_Id) as questionId from dbo.Rme_Questionnaire_Answer_Header A,Rme_Questionnaire_Answer_Header B where A.Questionnaire_Id = : currentQuesId and B.Questionnaire_Id &lt; A.Questionnaire_Id and A.Questionnaire_Code = B.Questionnaire_Code]]&gt; &lt;/sql-query&gt; </code></pre> <p>Error while starting server is,</p> <blockquote> <p>Errors in named queries: com.mmm.rme.core.domain.evaluation.QuestionnaireResponseHeader.findPreviousQuestionnarieId</p> </blockquote> <p>the method i am using to access is,</p> <pre><code>results = this.getHibernateTemplate().findByNamedParam(namedQuery, paramName, value); </code></pre>
24,433,630
0
What's required in order to get OAuth2 credentials for my marketplace app? <p>I've created a small application that utilizes the <a href="https://developers.google.com/gmail/" rel="nofollow noreferrer">recently announced Gmail API</a> to search received e-mails for a specific string. My new is app published as hidden in the Chrome / Google Apps store, and I've read that I should be given OAuth2 credentials to use with my application.</p> <p>For example, <a href="https://developers.google.com/google-apps/help/articles/2lo-in-tasks-for-marketplace" rel="nofollow noreferrer">this guide (for the old apps marketplace, which is no longer usable)</a> shows where a developer can go to grab credentials for their marketplace app:</p> <p><img src="https://i.stack.imgur.com/n2ecs.png" alt="enter image description here"></p> <p>However in the new store, I cannot find anywhere that makes these credentials available to me.</p> <p>Have I missed a step? Do I need to complete a <a href="https://docs.google.com/a/consuslabs.com/forms/d/14QOb8PbSLKDgwIp8Zv-luoAAVurPXUqtzL0Hgikp3rk/viewform" rel="nofollow noreferrer">Google Apps Marketplace Listing Review Request</a> in order to be provided credentials?</p> <p>Thanks!</p> <h1>Updated with solution</h1> <p>The user MeLight has the answer below - generate service account credentials, then use them after making sure that the project has been linked to the marketplace app in the Chrome Web Store. For any future Googlers, here's the code used to connect to the API and create a <code>service</code> object, which can be used for getting messages, etc.</p> <pre><code>from oauth2client.client import SignedJwtAssertionCredentials from apiclient.discovery import build from oauth2client.tools import run import os import httplib2 BASEDIR = os.path.dirname(__file__) PRIVATE_KEY = BASEDIR + "XXXX-privatekey.p12" SERVICE_ACCOUNT_EMAIL = "[email protected]" SCOPES = ["https://mail.google.com/"] USERNAME="[email protected]" def main(argv): f = file(PRIVATE_KEY, 'rb') key = f.read() f.close() credentials = SignedJwtAssertionCredentials(service_account_name=SERVICE_ACCOUNT_EMAIL, private_key=key, scope=" ".join(SCOPES), prn=USERNAME) http = httplib2.Http() # Authorize the httplib2.Http object with our credentials http = credentials.authorize(http) # Build the Gmail service from discovery service = build('gmail', 'v1', http=http) </code></pre>
33,577,880
0
How to deeplink to product page for Amazon Shopping app in Android? <p>Using Intents/Activities, how can I programatically deeplink / launch the Amazon Shopping app to the landing page of a particular product in Android?</p>
8,848,390
0
Eclipse Mac to Windows notepad formatting no carriage return <p>I am using eclipse on mac to do my java coding.</p> <p>Now i need to open a .java file that was created with mac eclipse and open it in a Windows notepad.</p> <p>However all the carriage return/ newline formatting is gone.</p> <p>Is there a way where I can retain all the formatting?</p>
15,444,495
0
<p>The webkit bug mentioned in @Phrogz answer seems to have been fixed in more recent versions, so I found a solution that doesn't require a manual parse is</p> <pre><code>// from http://bl.ocks.org/biovisualize/1209499 // via https://groups.google.com/forum/?fromgroups=#!topic/d3-js/RnORDkLeS-Q var xml = d3.select("svg") .attr("title", "test2") .attr("version", 1.1) .attr("xmlns", "http://www.w3.org/2000/svg") .node().parentNode.innerHTML; // from http://webcache.googleusercontent.com/search?q=cache:http://phpepe.com/2012/07/export-raphael-graphic-to-image.html // via http://stackoverflow.com/questions/4216927/problem-saving-as-png-a-svg-generated-by-raphael-js-in-a-canvas var canvas = document.getElementById("myCanvas") canvg(canvas, svgfix(xml)); document.location.href = canvas.toDataURL(); </code></pre> <p>which requires <a href="https://code.google.com/p/svgfix/" rel="nofollow">https://code.google.com/p/svgfix/</a> and <a href="https://code.google.com/p/canvg/" rel="nofollow">https://code.google.com/p/canvg/</a> and uses d3.js to obtain the svg source, which should be doable without d3.js as well (but this takes care of adding required metadata which can lead to problems when missing).</p>
7,198,394
0
<p>For IIS 7+, you're only missing the part that defines <em>which</em> httpErrors to handle with custom handlers:</p> <pre><code>&lt;configuration&gt; &lt;system.webServer&gt; &lt;httpErrors errorMode="Custom"&gt; &lt;remove statusCode="500" /&gt; &lt;error statusCode="500" path="~/Views/Shared/Error.aspx" /&gt; &lt;/httpErrors&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <p>(The <code>&lt;remove /&gt;</code> tag is optional, depending on your web.config hierarchy.)</p> <p>For IIS 6 and below, You have to set this via the IIS Manager by going to the appropriate Properties page, Custom Errors tab, then edit the appropriate HTTPError line to "Message type:" "URL" and "URL:" "~/Views/Shared/Error.aspx".</p>
22,508,299
0
<p>You need a little P/invoke:</p> <pre><code>add-type -type @' using System; using System.Runtime.InteropServices; using System.ComponentModel; using System.IO; namespace Win32Functions { public class ExtendedFileInfo { public static long GetFileSizeOnDisk(string file) { FileInfo info = new FileInfo(file); uint dummy, sectorsPerCluster, bytesPerSector; int result = GetDiskFreeSpaceW(info.Directory.Root.FullName, out sectorsPerCluster, out bytesPerSector, out dummy, out dummy); if (result == 0) throw new Win32Exception(); uint clusterSize = sectorsPerCluster * bytesPerSector; uint hosize; uint losize = GetCompressedFileSizeW(file, out hosize); long size; size = (long)hosize &lt;&lt; 32 | losize; return ((size + clusterSize - 1) / clusterSize) * clusterSize; } [DllImport("kernel32.dll")] static extern uint GetCompressedFileSizeW([In, MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [Out, MarshalAs(UnmanagedType.U4)] out uint lpFileSizeHigh); [DllImport("kernel32.dll", SetLastError = true, PreserveSig = true)] static extern int GetDiskFreeSpaceW([In, MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName, out uint lpSectorsPerCluster, out uint lpBytesPerSector, out uint lpNumberOfFreeClusters, out uint lpTotalNumberOfClusters); } } '@ </code></pre> <p>Use like this:</p> <pre><code>[Win32Functions.ExtendedFileInfo]::GetFileSizeOnDisk( 'C:\ps\examplefile.exe' ) 59580416 </code></pre> <p>it returns the 'size on disk' that you read in properties file from explore.</p>
38,802,136
0
Is it possible to send or receive data on traditional request /response basis using Firebase <p>Our requirement is to send or receive data on traditional synchronous request and response basis using Fire base. Rather than updating all connected clients when ever a piece of data changes at server . Going through your Docs... Fire base REST is some thing that looks fits our requirement. Please suggest if anyone have tried it or there is any other way to achieve the same using Fire base.</p>
6,840,515
0
<p>AWT and Applets aren't available for Java ME. Due to the screen size limitations and restricted user interactions, the MIDP UI API is designed for mobile devices comprising of the high level and low level UI. Look at <a href="http://download.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/index.html" rel="nofollow">Java ME documentation</a>. </p> <p>You can use <a href="http://developers.sun.com/mobility/midp/articles/gameapi/" rel="nofollow">Canvas</a> and draw the circle. Refer more info look at following links,</p> <ul> <li><a href="http://developers.sun.com/mobility/midp/articles/ui/" rel="nofollow">MIDP GUI Programming: Programming the Phone Interface</a></li> <li><a href="http://www.javaworld.com/javaworld/jw-05-2005/jw-0516-midp.html" rel="nofollow">MIDP user interface</a></li> <li><a href="http://www.developer.com/java/j2me/article.php/10934_1561591_1" rel="nofollow">MIDP Programming with J2ME</a></li> </ul> <p><strong>FYI:</strong> You can use <a href="http://stackoverflow.com/questions/6152237/what-is-lwuit-light-weight-user-interface-toolkit">LWUIT framework.</a> LWUIT provides many useful Swing-like features. </p>
2,703,951
0
<ol> <li><p>Currying does not hurt. Currying sometimes introduces closures as well. They are usually efficient too. refer to <a href="http://stackoverflow.com/questions/1974586/making-functions-inline-avoids-closure">this question</a> I asked before. You can use inline to boost performance if necessary. </p></li> <li><p>However, your performance problem in the example is mainly due to your code:</p> <p><code>normalize p |&gt; (Set.ofList setElems).Contains</code></p></li> </ol> <p>here you need to perform <code>Set.ofList setElems</code> even you curry it. It costs O(n log n) time. You need to change the type of <code>setElems</code> to F# Set, not List now. Btw, for small set, using lists is faster than sets even for querying. </p>
5,128,918
0
<p>You need to initialize your new structure with zeros. GetMem does not zero the allocated memory, so the fields of your record initially contain random garbage. You need to call</p> <p><code>FillChar(newItem^, sizeof(TAccessoryItem), 0)</code> </p> <p>after the GetMem, before using the record.</p> <p>Here's why: When you assign to the string field of the newly allocated but uninitialized record, the RTL sees that the destination string field is not null (contains a garbage pointer) and attempts to dereference the string to decrement its ref count before assigning the new string value to the field. This is necessary on every assignment to a string field or variable so that the previous string value will be freed if nothing else is using it before a new value is assigned to the string field or variable.</p> <p>Since the pointer is garbage, you get an access violation... if you're lucky. It is possible that the random garbage pointer could coincidentally be a value that points into an allocated address range in your process. If that were to happen, you would not get an AV at the point of assignment, but would likely get a much worse and far more mysterious crash later in program execution because this string assignment to an uninitialized variable has altered memory somewhere else in your process inappropriately.</p> <p>Whenever you're dealing with memory pointers directly and the type you're allocating contains compiler managed fields, you need to be very careful to initialize and dispose the type so that the compiler managed fields get initialized and disposed of correctly.</p> <p>The best way to allocate records in Delphi is to use the New() function:</p> <pre><code>New(newItem); </code></pre> <p>The compiler will infer the allocation size from the type of the pointer (sizeof what the pointer type points to), allocate the memory, and initialize all the fields appropriately for you.</p> <p>The corresponding deallocator is the Dispose() function:</p> <pre><code>Dispose(newItem); </code></pre> <p>This will make sure that all the compiler-managed fields of the record are disposed of correctly in addition to freeing the memory used by the record itself. </p> <p>If you just FreeMem(newItem), you will leak memory because the memory occupied by the strings and other compiler managed fields in that record will not be released.</p> <p>Compiler managed types include long strings ("String", not "string[10]"), wide strings, variants, interfaces, and probably something I've forgotten.</p> <p>One way to think about is this: GetMem/FreeMem simply allocate and release blocks of memory. They know nothing about how that block will be used. New and Dispose, though, are "aware" of the type you're allocating or freeing memory for, so they will do any additional work to make sure that all the internal housekeeping is taken care of automatically. </p> <p>In general, it's best to avoid GetMem/FreeMem unless all you really need is a raw block of memory with no type semantics associated with it.</p>
32,085,424
0
<p>Guan, have you tried with an earlier version of the JDK (e.g., JDK-1.5?). I realize it's much older, but I'm curious if it's related to using the CLT on JDK 1.8. Just an idea.</p> <p>Additionally, it would help if we could see the turk.properties file (please don't share your access keys or secret key) to make sure the endpoints are well-formed. Thanks!</p>
9,735,722
0
Running a JSF-2 page using embedded Jetty? <p>Is it possible to start up a JSF-2 page (assuming I have the *.html and backing bean) using embedded Jetty?</p> <p>By Embedded Jetty I mean something like the following (but obviously coupled with a JSF page)</p> <pre><code>import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; public class HelloHandler extends AbstractHandler { public void handle(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html;charset=utf-8"); response.setStatus(HttpServletResponse.SC_OK); baseRequest.setHandled(true); response.getWriter().println("&lt;h1&gt;Hello World&lt;/h1&gt;"); } public static void main(String[] args) throws Exception { Server server = new Server(8080); server.setHandler(new HelloHandler()); server.start(); server.join(); } } </code></pre>
4,688,595
0
How to query more than 5000 records in Flex Salesforce app? <p>I've run into an issue where Salesforce will only return 1000 records to my flex app from a query. I'd like to get more than that (like 5000-10000). Is this possible?</p> <p>Here is what I have tried (app is an F3WebApplication)<br> note:this code does work, I just need it to return more results:</p> <pre><code>app.wrapper.query(query, new mx.rpc.Responder( function(rows:ArrayCollection):void { if(user_list != null){ filteredList = addOwnerData(rows); filteredList = PutChildrenWithParents(filteredList); } else { filteredList = PutChildrenWithParents(rows); } my_accounts_raw = new ArrayCollection(filteredList.toArray()); refreshSearchData(filteredList); }, function():void{_status = "apex error!";} ) ); } </code></pre> <p>I've also tried app.connection.Query to then use queryMore but can't get that to work at all.<br> Any ideas?</p>
19,269,802
0
How to set css for chrome and mozila for responsive design? <p>I am new to CSS, Bootstrap &amp; HTML.</p> <p>I am trying to display search-box on my web page, in Mozilla it works fine but in Chrome it is not working.</p> <p><strong>Here is the screen shot of Mozilla browser:</strong></p> <p><img src="https://i.stack.imgur.com/oY3XQ.png" alt="enter image description here"></p> <p><strong>and this is of Chrome:</strong></p> <p><img src="https://i.stack.imgur.com/wFUnl.png" alt="enter image description here"></p> <p>Also note that when i increase or decrease screen resolution the control's gets scattered badly .Following is HTML code snippet responsible for this display:</p> <pre><code>&lt;body&gt; &lt;section id="customers"&gt; &lt;div class="container" style="margin-top:0px;"&gt; &lt;div class="row"&gt; &lt;div class="col-lg-12 &lt;form class="form-inline" role="form" style="background:#eee"&gt; &lt;div class="form-group"&gt; &lt;input id="" class="leftText" type="text" value="" tabindex="1" name="query" autocomplete="off" placeholder="I am looking for" &gt;&lt;/input&gt; &lt;strong &gt;in&lt;/strong&gt; &lt;input id="" class="rigtTextBox" type="text" value="" tabindex="1" name="query" autocomplete="off" helptext="In the location" placeholder="In the location"&gt;&lt;/input&gt; &lt;select class="rightcitydropdown"&gt; &lt;option&gt;Mumbai&lt;/option&gt; &lt;option&gt;Pune&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;button class="btn btn-primary" id="srchBtn" &gt;Ask Me&lt;/button&gt; &lt;/div&gt;&lt;!--end of col-lg-12--&gt; &lt;/form&gt; &lt;/div&gt;&lt;!--end of row--&gt; &lt;/div&gt;&lt;!--end of container--&gt; &lt;/section&gt; &lt;/body&gt; </code></pre> <p>following in my CSS for above controls:</p> <pre><code> .leftText{ float :left; border-style:solid; border-width:5px; border-color:#989898 ; height:38px; } .rigtTextBox{ border-style:solid; border-width:5px; border-right-width:1px; height:38px; border-color:#989898 ; } .form-control{ border-style:solid; border-width:5px; border-left-width:1px; border-color:#eee; font-size:10px; height:30px; } .form{ border-width:5px; border-left-width:1px; border-color:#eee; font-size:10px; } .rightcitydropdown{ float:right; border-style:solid; border-width:5px; border-left-width:1px; border-color:#989898 ; margin-right:17px; background:white;height:38px; } #searchOuterdiv{ background:#F0F0F0; } #centralRow{ margin-top:3px; } strong { float:left; font-size:28px; margin:0px 10px 0 10px; height:30px; line-height:30px; color:#333333; } #srchBtn { background:#4682B4; font-size:18px; line-height:16px; border:none; width:125px; text-align:center;margin-top:6px; height:35px; padding-bottom:5px; cursor:pointer; color:#333; padding-top:0px; margin-left:7px;color:white} </code></pre> <p>So please, can any one tell me how to set CSS or correct written code to make responsive appearance.I want this page to be displayed on multiple resolution screens, say desktop,laptop,tablets e.t.c Thanks in advance.</p>
25,285,265
0
Howto inject local css into webpage <p>I would like to test out CSS on a webpage that I don't have direct access to. Does anyone know how to achieve this ?</p> <p>So I write my CSS, and on save, that code is used on the webpage. Of cause this will only happen on my local machine</p>
35,996,913
0
<p>I had read that for early Windows OS I should use the non-thread safe version of PHP. That version is missing the php5apache2_x.dll which caused doubt about this package. An acquaintance said to use the thread safe version which had the php5apache2_4.dll. It seemed to work in the Windows CMD browser after I set my environment variable to that folder. But digging further, it appears that I should also upgrade my Apache to 2.4 as later PHP and later Apache are using different Visual Studio compilers.</p>
14,590,472
0
<p>It looks like it is just a single object being returned rather than an array so you should be able to access the id property using <strong>data.id</strong> , no need to specify an array index.</p>
26,091,676
0
<pre><code>arr.each_cons(2).select{|array|array.inject(:+) == 0}.count &gt; 0 </code></pre>
39,163,394
0
Put label on a label in netbeans GUI builder <p>Trying desperately to put a label over another label in netbeans because the one label is acting as the background image and I want the label in the foreground to have a different image.</p> <p>Every time i drag another label on top, the JFrame gets bigger and the label tries to slot down the side.</p> <p>Here is what I've got (I want the label where the red circle in the middle is not on the right down the side):</p> <p><a href="https://i.stack.imgur.com/eUJdS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eUJdS.jpg" alt=""></a>:</p>
12,053,136
0
<p>you never call extractRow and displayBoard methods.</p> <p>Call these methods inside start method your code will work properly.</p>
27,234,347
0
<pre><code>Dim intCounter As Integer Dim nmTemp As Name For intCounter = 1 To ActiveWorkbook.Names.Count MsgBox ActiveWorkbook.Names(intCounter) Next intCounter </code></pre>
16,030,872
0
<p>Try something like this:</p> <pre><code>self.array = [[NSMutableArray alloc] init]; MyViewController *vc = self; [MyApp getCampaigns:^(NSArray *response) { [vc.array addObjectsFromArray:response]; }]; </code></pre> <p>This will allow the objective-c compiler to create a strong reference to vc in the block, which will then point to self.</p>
38,962,095
0
Image in ListView that goes off-screen loses its state (never set to 'loaded') <p><strong>The situation:</strong> </p> <p>I have a large list of photos and we are loading them in a grid of thumbnails. These thumbnails are each their own component that are loaded in sets of three within the RenderRow function. Here's the Image component in question:</p> <pre><code>&lt;Image style={styles.image} source={this.state.loaded ? { uri: image.url_small } : imagePlaceholder} onLoad={() =&gt; { this.setState({ loaded: true }); }} onLoadStart={() =&gt; { this.setState({ loaded: false }); }} /&gt; </code></pre> <p><strong>The issue:</strong></p> <p>Our issue is that if you are scrolling rapidly, or have a less-than-optimal internet connection, some of the images that begin loading never have the "onLoad" called, presumably because they are no longer visible (because we scrolled beyond them in the list already). </p> <p>However, when we scroll back to those images, all that is rendered is the placeholder image, and the state of the photo is never set to <code>loaded: true</code>. I've tried messing with the <code>onChangeVisibleRows</code> function on the ListView like so:</p> <pre><code>onChangeVisibleRows={(visibleRows) =&gt; { const visibleRowNumbers = []; for (const row in visibleRows) { visibleRowNumbers.push(row); } this.setState({ visibleRowNumbers }); }} </code></pre> <p>This seems to work as expected and in the RenderRow function I can check if that specific row is visible, and try to re-render and images in that row by passing a <code>isVisible</code> prop to the image component, but the image component still isn't updating when I return true from <code>shouldComponentUpdate</code> when the isVisible prop changes. </p> <p>But to no avail. </p> <p>I believe I'm on the right track, but have hit a dead end. <strong>Does anyone have an idea how I can force an image component to reload?</strong> Or is there some sort of <code>onLoadInterrupted</code> that might be added so that it begins loading again once it is in view?</p>
32,295,315
0
Are compilers able to avoid branching instructions? <p>I've been reading about <a href="http://www.graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">bit twiddling hacks</a> and thought, are compilers able to avoid branching in the following code:</p> <pre><code>constexpr int min(const int lhs, const int rhs) noexcept { if (lhs &lt; rhs) { return lhs; } return rhs } </code></pre> <p>by replacing it with (<a href="http://www.graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax" rel="nofollow">explanation</a>):</p> <pre><code>constexpr int min(const int lhs, const int rhs) noexcept { return rhs ^ ((lhs ^ rhs) &amp; -(lhs &lt; rhs)); } </code></pre>
26,351,797
0
Altering text in a .txt file and creating a new file output in MATLAB <p>I apologize in advance if the title seems a bit off. I was having trouble deciding what exactly I should name it. Anyway, basically what I am doing now is completely homework that deals with low-level I/Os. For my one assignment, I have given two .txt files, one that includes a list of email addresses and another that includes a list members who no longer was to be on an email list. What I have to do is delete the emails of the members from the second list. Additionally, there may be some nasty surprises in the .txt files. I have to clean-up the emails and take out any unwanted punctuation after the emails, such as semi-colons, commas and spaces. Furthermore, I need to lowercase all of the text. I'm struggling with this problem in more ways than one (I'm not entirely sure how to get my file to write what I need it to in my output), but right now my main concern is outputting the unsubscribe message in the correct order. Sortrow doesn't seem to work.</p> <p>Here are some test cases:</p> <pre><code>Test Cases unsubscribe('Grand Prix Mailing List.txt', ... 'Unsubscribe from Grand Prix.txt') =&gt; output file named 'Grand Prix Mailing List_updated.txt' that looks like 'Grand Prix Mailing List_updated_soln.txt' =&gt; output file named 'Unsubscribe from Grand Prix_messages.txt' that looks like 'Unsubscribe from Grand Prix_messages_soln.txt' </code></pre> <p>The original mailing list</p> <pre><code>Grand Prix Mailing List: [email protected], [email protected] [email protected]; [email protected] [email protected], [email protected] [email protected] [email protected]; [email protected] [email protected] [email protected] </code></pre> <p>People who are like nope: </p> <pre><code>MARIO PLUMBER; bowser koopa Luigi Plumber, Donkey Kong King BOO; Princess Peach </code></pre> <p>What it's supposed to look like afterwards:</p> <pre><code>[email protected] [email protected] [email protected] [email protected] [email protected] </code></pre> <p>My file output:</p> <pre><code>Mario, you have been unsubscribed from the Grand Prix mailing list. Luigi, you have been unsubscribed from the Grand Prix mailing list. Bowser, you have been unsubscribed from the Grand Prix mailing list. Princess, you have been unsubscribed from the Grand Prix mailing list. King, you have been unsubscribed from the Grand Prix mailing list. Donkey, you have been unsubscribed from the Grand Prix mailing list. </code></pre> <p>So Amro has been kind enough to provide a solution, though it's a little above what I know right now. My main issue now is that when I output the unsubscribe message, I need it to be in the same order as the original email list. For instance, while Bowser was on the complaining list before Luigi, in the unsubscribe message, Luigi needs to come before him.</p> <p>Here is my original code:</p> <pre><code>function[] = unsubscribe(email_ids, member_emails) Old_list = fopen(email_ids, 'r'); %// opens my email list Old_Members = fopen(member_emails, 'r'); %// Opens up the names of people who want to unsubscribe emails = fgets(Old_list); %// Reads first line of emails member_emails = [member_emails]; %// Creates an array to populate while ischar(emails) %// Starts my while loop %// Pulls out a line in the email emails = fgets(Old_list); %// Quits when it sees this jerk if emails == -1 break; end %// I go in to clean stuff up here, but it doesn't do any of it. It's still in the while loop though, so I am not sure where the error is proper_emails = lower(member_emails); %// This is supposed to lowercase the emails, but it's not working unwanted = findstr(member_emails, ' ,;'); member_emails(unwanted) = ''; member_emails = [member_emails, emails]; end while ischar(Old_Members) %// Does the same for the members who want to unsubscribe names = fgetl(member_emails); if emails == -1 break end proper_emails = lower(names); %// Lowercases everything unwanted = findstr(names, ' ,;'); names(unwanted) = ''; end Complainers = find(emails); New_List = fopen('Test2', 'w'); %// Creates a file to be written to fprintf(New_List, '%s', member_emails); %// Writes to it Sorry_Message = fopen('Test.txt', 'w'); fprintf(Sorry_Message, '%s', Complainers); %// Had an issue with these, so I commented them out temporarily %// fclose(New_List); %// fclose(Sorry_Message); %// fclose(email_ids); %// fclose(members); end </code></pre>
11,945,417
0
How to make that regular expression for something like "1,3,5,2"? <p>I'm trying to make a regex for this:</p> <pre><code>1 1,1 1,1,1 1,1,1,1 </code></pre> <p>the 1's could be any digit (0 to 9)</p> <p>I guess it would be something like that:</p> <pre><code>/^\d{1}+(,+\d{1})?+(,+\d{1})$/ </code></pre> <p>But I don't know how to put that comma in the expression and to make sure there could be a maximum of 4 digits, separated by 3 commas. </p>
6,427,240
0
<blockquote> <p>i dont understand why, adding an element on the list also fires a list selection.</p> </blockquote> <p>Somewhere in your code you must be changing the selected index.</p> <p>Download and test the ListDemo example for <a href="http://download.oracle.com/javase/tutorial/uiswing/components/list.html" rel="nofollow">How to Use Lists</a>. When you run the code and "Hire" a person, then the list selection event fires (I added a System.out.println(...) to the listener). Then if you comment out:</p> <pre><code>// list.setSelectedIndex(index); </code></pre> <p>the event is not fired. So you have a problem in your code. Compare your code to the working example code to see what if different.</p> <p>If you need more help then post a <a href="http://sscce.org" rel="nofollow">SSCCE</a> that demonstrates the problem.</p>
25,911,398
0
<p>Probably you forgot about something...</p> <pre><code>li { display: list-item; } </code></pre> <p>In your code there is <code>display:inline</code> which isn't list item and haven't list styles.</p>
40,958,678
0
<p>maybe try <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.apply_along_axis.html" rel="nofollow noreferrer">np.apply_along_axis</a>:</p> <pre><code>&gt;&gt;&gt; def my_func(a): ... """Average first and last element of a 1-D array""" ... return (a[0] + a[-1]) * 0.5 &gt;&gt;&gt; b = np.array([[1,2,3], [4,5,6], [7,8,9]]) &gt;&gt;&gt; np.apply_along_axis(my_func, 0, b) array([ 4., 5., 6.]) &gt;&gt;&gt; np.apply_along_axis(my_func, 1, b) array([ 2., 5., 8.]) </code></pre>
35,774,724
0
<p><code>&amp;lt;</code> stands for the less-than sign <code>&lt;</code> and <code>&amp;gt;</code> stands for the greater-than sign <code>&gt;</code></p> <p><a href="http://stackoverflow.com/questions/5068951/what-do-entities-lt-and-gt-stand-for">What do entities: &amp;lt; and &amp;gt; stand for?</a></p> <p>I think(not really sure) you can replace like</p> <pre><code>string.replaceAll("&amp;l t;","&lt;"); </code></pre> <p>wish I could add comment, instead of answering but my reputation is not allowing me to do.</p>
15,347,976
0
<p>When running a <code>p4 integrate</code>, the destination for the integration should be mapped in your <code>perforce client workspace</code> which is what this error indicates:</p> <p><code>provide a branch view that maps this file, or use -Di to disregard move/deletes</code></p> <p>Using <code>p4 client</code> or <code>p4v</code>, map the following perforce depot <code>//depot/MyDemoInfo/1.0/Server/My_Service</code> into your client workspace to some directory on your machine say: <code>/myp4workspace/MyDemoInfo/1.0/Server/My_Service</code></p> <p>Then do this:</p> <pre><code>cd /myp4workspace/MyDemoInfo/1.0/Server/My_Service p4 integrate //depot/MyDemoInfo/trunk/Server/My_Service/... ... # This is optional, but a regular workflow to make sure you resolve all the conflicts # Display any conflicts (there shouldn't be any since this is the first time you're integrating into this location) p4 resolve -n ... # If there are any, use p4 resolve -as ... , p4 resolve -am ... , and then p4 resolve ... # Submit your changes after verifying it is correct p4 submit ... </code></pre> <p>And one more thing you might want to take care of is, run <code>p4 integrate</code> with the <code>-t -d</code> option so that it preserves file-types, and brings in any deleted file changes (although these 2 options might not be really required in your case but nothing wrong in specifying them).</p> <p>Also you can run <code>p4 where</code> to confirm that you're in the right perforce depot location before doing any integrations.</p>
34,280,497
0
Why does a lazy-loaded QWidget get displayed but a stored one does not? <p>I have a collection of small popup widgets that appear in various places, but only one of each and one at a time. For simple functionality, new-to-show and delete-to-hide is okay and works like it's supposed to, but as they start to handle their own data, I can see a memory leak coming up.</p> <p>So because I only need one of each kind, I thought I'd create all of them up front in the parent constructor and just show and hide them as needed. As far as I can tell, that ought to work, but popup->show() doesn't show. The complex app that this example is based on shows that the popup does exist at the correct location and can interact with the user...except that it's invisible.</p> <p>Here's the lazy version that shows:</p> <pre><code>#ifndef MAIN_H #define MAIN_H #include &lt;QtWidgets&gt; class Popup : public QLabel { Q_OBJECT public: explicit Popup(int x, int y, int width, int height, QWidget* parent = 0); }; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget* parent = 0); ~MainWindow() {} void mousePressEvent(QMouseEvent* ev); private: Popup* popup; }; #endif // MAIN_H /*************** *** main.cpp *** ***************/ #include "main.h" #include &lt;QApplication&gt; int main(int argc, char* argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { popup = 0; QWidget* cWidget = new QWidget(this); cWidget-&gt;setStyleSheet("background-color: lightgray"); setCentralWidget(cWidget); showMaximized(); } void MainWindow::mousePressEvent(QMouseEvent* ev) { if(popup != 0) { if(!popup-&gt;geometry().contains(ev-&gt;x(), ev-&gt;y())) { delete popup; popup = 0; } } else { popup = new Popup(ev-&gt;x(), ev-&gt;y(), 100, 100, this); popup-&gt;show(); } ev-&gt;accept(); } Popup::Popup(int x, int y, int width, int height, QWidget* parent) : QLabel(parent) { setStyleSheet("background-color: black"); setGeometry( x - (width / 2), // Left y - (height / 2), // Top width , // Width height // Height ); } </code></pre> <p>And here's the pre-created version that doesn't show:</p> <pre><code>#ifndef MAIN_H #define MAIN_H #include &lt;QtWidgets&gt; class Popup : public QLabel { Q_OBJECT public: explicit Popup(QWidget* parent = 0); void setup(int x, int y, int width, int height); }; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget* parent = 0); ~MainWindow() {} void mousePressEvent(QMouseEvent* ev); private: Popup* popup; }; #endif // MAIN_H /*************** *** main.cpp *** ***************/ #include "main.h" #include &lt;QApplication&gt; int main(int argc, char* argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { popup = new Popup(this); QWidget* cWidget = new QWidget(this); cWidget-&gt;setStyleSheet("background-color: lightgray"); setCentralWidget(cWidget); showMaximized(); } void MainWindow::mousePressEvent(QMouseEvent* ev) { if(popup-&gt;isVisible()) { if(!popup-&gt;geometry().contains(ev-&gt;x(), ev-&gt;y())) { popup-&gt;hide(); } } else { popup-&gt;setup(ev-&gt;x(), ev-&gt;y(), 100, 100); popup-&gt;show(); } ev-&gt;accept(); } Popup::Popup(QWidget* parent) : QLabel(parent) { setStyleSheet("background-color: black"); } void Popup::setup(int x, int y, int width, int height) { setGeometry( x - (width / 2), // Left y - (height / 2), // Top width , // Width height // Height ); } </code></pre> <p>What am I missing?</p>
36,719,805
0
<p>Test if you can request from other apps (like safari). If not might be something on your computer. In my case I had this problem with Avast Antivirus, which was blocking my simulators request (don't ask me why).</p>
7,802,702
0
<p>The browser stores it locally using its own method.</p> <p>For instance, Firefox stores this in its own SQLite database. But other browsers can do it however they like.</p> <p>The method it does this should have no consequence on web applications as it's internal to the browser. It may be relevant to you, however, if you are developing a web browser or browser extension, perhaps.</p>
4,033,981
0
How to link shared libraries in local directory, OSX vs Linux <p>I have some shared/dynamic libraries installed in a sandbox directory. I'm building some applications which link agains the libraries. I'm running into what appears to be a difference between OSX and Linux in this regard and I'm not sure what the (best) solution is.</p> <p>On OSX the location of library itself is recorded into the library, so that if your applications links against it, the executable knows where to look for the library at runtime. This works like expected with my sandbox, because the executable looks there instead of system wide install paths.</p> <p>On Linux I can't get this to work. Apparently the library location is not present in the library itself. As I understand it you have to add the folders which contain libraries to /etc/ld.so.conf and regenerate the ld cache by running ldconfig.</p> <p>This doesn't seem to do the trick for me because my libraries are located inside a users home directory. It looks like ldconfig doesn't like that, which makes sense actually.</p> <p>How can I solve this? I don't want to move the libraries out of my sandbox.</p>
26,605,732
0
<p>Add the protocol (<code>http://</code> or <code>https://</code> for example), then the handler knows what to do:</p> <pre><code>System.Diagnostics.Process.Start("http://google.com"); </code></pre> <p>Windows checks the file extension list, and that included protocols too. There it finds <code>http</code> maps to your browser. You can consider to be 'lucky' it detects <code>www.</code> too, but I wouldn't depend on it too much.</p>
39,798,947
0
<p>I agree with knbk's answer that it is not possible: durability is only present at the level of a transaction, and atomic provides that. It does not provide it at the level of save points. Depending on the use case, there may be workarounds.</p> <p>I'm guessing your use case is something like:</p> <pre><code>@atomic # possibly implicit if ATOMIC_REQUESTS is enabled def my_view(): run_some_code() # It's fine if this gets rolled back. charge_a_credit_card() # It's not OK if this gets rolled back. run_some_more_code() # This shouldn't roll back the credit card. </code></pre> <p>I think you'd want something like:</p> <pre><code>@transaction.non_atomic_requests def my_view(): with atomic(): run_some_code() with atomic(): charge_a_credit_card() with atomic(): run_some_more_code() </code></pre> <p>If your use case is for credit cards specifically (as mine was when I had this issue a few years ago), my coworker discovered that <a href="https://support.stripe.com/questions/does-stripe-support-authorize-and-capture">credit card processors actually provide mechanisms for handling this</a>. A similar mechanism might work for your use case, depending on the problem structure:</p> <pre><code>@atomic def my_view(): run_some_code() result = charge_a_credit_card(capture=False) if result.successful: transaction.on_commit(lambda: result.capture()) run_some_more_code() </code></pre> <p>Another option would be to use a non-transactional persistence mechanism for recording what you're interested in, like a log database, or a redis queue of things to record.</p>
4,731,996
0
<p>You can also build your application for "Any CPU" and dynamically choose which DLL to load.</p>
37,855,792
0
<p>You're on the right track. You can bind the AlternationCount to the length of your collection then create a style for the default items, and change it for first the rows:</p> <pre><code>&lt;Style x:Key="differentItemsStyle" TargetType="{x:Type Label}"&gt; &lt;Setter Property="Foreground" Value="Red"&gt;&lt;/Setter&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding Path=(ItemsControl.AlternationIndex), RelativeSource={RelativeSource TemplatedParent}}" Value="0"&gt; &lt;Setter Property="Foreground" Value="Green"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding Path=(ItemsControl.AlternationIndex), RelativeSource={RelativeSource TemplatedParent}}" Value="1"&gt; &lt;Setter Property="Foreground" Value="Yellow"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre> <p>In your example you would have a default style for Option C, D, E which you can overwrite as you wish for Option A and Option B.</p> <p><strong>Edit</strong> In order to make this work for ListBox the binding needs to be changed:</p> <pre><code>&lt;DataTrigger Binding="{Binding Path=(ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="1"&gt; &lt;Setter Property="Foreground" Value="Yellow"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; </code></pre> <p>See <a href="http://stackoverflow.com/questions/19491318/why-does-listbox-alternationindex-always-return-0">this answer</a> for more info.</p>
39,951,919
0
sample spark CSV and JSON program not running in windows <p>I am running spark program in Windows 10 machine.</p> <p>I am trying to run the below spark program</p> <pre><code>import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.spark.SparkConf import org.apache.spark.sql.Column import org.apache.spark.sql.functions._ import org.apache.spark.sql.SQLContext import org.apache.spark.sql._ import org.apache.spark.sql.SQLImplicits import org.apache.spark.sql.expressions.Window import org.apache.spark.sql.TypedColumn import org.apache.spark.sql.Encoder import org.apache.spark.sql.Encoders import com.databricks.spark.csv object json1 { def main(args : Array[String]){ val conf = new SparkConf().setAppName("Simple Application").setMaster("local[2]").set("spark.executor.memory", "1g") val sc = new org.apache.spark.SparkContext(conf) val sqlc = new org.apache.spark.sql.SQLContext(sc) val NyseDF = sqlc.load("com.databricks.spark.csv",Map("path" -&gt; args(0),"header"-&gt;"true")) NyseDF.registerTempTable("NYSE") NyseDF.printSchema() } } </code></pre> <p>When i run the program through Run application mode in eclispse with passing arguments</p> <p>as</p> <p>src/test/resources/demo.text</p> <p>It fails with below error.</p> <pre><code>Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties 16/10/10 11:02:18 INFO SparkContext: Running Spark version 1.6.0 16/10/10 11:02:18 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 16/10/10 11:02:18 INFO SecurityManager: Changing view acls to: subho 16/10/10 11:02:18 INFO SecurityManager: Changing modify acls to: subho 16/10/10 11:02:18 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(subho); users with modify permissions: Set(subho) 16/10/10 11:02:19 INFO Utils: Successfully started service 'sparkDriver' on port 61108. 16/10/10 11:02:20 INFO Slf4jLogger: Slf4jLogger started 16/10/10 11:02:20 INFO Remoting: Starting remoting 16/10/10 11:02:20 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://[email protected]:61121] 16/10/10 11:02:20 INFO Utils: Successfully started service 'sparkDriverActorSystem' on port 61121. 16/10/10 11:02:20 INFO SparkEnv: Registering MapOutputTracker 16/10/10 11:02:20 INFO SparkEnv: Registering BlockManagerMaster 16/10/10 11:02:21 INFO DiskBlockManager: Created local directory at C:\Users\subho\AppData\Local\Temp\blockmgr-69afda02-ccd1-41d1-aa25-830ba366a75c 16/10/10 11:02:21 INFO MemoryStore: MemoryStore started with capacity 1128.4 MB 16/10/10 11:02:21 INFO SparkEnv: Registering OutputCommitCoordinator 16/10/10 11:02:21 INFO Utils: Successfully started service 'SparkUI' on port 4040. 16/10/10 11:02:21 INFO SparkUI: Started SparkUI at http://192.168.1.116:4040 16/10/10 11:02:21 INFO Executor: Starting executor ID driver on host localhost 16/10/10 11:02:21 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 61132. 16/10/10 11:02:21 INFO NettyBlockTransferService: Server created on 61132 16/10/10 11:02:21 INFO BlockManagerMaster: Trying to register BlockManager 16/10/10 11:02:21 INFO BlockManagerMasterEndpoint: Registering block manager localhost:61132 with 1128.4 MB RAM, BlockManagerId(driver, localhost, 61132) 16/10/10 11:02:21 INFO BlockManagerMaster: Registered BlockManager 16/10/10 11:02:23 INFO MemoryStore: Block broadcast_0 stored as values in memory (estimated size 107.7 KB, free 107.7 KB) 16/10/10 11:02:23 INFO MemoryStore: Block broadcast_0_piece0 stored as bytes in memory (estimated size 9.8 KB, free 117.5 KB) 16/10/10 11:02:23 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on localhost:61132 (size: 9.8 KB, free: 1128.4 MB) 16/10/10 11:02:23 INFO SparkContext: Created broadcast 0 from textFile at TextFile.scala:30 16/10/10 11:02:23 ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:278) at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300) at org.apache.hadoop.util.Shell.&lt;clinit&gt;(Shell.java:293) at org.apache.hadoop.util.StringUtils.&lt;clinit&gt;(StringUtils.java:76) at org.apache.hadoop.mapred.FileInputFormat.setInputPaths(FileInputFormat.java:362) at org.apache.spark.SparkContext$$anonfun$hadoopFile$1$$anonfun$33.apply(SparkContext.scala:1015) at org.apache.spark.SparkContext$$anonfun$hadoopFile$1$$anonfun$33.apply(SparkContext.scala:1015) at org.apache.spark.rdd.HadoopRDD$$anonfun$getJobConf$6.apply(HadoopRDD.scala:176) at org.apache.spark.rdd.HadoopRDD$$anonfun$getJobConf$6.apply(HadoopRDD.scala:176) at scala.Option.map(Option.scala:146) at org.apache.spark.rdd.HadoopRDD.getJobConf(HadoopRDD.scala:176) at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:195) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.RDD$$anonfun$take$1.apply(RDD.scala:1293) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:111) at org.apache.spark.rdd.RDD.withScope(RDD.scala:316) at org.apache.spark.rdd.RDD.take(RDD.scala:1288) at com.databricks.spark.csv.CsvRelation.firstLine$lzycompute(CsvRelation.scala:174) at com.databricks.spark.csv.CsvRelation.firstLine(CsvRelation.scala:169) at com.databricks.spark.csv.CsvRelation.inferSchema(CsvRelation.scala:147) at com.databricks.spark.csv.CsvRelation.&lt;init&gt;(CsvRelation.scala:70) at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:138) at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:40) at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:28) at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:158) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:119) at org.apache.spark.sql.SQLContext.load(SQLContext.scala:1153) at json1$.main(json1.scala:22) at json1.main(json1.scala) Exception in thread "main" org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/demo.text at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:251) at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:270) at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:199) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:239) at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:237) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.rdd.RDD.partitions(RDD.scala:237) at org.apache.spark.rdd.RDD$$anonfun$take$1.apply(RDD.scala:1293) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:150) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:111) at org.apache.spark.rdd.RDD.withScope(RDD.scala:316) at org.apache.spark.rdd.RDD.take(RDD.scala:1288) at com.databricks.spark.csv.CsvRelation.firstLine$lzycompute(CsvRelation.scala:174) at com.databricks.spark.csv.CsvRelation.firstLine(CsvRelation.scala:169) at com.databricks.spark.csv.CsvRelation.inferSchema(CsvRelation.scala:147) at com.databricks.spark.csv.CsvRelation.&lt;init&gt;(CsvRelation.scala:70) at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:138) at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:40) at com.databricks.spark.csv.DefaultSource.createRelation(DefaultSource.scala:28) at org.apache.spark.sql.execution.datasources.ResolvedDataSource$.apply(ResolvedDataSource.scala:158) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:119) at org.apache.spark.sql.SQLContext.load(SQLContext.scala:1153) at json1$.main(json1.scala:22) at json1.main(json1.scala) 16/10/10 11:02:23 INFO SparkContext: Invoking stop() from shutdown hook 16/10/10 11:02:23 INFO SparkUI: Stopped Spark web UI at http://192.168.1.116:4040 16/10/10 11:02:23 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped! 16/10/10 11:02:23 INFO MemoryStore: MemoryStore cleared 16/10/10 11:02:23 INFO BlockManager: BlockManager stopped 16/10/10 11:02:24 INFO BlockManagerMaster: BlockManagerMaster stopped 16/10/10 11:02:24 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped! 16/10/10 11:02:24 INFO SparkContext: Successfully stopped SparkContext 16/10/10 11:02:24 INFO ShutdownHookManager: Shutdown hook called 16/10/10 11:02:24 INFO ShutdownHookManager: Deleting directory C:\Users\subho\AppData\Local\Temp\spark-7f53ea20-a38c-46d5-8476-a1ae040736ac </code></pre> <p>Below is the main error msg</p> <p>Input path does not exist: file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/demo.text</p> <p>I have the file in the below location.</p> <p><a href="http://i.stack.imgur.com/ugXF7.jpg" rel="nofollow">!</a>]<a href="http://i.stack.imgur.com/ugXF7.jpg" rel="nofollow">1</a></p> <p>When i ran the below program it ran sucussfully,</p> <pre><code>import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.spark.SparkConf import org.apache.spark.sql.Column import org.apache.spark.sql.functions._ import org.apache.spark.sql.SQLContext import org.apache.spark.sql._ import org.apache.spark.sql.SQLImplicits import org.apache.spark.sql.expressions.Window import org.apache.spark.sql.TypedColumn import org.apache.spark.sql.Encoder import org.apache.spark.sql.Encoders import com.databricks.spark.csv object json1 { def main(args : Array[String]){ val conf = new SparkConf().setAppName("Simple Application").setMaster("local[2]").set("spark.executor.memory", "1g") val sc = new org.apache.spark.SparkContext(conf) val sqlc = new org.apache.spark.sql.SQLContext(sc) /* val NyseDF = sqlc.load("com.databricks.spark.csv",Map("path" -&gt; args(0),"header"-&gt;"true")) NyseDF.registerTempTable("NYSE") NyseDF.printSchema() print(sqlc.sql("select distinct(symbol) from NYSE").collect().toList)*/ val PersonDF = sqlc.jsonFile("src/test/resources/Person.json") // PersonDF.printSchema() PersonDF.registerTempTable("Person") sqlc.sql("select * from Person where age &lt; 60").collect().foreach(print) } </code></pre> <p>Below is the log file.</p> <pre><code>Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties 16/10/10 11:54:12 INFO SparkContext: Running Spark version 1.6.0 16/10/10 11:54:13 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 16/10/10 11:54:13 INFO SecurityManager: Changing view acls to: subho 16/10/10 11:54:13 INFO SecurityManager: Changing modify acls to: subho 16/10/10 11:54:13 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users with view permissions: Set(subho); users with modify permissions: Set(subho) 16/10/10 11:54:14 INFO Utils: Successfully started service 'sparkDriver' on port 51113. 16/10/10 11:54:14 INFO Slf4jLogger: Slf4jLogger started 16/10/10 11:54:14 INFO Remoting: Starting remoting 16/10/10 11:54:15 INFO Remoting: Remoting started; listening on addresses :[akka.tcp://[email protected]:51126] 16/10/10 11:54:15 INFO Utils: Successfully started service 'sparkDriverActorSystem' on port 51126. 16/10/10 11:54:15 INFO SparkEnv: Registering MapOutputTracker 16/10/10 11:54:15 INFO SparkEnv: Registering BlockManagerMaster 16/10/10 11:54:15 INFO DiskBlockManager: Created local directory at C:\Users\subho\AppData\Local\Temp\blockmgr-a52a5d5a-075b-4859-8434-935fdaba8538 16/10/10 11:54:15 INFO MemoryStore: MemoryStore started with capacity 1128.4 MB 16/10/10 11:54:15 INFO SparkEnv: Registering OutputCommitCoordinator 16/10/10 11:54:15 INFO Utils: Successfully started service 'SparkUI' on port 4040. 16/10/10 11:54:15 INFO SparkUI: Started SparkUI at http://192.168.1.116:4040 16/10/10 11:54:15 INFO Executor: Starting executor ID driver on host localhost 16/10/10 11:54:15 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 51137. 16/10/10 11:54:15 INFO NettyBlockTransferService: Server created on 51137 16/10/10 11:54:15 INFO BlockManagerMaster: Trying to register BlockManager 16/10/10 11:54:15 INFO BlockManagerMasterEndpoint: Registering block manager localhost:51137 with 1128.4 MB RAM, BlockManagerId(driver, localhost, 51137) 16/10/10 11:54:15 INFO BlockManagerMaster: Registered BlockManager 16/10/10 11:54:17 INFO JSONRelation: Listing file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/Person.json on driver 16/10/10 11:54:17 ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:278) at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:300) at org.apache.hadoop.util.Shell.&lt;clinit&gt;(Shell.java:293) at org.apache.hadoop.util.StringUtils.&lt;clinit&gt;(StringUtils.java:76) at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.setInputPaths(FileInputFormat.java:447) at org.apache.spark.sql.execution.datasources.json.JSONRelation.org$apache$spark$sql$execution$datasources$json$JSONRelation$$createBaseRdd(JSONRelation.scala:98) at org.apache.spark.sql.execution.datasources.json.JSONRelation$$anonfun$4$$anonfun$apply$1.apply(JSONRelation.scala:115) at org.apache.spark.sql.execution.datasources.json.JSONRelation$$anonfun$4$$anonfun$apply$1.apply(JSONRelation.scala:115) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.sql.execution.datasources.json.JSONRelation$$anonfun$4.apply(JSONRelation.scala:115) at org.apache.spark.sql.execution.datasources.json.JSONRelation$$anonfun$4.apply(JSONRelation.scala:109) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.sql.execution.datasources.json.JSONRelation.dataSchema$lzycompute(JSONRelation.scala:109) at org.apache.spark.sql.execution.datasources.json.JSONRelation.dataSchema(JSONRelation.scala:108) at org.apache.spark.sql.sources.HadoopFsRelation.schema$lzycompute(interfaces.scala:636) at org.apache.spark.sql.sources.HadoopFsRelation.schema(interfaces.scala:635) at org.apache.spark.sql.execution.datasources.LogicalRelation.&lt;init&gt;(LogicalRelation.scala:37) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:125) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:109) at org.apache.spark.sql.DataFrameReader.json(DataFrameReader.scala:244) at org.apache.spark.sql.SQLContext.jsonFile(SQLContext.scala:1011) at json1$.main(json1.scala:28) at json1.main(json1.scala) 16/10/10 11:54:18 INFO MemoryStore: Block broadcast_0 stored as values in memory (estimated size 128.0 KB, free 128.0 KB) 16/10/10 11:54:18 INFO MemoryStore: Block broadcast_0_piece0 stored as bytes in memory (estimated size 14.1 KB, free 142.1 KB) 16/10/10 11:54:18 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on localhost:51137 (size: 14.1 KB, free: 1128.4 MB) 16/10/10 11:54:18 INFO SparkContext: Created broadcast 0 from jsonFile at json1.scala:28 16/10/10 11:54:18 INFO FileInputFormat: Total input paths to process : 1 16/10/10 11:54:18 INFO SparkContext: Starting job: jsonFile at json1.scala:28 16/10/10 11:54:18 INFO DAGScheduler: Got job 0 (jsonFile at json1.scala:28) with 2 output partitions 16/10/10 11:54:18 INFO DAGScheduler: Final stage: ResultStage 0 (jsonFile at json1.scala:28) 16/10/10 11:54:18 INFO DAGScheduler: Parents of final stage: List() 16/10/10 11:54:18 INFO DAGScheduler: Missing parents: List() 16/10/10 11:54:18 INFO DAGScheduler: Submitting ResultStage 0 (MapPartitionsRDD[3] at jsonFile at json1.scala:28), which has no missing parents 16/10/10 11:54:18 INFO MemoryStore: Block broadcast_1 stored as values in memory (estimated size 4.2 KB, free 146.3 KB) 16/10/10 11:54:18 INFO MemoryStore: Block broadcast_1_piece0 stored as bytes in memory (estimated size 2.4 KB, free 148.6 KB) 16/10/10 11:54:18 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on localhost:51137 (size: 2.4 KB, free: 1128.4 MB) 16/10/10 11:54:18 INFO SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:1006 16/10/10 11:54:18 INFO DAGScheduler: Submitting 2 missing tasks from ResultStage 0 (MapPartitionsRDD[3] at jsonFile at json1.scala:28) 16/10/10 11:54:18 INFO TaskSchedulerImpl: Adding task set 0.0 with 2 tasks 16/10/10 11:54:18 INFO TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, localhost, partition 0,PROCESS_LOCAL, 2113 bytes) 16/10/10 11:54:18 INFO TaskSetManager: Starting task 1.0 in stage 0.0 (TID 1, localhost, partition 1,PROCESS_LOCAL, 2113 bytes) 16/10/10 11:54:18 INFO Executor: Running task 1.0 in stage 0.0 (TID 1) 16/10/10 11:54:18 INFO Executor: Running task 0.0 in stage 0.0 (TID 0) 16/10/10 11:54:18 INFO HadoopRDD: Input split: file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/Person.json:0+92 16/10/10 11:54:18 INFO HadoopRDD: Input split: file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/Person.json:92+93 16/10/10 11:54:18 INFO deprecation: mapred.tip.id is deprecated. Instead, use mapreduce.task.id 16/10/10 11:54:18 INFO deprecation: mapred.tip.id is deprecated. Instead, use mapreduce.task.id 16/10/10 11:54:18 INFO deprecation: mapred.task.id is deprecated. Instead, use mapreduce.task.attempt.id 16/10/10 11:54:18 INFO deprecation: mapred.task.is.map is deprecated. Instead, use mapreduce.task.ismap 16/10/10 11:54:18 INFO deprecation: mapred.task.partition is deprecated. Instead, use mapreduce.task.partition 16/10/10 11:54:18 INFO deprecation: mapred.job.id is deprecated. Instead, use mapreduce.job.id 16/10/10 11:54:19 INFO Executor: Finished task 0.0 in stage 0.0 (TID 0). 2886 bytes result sent to driver 16/10/10 11:54:19 INFO Executor: Finished task 1.0 in stage 0.0 (TID 1). 2886 bytes result sent to driver 16/10/10 11:54:19 INFO TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 1287 ms on localhost (1/2) 16/10/10 11:54:19 INFO TaskSetManager: Finished task 1.0 in stage 0.0 (TID 1) in 1264 ms on localhost (2/2) 16/10/10 11:54:19 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool 16/10/10 11:54:19 INFO DAGScheduler: ResultStage 0 (jsonFile at json1.scala:28) finished in 1.314 s 16/10/10 11:54:19 INFO DAGScheduler: Job 0 finished: jsonFile at json1.scala:28, took 1.413653 s 16/10/10 11:54:20 INFO BlockManagerInfo: Removed broadcast_1_piece0 on localhost:51137 in memory (size: 2.4 KB, free: 1128.4 MB) 16/10/10 11:54:20 INFO ContextCleaner: Cleaned accumulator 1 16/10/10 11:54:20 INFO BlockManagerInfo: Removed broadcast_0_piece0 on localhost:51137 in memory (size: 14.1 KB, free: 1128.4 MB) 16/10/10 11:54:21 INFO MemoryStore: Block broadcast_2 stored as values in memory (estimated size 59.6 KB, free 59.6 KB) 16/10/10 11:54:21 INFO MemoryStore: Block broadcast_2_piece0 stored as bytes in memory (estimated size 13.8 KB, free 73.3 KB) 16/10/10 11:54:21 INFO BlockManagerInfo: Added broadcast_2_piece0 in memory on localhost:51137 (size: 13.8 KB, free: 1128.4 MB) 16/10/10 11:54:21 INFO SparkContext: Created broadcast 2 from collect at json1.scala:34 16/10/10 11:54:21 INFO MemoryStore: Block broadcast_3 stored as values in memory (estimated size 128.0 KB, free 201.3 KB) 16/10/10 11:54:21 INFO MemoryStore: Block broadcast_3_piece0 stored as bytes in memory (estimated size 14.1 KB, free 215.4 KB) 16/10/10 11:54:21 INFO BlockManagerInfo: Added broadcast_3_piece0 in memory on localhost:51137 (size: 14.1 KB, free: 1128.3 MB) 16/10/10 11:54:21 INFO SparkContext: Created broadcast 3 from collect at json1.scala:34 16/10/10 11:54:21 INFO FileInputFormat: Total input paths to process : 1 16/10/10 11:54:21 INFO SparkContext: Starting job: collect at json1.scala:34 16/10/10 11:54:21 INFO DAGScheduler: Got job 1 (collect at json1.scala:34) with 2 output partitions 16/10/10 11:54:21 INFO DAGScheduler: Final stage: ResultStage 1 (collect at json1.scala:34) 16/10/10 11:54:21 INFO DAGScheduler: Parents of final stage: List() 16/10/10 11:54:21 INFO DAGScheduler: Missing parents: List() 16/10/10 11:54:21 INFO DAGScheduler: Submitting ResultStage 1 (MapPartitionsRDD[9] at collect at json1.scala:34), which has no missing parents 16/10/10 11:54:21 INFO MemoryStore: Block broadcast_4 stored as values in memory (estimated size 7.6 KB, free 223.0 KB) 16/10/10 11:54:21 INFO MemoryStore: Block broadcast_4_piece0 stored as bytes in memory (estimated size 4.1 KB, free 227.1 KB) 16/10/10 11:54:21 INFO BlockManagerInfo: Added broadcast_4_piece0 in memory on localhost:51137 (size: 4.1 KB, free: 1128.3 MB) 16/10/10 11:54:21 INFO SparkContext: Created broadcast 4 from broadcast at DAGScheduler.scala:1006 16/10/10 11:54:21 INFO DAGScheduler: Submitting 2 missing tasks from ResultStage 1 (MapPartitionsRDD[9] at collect at json1.scala:34) 16/10/10 11:54:21 INFO TaskSchedulerImpl: Adding task set 1.0 with 2 tasks 16/10/10 11:54:21 INFO TaskSetManager: Starting task 0.0 in stage 1.0 (TID 2, localhost, partition 0,PROCESS_LOCAL, 2113 bytes) 16/10/10 11:54:21 INFO TaskSetManager: Starting task 1.0 in stage 1.0 (TID 3, localhost, partition 1,PROCESS_LOCAL, 2113 bytes) 16/10/10 11:54:21 INFO Executor: Running task 0.0 in stage 1.0 (TID 2) 16/10/10 11:54:21 INFO Executor: Running task 1.0 in stage 1.0 (TID 3) 16/10/10 11:54:21 INFO HadoopRDD: Input split: file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/Person.json:92+93 16/10/10 11:54:21 INFO HadoopRDD: Input split: file:/C:/Users/subho/Desktop/code-master/simple-spark-project/src/test/resources/Person.json:0+92 16/10/10 11:54:22 INFO BlockManagerInfo: Removed broadcast_2_piece0 on localhost:51137 in memory (size: 13.8 KB, free: 1128.4 MB) 16/10/10 11:54:22 INFO GenerateUnsafeProjection: Code generated in 548.352258 ms 16/10/10 11:54:22 INFO GeneratePredicate: Code generated in 5.245214 ms 16/10/10 11:54:22 INFO Executor: Finished task 1.0 in stage 1.0 (TID 3). 2283 bytes result sent to driver 16/10/10 11:54:22 INFO Executor: Finished task 0.0 in stage 1.0 (TID 2). 2536 bytes result sent to driver 16/10/10 11:54:22 INFO TaskSetManager: Finished task 1.0 in stage 1.0 (TID 3) in 755 ms on localhost (1/2) 16/10/10 11:54:22 INFO TaskSetManager: Finished task 0.0 in stage 1.0 (TID 2) in 759 ms on localhost (2/2) 16/10/10 11:54:22 INFO DAGScheduler: ResultStage 1 (collect at json1.scala:34) finished in 0.760 s 16/10/10 11:54:22 INFO DAGScheduler: Job 1 finished: collect at json1.scala:34, took 0.779652 s 16/10/10 11:54:22 INFO TaskSchedulerImpl: Removed TaskSet 1.0, whose tasks have all completed, from pool [53,Barack,Obama]16/10/10 11:54:22 INFO SparkContext: Invoking stop() from shutdown hook 16/10/10 11:54:22 INFO SparkUI: Stopped Spark web UI at http://192.168.1.116:4040 16/10/10 11:54:22 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped! 16/10/10 11:54:22 INFO MemoryStore: MemoryStore cleared 16/10/10 11:54:22 INFO BlockManager: BlockManager stopped 16/10/10 11:54:22 INFO BlockManagerMaster: BlockManagerMaster stopped 16/10/10 11:54:22 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped! 16/10/10 11:54:22 INFO SparkContext: Successfully stopped SparkContext 16/10/10 11:54:22 INFO ShutdownHookManager: Shutdown hook called 16/10/10 11:54:22 INFO ShutdownHookManager: Deleting directory C:\Users\subho\AppData\Local\Temp\spark-6cab6329-83f1-4af4-b64c-c869550405a4 16/10/10 11:54:22 INFO RemoteActorRefProvider$RemotingTerminator: Shutting down remote daemon. </code></pre> <p>Thanks and Regards,</p>
12,842,819
0
<p>You need to put the name of the field into square brackets.</p> <p>So change...</p> <pre><code>ON e.EEO-1Class = jt.EEO-1Class </code></pre> <p>Into</p> <pre><code>ON e.[EEO-1Class] = jt.[EEO-1Class] </code></pre> <p>If your field or table name contains just alphanumeric characters (ie A-Z and 0-9) and the underscore <code>_</code> character, then you can use it without square brackets (<code>[</code> and <code>]</code>).</p> <p>But as soon as you have a different characters in there (and one that can easily be confused by SQL server, such as <code>-</code>) then you need to place the field/table into square brackets.</p> <p>However, what I would recommend above everything else is that you only ever use alphanumeric characters (and the underscore <code>_</code> character) for your field and table names, as it is considered better practise, and will remove this type of thing happening again for you</p>
3,188,354
0
<p>This <a href="http://www.cadtutor.net/forum/archive/index.php/t-20809.html" rel="nofollow noreferrer">Forum thread</a> includes a VB program to strip the control characters from the MText. The code indicates what should be done to strip each control character, so it should be straightforward to write something similar in C#.</p> <p>Additionally, the documentation of the format codes is available in the <a href="http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-63b9.htm,topicNumber=d0e123454" rel="nofollow noreferrer">AutoCAD documentation</a>.</p>
17,157,262
0
Best way to fetch multiple variables from MySQL Database using PDO <p>Okai, so I am trying to fetch multiple variables from the MySQL Database using PDO and I feel that I have to repeat myself alot in the code. Is there a neater way to write this or a more secure way?</p> <p>Here is my code for the following example:</p> <pre><code> $username = $_SESSION['username']; $db = new PDO('mysql:xxxxxxxx;dbname=xxxxxxxxxxxx', 'xxxxxx', 'xxxxxxx'); // FETCH name VARIABLE $fetchname = $db-&gt;prepare("SELECT name FROM login WHERE username = :username"); $fetchname-&gt;bindParam(':username', $username, PDO::PARAM_STR, 40); $fetchname-&gt;execute(); $myname = $fetchname-&gt;fetchColumn(); // FETCH age VARIABLE $fetchage = $db-&gt;prepare("SELECT age FROM login WHERE username = :username"); $fetchage-&gt;bindParam(':username', $username, PDO::PARAM_STR, 40); $fetchage-&gt;execute(); $myage = $fetchage-&gt;fetchColumn(); </code></pre> <p>I wish to avoid having to repeat this FETCH for each variable from the same table...</p>
28,563,554
0
<p>if you need to validate decimal with dots, commas, positives and negatives try this:</p> <pre><code>Object testObject = "-1.5"; boolean isDecimal = Pattern.matches("^[\\+\\-]{0,1}[0-9]+[\\.\\,]{1}[0-9]+$", (CharSequence) testObject); </code></pre> <p>Good luck.</p>
35,868,561
0
<p>Here is how I would do.</p> <blockquote> <p>app.js</p> </blockquote> <pre><code>(function(){ angular.module('app',[]); /* other code like configuration etc */ })(); </code></pre> <blockquote> <p>SomeService.js</p> </blockquote> <pre><code>(function(){ angular.module('app'); .factory('someService',function(){ return { doSomething: function(){ $('.container-fluid').css('display', 'none'); } }; }); })(); </code></pre> <blockquote> <p>app.run.js</p> </blockquote> <pre><code>(function(){ angular.module('app') //Inject your service here .run(function($rootScope,someService){ //Look for successful state change. //For your ref. on other events. //https://github.com/angular-ui/ui-router/wiki#state-change-events $rootScope.$on('$stateChangeSuccess', function() { //If you don't wanna create the service, you can directly write // your function here. someService.doSomething(); }); }) })(); </code></pre> <p>Always wrap your angular code within <a href="https://en.wikipedia.org/wiki/Immediately-invoked_function_expression" rel="nofollow">IIFE</a> it wraps everything in closure and prevents leaks as well as provides a layer of security.</p> <p>Hope this helps!</p>
12,935,544
0
<p>I do not think it is that easy.</p> <p>According to the specs at <a href="http://dev.w3.org/html5/spec/association-of-controls-and-forms.html#attr-fae-form" rel="nofollow">http://dev.w3.org/html5/spec/association-of-controls-and-forms.html#attr-fae-form</a></p> <ol> <li>The form owner must exist in order to be set to an element.</li> <li>The element must be in the document in order to alter its form owner</li> </ol>
3,519,215
0
<p>Try using this</p> <pre><code>$.sheet.instance[0].makeTable.json() </code></pre>
2,964,006
0
<p>Yes. People normally just use VirtualHosts. </p> <p>There are several ways. </p> <ul> <li>You can use a relative path to include a config file. </li> <li>You can use a DOCUMENT_ROOT from the $_SERVER superglobal to place a config file there. </li> <li>You can use web-server config if possible. like <code>php_value auto_prepend_file</code> in .htaccess </li> <li>And at least you can detect your environment and choose between two roots, both written in conditions at the top. </li> <li>And yes, if you're using mod_rewrite - make a front controller which will include all the other files, so - the only one file to place these settings.</li> </ul>
6,208,342
0
Using server side html+js in phonegap (multiplatform mobile dev) <p>Phonegap uses html source located in www folder. I was testing what happens if index.html is still in www, but it links to other html that are located in at the server side. It will open the server side html in the web browser instead of handle it as part of the app.</p> <p>Is there any way to make phonegap work with server side html + js source?</p> <p>It is not a bad idea if you need to mix usage of libraries (jars + ios libraries), local phonegap html+js with server side dynamic html code (like php output).</p> <p>thanks. </p>
11,159,898
0
UILabel Landscape Orientation <p>Im trying to change a UIlabels coordinates in landscape orient so i did this. The problem is that it doesn't work. What am I doing wrong?</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); if (interfaceOrientation != UIInterfaceOrientationLandscapeLeft) { label.frame = CGRectMake(377, 15, 42, 21); } } </code></pre>
12,124,574
0
<p>You can't sort a table by default, but you have to do it programmatically. With a little bit of work you can write a reusable <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/event/PhaseListener.html" rel="nofollow"><code>PhaseListener</code></a> which you can control from your JSF page.</p> <p>Make sure it only <a href="http://stackoverflow.com/questions/2678207/jsf-fview-beforephase-firing-multiple-times-as-i-leave-the-page">handles a single phase</a> (for example <code>PhaseId.RESTORE_VIEW</code>) and use it to set the sort order using <a href="http://myfaces.apache.org/trinidad/trinidad-api/apidocs/org/apache/myfaces/trinidad/component/UIXTable.html#setSortCriteria%28java.util.List%29" rel="nofollow"><code>setSortCriteria</code></a>:</p> <pre><code>List&lt;SortCriterion&gt; sortCriteria = new ArrayList&lt;SortCriterion&gt;(1); String property = "myProperty"; boolean ascending = true; sortCriteria.add(new SortCriterion(property, ascending)); myCoreTable.setSortCriteria(sortCriteria); </code></pre> <p>Now you only have to add two <code>&lt;f:attribute/&gt;</code>s on your table to pass both the property name and the ascending boolean so you can create a reusable listener for all your tables.</p> <p>In your <code>&lt;tr:document&gt;</code> you can have a <code>&lt;f:attribute/&gt;</code> with a list of table ID's to process.</p>
31,576,553
0
jQuery: Is there a way to grab a HTML element's external CSS and append to its "Style" attribute? <p>Basically what i want to do is grab all CSS that is referenced in an external stylesheet e.g <code>&lt;link rel="stylesheet" href="css/General.css"&gt;</code> and append it to any existing styling for each HTML element in my page. (make all CSS inline)</p> <p>The reason for this is because i need to call <code>.html()</code> to grab a div and send to server to be made into a PDF. The downside with this tool is that it only recognises inline CSS.</p> <p>Are there any ways to do this?</p> <p>Edit: the question that was linked to mine as a "possible duplicate" spoke only of putting everything in the <code>&lt;style&gt;</code> tag. while that may be useful, im mainly concerned with loading into the <code>style=""</code> html atribute</p>
25,501,006
0
<p>I am not sure about the bootsrap, But here is the generic way of approach to solve your problem.</p> <p><strong>HTML</strong></p> <pre><code>&lt;div class="main"&gt; &lt;div&gt;one&lt;/div&gt; &lt;div&gt;two&lt;/div&gt; &lt;div&gt;three&lt;/div&gt; &lt;div&gt;four&lt;/div&gt; &lt;div&gt;five&lt;/div&gt; &lt;div&gt;six&lt;/div&gt; &lt;div&gt;seven&lt;/div&gt; &lt;div&gt;eight&lt;/div&gt; &lt;div&gt;nine&lt;/div&gt; &lt;div&gt;ten&lt;/div&gt; &lt;div&gt;eleven&lt;/div&gt; &lt;div&gt;twelve&lt;/div&gt; &lt;div&gt;thirteen&lt;/div&gt; &lt;div&gt;fourteen&lt;/div&gt; &lt;div&gt;fifteen&lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>.main div { float: right; width: 70px; } .main div:nth-child(6n + 7) { clear: right; } </code></pre> <p><a href="http://jsfiddle.net/q9zh8508/1/" rel="nofollow"><strong>FIDDLE DEMO</strong></a></p>
10,087,701
0
<p>You should perform validations at server side as well as client side.Client side validations increase interactivity of your applications.In other words make your application more user friendly.However client side validations may have their shortcomings , if your user disables javascript , then he could very well enter non sense data values and send them to your server.You dont want this to happen.For that purpose you need to perform server side validations.Server side validation controls filter the input and make sure proper data is entered.There are good validation controls Asp.Net offers.You could very well utilize them. I recommend you to use both client as well as server side validation for a blend of interactivity and protection. Thanks</p>
37,588,890
0
Datatables sorting time column <p>I'm using jQuery DataTables and I have a problem when I'm sorting my time column with this format <code>mm:ss</code>. For example when I sort this <code>00:08</code> the sort does something but this is not good. I have in my column:</p> <pre><code>00:08 00:15 00:01 01:20 00:16 02:11 </code></pre> <p>So the sort doesn't work. Do you know how can I sort my time column?</p> <p>Here is my code : </p> <pre><code>$('#table').DataTable({ dom: "t&lt;'col-sm-5'i&gt;&lt;'col-sm-7'p&gt;", autoWidth: false, serverSide: true, aaSorting: [[0, 'desc']], rowId: 'id', lengthChange: false, ajax: { url: 'index', method: 'POST' } columns: [ {data: "id", width: '5%'}, {data: "name", width: '10%', orderData: [ 1, 0 ]}, {data: "user_name", width: '10%', orderData: [ 2, 0 ]}, {data: "email", width: '35%', orderData: [ 3, 0 ]}, {data: "duration", render: duration_time, width: '10%', type: "time",orderData: [ 4, 0 ]}, {data: "incomplete", render: incomplete, width: '30%', orderData: [ 5, 0 ]} ] }); </code></pre> <p>Here is the function for the render parameter :</p> <pre><code>function duration_time(data, type, dataToSet){ var start = dataToSet.date_start; var end = dataToSet.date_end; var time = moment.utc(moment(end, "YYYY-MM-DD HH:mm:ss").diff(moment(start, "YYYY-MM-DD HH:mm:ss"))).format("mm:ss"); return time; } function incomplete(data, type, dataToSet){ return dataToSet.incomplete == 0 ? 'Complete' : 'Incomplete'; } </code></pre>