I'm trying to print the results of my arrays to the console, but I can't access the functions inside the class. what can we do

Question: I'm trying to print the results of my arrays to the console, but I can't access the functions inside the class. what can we do.
This is the result I want. But arranged according to oop principles

let arrya = [];
let arryb = [];

for (let i = 0; i <= 9; i++) {
  function crad_a(max) {
    a = Math.floor(Math.random() * max);
    return a;
  }
  // console.log(crad_a(10));

  function crad_b(max) {
    b = Math.floor(Math.random() * max);
    return b;
  }
  // console.log(crad_b(10));
  i++;

  arrya.push(crad_a(10));
  arryb.push(crad_b(10));
}
console.log(arrya);
console.log(arryb);

for (let j = 0; j <= arrya.length; j++) {
  if (arrya[j] != arryb[j]) {
    if (arrya[j] > arryb[j]) {
      console.log("a" + " " + "win" + " " + " the game");
    } else {
      console.log("b" + " " + "win" + " " + "the game");
    }
  }
}

This is what I tried and got stuck

class card_number_one {
  constructor() {
    this.card_one = [];
    this.card_tow = [];
  }

  crad_a(max) {
    for (let d = 0; d <= 9; d++) {
      a = Math.floor(Math.random() * max);
      return a;
    }
    d++;
    this.card_one.push(crad_a(10));
  }

  crad_b(max) {
    for (let i = 0; i <= 9; i++) {
      b = Math.floor(Math.random() * max);
      return b;
    }
    i++;
    this.card_tow.push(crad_b(10));
  }
}

console.log(this.card_one); /// Not working for me
Comment: `this` outside of class `card_number_one` points to `window` object(Also depends whether you are running it on a browser or server(node.js) or whether you are in strict mode or not). Maybe acquire some knowledge on how `this` works in JavaScript? MDN is a great place to start.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this
Answer: I would recommend reading this here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes it should help you solve this one. What I notice however;
Classes must be defined before they can be constructed
 // Defining your class
 class Card {
    // stuff
 }

 // Constructing your class
 let foo = new Card();

Then afterwards you can do a log of foo:
console.log(foo)

Its good practice to use pascal notation over camel notation when defining your class, so class Card instead of class cardName.

I am not 100% sure what your method is doing but try to keep your code DRY so instead of having 2 for loops, you can have one method which you can reuse.

So in your case that would be:
ps:// I also changed your method to a getter, you can read more avout getters here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
class Card {
  constructor(array, max) {
    this.array = array;
    this.max = max;
  }
  get maxNumber(){
    for (let i = 0; i <= this.max; i++) {
      return Math.floor(Math.random() * this.max);
    }
  }

}

let array1 = [1,2,3,4];
let array2 = [5,6,7,8];

let card1 = new Card(array1, 10)
let card2 = new Card(array2, 20)

console.log(card1.maxNumber); // Returns 7
console.log(card2.maxNumber); // Returns 6

let difference = card1.maxNumber - card2.maxNumber // Assuming the number doesn't have to be greater than 0.

// Print your message
console.log(`Your game score is ${difference}, good job!`);

So now you have a reusable class, which you can use to load as many cards as you want :)
Comment: Thank you very much. For the answer, it basically works, I will learn from it and try to develop it for my project
Comment: You are welcome, I also learnt about classes not so long ago. Keep going, you are doing great! :)
Answer: Inside your console.log() call the this does not refer to the class (it is outline the class).
You could create an instance of the class, and then log the property of the instance, something like this:

class card_number_one {
  constructor() {
    this.card_one = [];
    this.card_tow = [];
  }
  crad_a(max) {
    for (let d = 0; d <= 9; d++) {
      a = Math.floor(Math.random() * max);
      return a;
    }
    d++;
    this.card_one.push(crad_a(10));
  }
  crad_b(max) {
    for (let i = 0; i <= 9; i++) {
      b = Math.floor(Math.random() * max);
      return b;
    }
    i++;
    this.card_tow.push(crad_b(10));
  }
}

// Create an instance of the class and save it in the "exampleCard" variable
const exampleCard = new card_number_one();

// Console log the property "card_one" of the "exampleCard" instance of your class
console.log(exampleCard.card_one);

There is some good information about JS classes here on MDN


What is a real structure on a manifold?

Question: I have been looking at manifolds (twistor spaces) that have a "real structure". I am not quite sure what this means. I've looked on Wikipedia and they have an article that explains real structures on vector spaces and this makes sense. But I'm not sure how you extrapolate to manifolds. Do you need such a map at every tangent space $T_p M$? Or do you just need an antilinear involution $\sigma: M \rightarrow M$ with some non-empty fixed set?
Also, for the vector space case, what you end up with is $V_{\mathbb{R}} \subset V$ such that $V_{\mathbb{R}} \otimes_{\mathbb{R}} \mathbb{C} \cong V$. This is a nice statement and I can see why you'd like this subspace. But do we have an analogous statement for complex manifolds? Are there such things as complex manifolds without real structures?
So in short, what is a real structure on a complex manifold and why is it useful or important? Thanks for the help.
Comment: It's probably referring to an identification of the bundle $\mathbb{C}^n \to TM \to M$ with $\mathbb{R}^{2n} \to TM \to M$ (globally, not just at a particular fiber).
Answer: The definition I know can be phrased for any complex vector bundle, and it is a real structure on each fibre, varying smoothly along the manifold.
For a complex manifold, you can of course just take the tangent bundle. But if you have e.g. a real spin manifold, you can adjoin some complex representation of the spin group and get a complex spinor bundle. Real structures on these bundles are quite important objects e.g. in the study of noncommutative geometry: Connes proved that if you start with a Riemannian manifold, take the Dirac operator, the *-algebra of functions, the spinor bundle and its real structure (and lots of technical details), you can recover the Riemannian manifold from it.
If you have a real structure on a complex vector bundle in the sense explained above, you have a real structure on the (vector) space of sections of the vector bundle, in the way you already know.

What is a real structure on a manifold?


How to write raw multipart SOAP HTTP message to output with Grails

Question: I have a Grails application that should respond with previously stored raw SOAP messages. These messages are read from a database. When I write the message to output, it is added to body part of the HTTP response. The results is that reading the response on client end fails as the HTTP headers etc are part of the body. The results on client side looks something like this
------=_Part_0_1123526246346
Content-Type: application/soap+xml; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-ID: <some-id>

<soap:Envelope>

</soap:Envelope>

------=_Part_0_1123526246346
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <temp.pdf>
Content-Disposition: attachment; name="temp.pdf"

%%EOF
------=_Part_0_1123526246346--

All this means that it's a multipart SOAP message where a PDF doc comes as an attachment. The messages written to DB are consumed correctly by the client and only the soap envelope is seen as the body, PDF as an attachment.
How can I write this message as RAW ouput with Grails, so that the HTTP stuff does not end up being duplicated?
Answer: If you need full control of the response produced by a controller, including headers, then you should look at the response object which is available. Every controller in Grails has access to the HttpServletResponse through the response object so you can manage the raw response yourself.
However, your problem is that you need a multi-part response and the HTTP headers are embedded in your text. You should be able to parse them out and manually create a MultiPartResponse using the famous package from Jason Hunter.
With a bit of parsing of your data, combining the HttpServletResponse available in Grails and the MultipartResponse you should be able to get the results you need.
Another possible option is to simply set the headers on the HttpServletResponse to indicate it's a multi-part response and write the text/data straight to the output stream. This may or may not work depending on how it's being consumed, but it's worth a try.
// some controller method
response.setContentType("multipart/x-mixed-replace")
response.outputstream << theDataAsAByteArray

Comment: Setting the content-type to multipart does not work with the clients I used. SoapUI hangs after the first response (which is OK by the way) and spring-WS gives an error on incorrect content-type.
Comment: Using the MultipartResponse package is not possible in this case due to the license terms. Thanks for the suggestions, though.
Comment: Setting the content-type to `multipart/related` seems to work for SoapUI, but Spring-WS has a problem: `Missing Start Boundary, or boundary does not start on a new line`. Keeping the question still open in hope for other great input on this.
Comment: After reading about multipart HTTP messages, I finally managed to get this one solved. Setting content type to `multipart/related` was one key thing. Also need to have the `boundary` set in the header, which in this case was an extra burden as the boundary part contains hyphens in the beginning. For the header to work correctly, two first hyphens needed to be removed.


RPSLS: How can the program print out the winning logic depending on which player wins?

Question: So in an attempt to learn Python, I am building an RPSLS game for class. I have most of it done (albeit the efficiency can be improved) but want to make the result change depending on what the action is that leads to a win.
For example if Player 1 chose Spock and Player 2 chose Rock. I want the program to output Spock vaporizes rock
I have tested with a 2D array and tried playing around with index, but alas. Any nudge or what to even search for would be appreciated.
This is what my program looks like:
winningPairs = [("scissors","paper"),
                ("scissors","lizard"),
                ("spock","scissors"),
                ("spock","rock"),
                ("lizard","spock"),
                ("lizard","paper"),
                ("rock","lizard"),
                ("rock","scissors"),
                ("paper","rock"),
                ("paper","spock")]

actionPairs = [ "  - Scissors cuts paper",
                "  - Scissors decapitates lizard",
                "  - Spock smashes scissors",
                "  - Spock vaporizes rock",
                "  - Lizard poisons Spock",
                "  - Lizard eats paper",
                "  - Rock crushes lizard",
                "  - Rock crushes scissors",
                "  - Paper covers rock",
                "  - Paper disproves Spock"]

# ask players for their name
print()
namePlayerOne = input("Player 1, enter your name: ")
namePlayerTwo = input("Player 2, enter your name: ")
print()

# set two variables for keeping score
playerOneScore = 0
playerTwoScore = 0

# ask if players want to see instructions for winning
instructions = input("Would you like to see instructions for winning (y/n)?")
if instructions == "y":
    for action in actionPairs:
        print(action)
print()

while True:
    # asking players for their choice
    playerOneOption = input(f"{namePlayerOne} select your option (Rock, Paper, Scissors, Lizard, Spock): ").lower()
    playerTwoOption = input(f"{namePlayerTwo} select your option (Rock, Paper, Scissors, Lizard, Spock): ").lower()

    # if both players select the same option, it's always a draw
    if playerOneOption == playerTwoOption:
        results = "Draw"

    # check if order of input is same as element in winningPairs, if it is Player one wins (who selects first)
    elif (playerOneOption,playerTwoOption) in winningPairs:
        results = f"{namePlayerOne} wins" # print win
        playerOneScore += 1 # add 1 score to player

    # if elif is not true, player two wins
    else:
        results = f"{namePlayerTwo} wins" # print win
        playerTwoScore += 1 # add 1 score to player

    print("-"*20)
    print(f"{namePlayerOne} chose {playerOneOption}\n{namePlayerTwo} chose {playerTwoOption}") # print each player's pick
    print(results) # print results
    print()
    print(f"{namePlayerOne} score: {playerOneScore}\n{namePlayerTwo} score: {playerTwoScore}") # print player scores
    print("-"*20)
    '''for result in actionPairs:
        if (playerOneOption,playerTwoOption) in winningPairs:
            print(result[winningPairs])'''

    playAgain = input("Play again? (y/n): ") # ask if players want to play again
    if playAgain.lower() != "y":
        break

This is the output so far, when players do not wish to see instructions:
Player 1, enter your name: name1
Player 2, enter your name: name2

Would you like to see instructions for winning (y/n)?n

name1 select your option (Rock, Paper, Scissors, Lizard, Spock): Rock
name2 select your option (Rock, Paper, Scissors, Lizard, Spock): Spock
--------------------
name1 chose rock
name2 chose spock
name2 wins

name1 score: 0
name2 score: 1
--------------------
Play again? (y/n): n

before name2 wins I'd like it to say Spock vaporizes rock, name2 wins and if the winning conditions were changed, so Player 1 was the winner, it should change it in favor of that player.
Comment: check out my answer if there is any query please let me know
Answer: Changes made:-
(1) actionPairs initialised as dictionary
(2) see the edit made portion.
(3) change in the results

Code:-
winningPairs = [("scissors","paper"),
                ("scissors","lizard"),
                ("spock","scissors"),
                ("spock","rock"),
                ("lizard","spock"),
                ("lizard","paper"),
                ("rock","lizard"),
                ("rock","scissors"),
                ("paper","rock"),
                ("paper","spock")]

actionPairs = { 0:"Scissors cuts paper",
                1:"Scissors decapitates lizard",
                2:"Spock smashes scissors",
                3:"Spock vaporizes rock",
                4:"Lizard poisons Spock",
                5:"Lizard eats paper",
                6:"Rock crushes lizard",
                7:"Rock crushes scissors",
                8:"Paper covers rock",
                9:"Paper disproves Spock"}

# ask players for their name
print()
namePlayerOne = input("Player 1, enter your name: ")
namePlayerTwo = input("Player 2, enter your name: ")
print()

# set two variables for keeping score
playerOneScore = 0
playerTwoScore = 0

# ask if players want to see instructions for winning
instructions = input("Would you like to see instructions for winning (y/n)?")
if instructions == "y":
    for action in actionPairs:
        print(action)
print()

while True:
    # asking players for their choice
    playerOneOption = input(f"{namePlayerOne} select your option (Rock, Paper, Scissors, Lizard, Spock): ").lower()
    playerTwoOption = input(f"{namePlayerTwo} select your option (Rock, Paper, Scissors, Lizard, Spock): ").lower()

    #edit made..
    for i in range(len(winningPairs)):
        if winningPairs[i]==(playerOneOption,playerTwoOption) or winningPairs[i]==(playerTwoOption,playerOneOption):
            temp=i

    # if both players select the same option, it's always a draw
    if playerOneOption == playerTwoOption:
        results = "Draw"

    # check if order of input is same as element in winningPairs, if it is Player one wins (who selects first)
    elif (playerOneOption,playerTwoOption) in winningPairs:
        results=actionPairs.get(temp,"")+", "
        results += f"{namePlayerOne} wins" # print win
        playerOneScore += 1 # add 1 score to player

    # if elif is not true, player two wins
    else:
        results=actionPairs.get(temp,"")+", "
        results += f"{namePlayerTwo} wins" # print win
        playerTwoScore += 1 # add 1 score to player

    print("-"*20)
    print(f"{namePlayerOne} chose {playerOneOption}\n{namePlayerTwo} chose {playerTwoOption}") # print each player's pick
    print(results) # print results
    print()
    print(f"{namePlayerOne} score: {playerOneScore}\n{namePlayerTwo} score: {playerTwoScore}") # print player scores
    print("-"*20)
    '''for result in actionPairs:
        if (playerOneOption,playerTwoOption) in winningPairs:
            print(result[winningPairs])'''

    playAgain = input("Play again? (y/n): ") # ask if players want to play again
    if playAgain.lower() != "y":
        break

Output:-
Player 1, enter your name: Yash
Player 2, enter your name: Rohan
Would you like to see instructions for winning (y/n)?n
Yash select your option (Rock, Paper, Scissors, Lizard, Spock): rock
Rohan select your option (Rock, Paper, Scissors, Lizard, Spock): paper
--------------------
Yash chose rock
Rohan chose paper
Paper covers rock, Rohan wins

Yash score: 0
Rohan score: 1
--------------------
Play again? (y/n): y
Yash select your option (Rock, Paper, Scissors, Lizard, Spock): paper
Rohan select your option (Rock, Paper, Scissors, Lizard, Spock): rock
--------------------
Yash chose paper
Rohan chose rock
Paper covers rock, Yash wins

Yash score: 1
Rohan score: 1
--------------------
Play again? (y/n): y
Yash select your option (Rock, Paper, Scissors, Lizard, Spock): paper
Rohan select your option (Rock, Paper, Scissors, Lizard, Spock): paper
--------------------
Yash chose paper
Rohan chose paper
Draw

Yash score: 1
Rohan score: 1
--------------------
Play again? (y/n): n


what is the best route for my shed? what amperage should I use?

Question: ok...so...I am undecided what to use to power up this detached shed, which is 70 feet away from the main panel. I obviously want to go the safest route (shed is 200 square feet) Before hand, I really want to go the 30amp route, due to its cost friendly ways and I dont think I am going to use that much power; just want some opinions.
route 1 -
Use a double pole 60amp with #6-3 UF wire to feed a 60amp sub panel in the detached shed? (wire will be buried)
route 2 -
use a double pole 30amp 10-3 wire UF rated to feed a 50 or 60amp sub panel in the detached shed and use pvc conduit for the wire (or does NEC only allow direct burial with no conduit for UF wire?
what I plan on using in the shed -
3 security cameras
5 outlets (GFCI)
power tools such as table saws and vacuums
small TV and leave batteries charging
thats about it....
what is the best route?
Comment: It really comes down to whatever you plan to run at once, but assuming 200W per rcpt, 200W per battery, 200W for TV, 1800W for table saw, 1500W for shop vac, and like 100W for all the cameras. You're looking at like 5kW reasonable with everything on, which is like 21A on the panel.

This is all variable. But you could definitely cover it with a 30A. But, at the same time, I'd say this is your only chance to get more power without digging up the line, and you're already buying a 60A panel regardless.
Comment: i suppose worst case power load is if you want to run the vac to collect dust from a tool as it is operating..now pushing close to 30 amp right there.
Answer: A 30 amp and 60 amp two pole breaker are basically the same price.
The panel is the same price in both scenarios.
The labor to install it is practically the same.
The only difference is the price of the wire.
For 70 feet of wire price difference I wouldn't skimp on this one.
I would go for scenario #1 and have enough capacity for future expansion.
Good luck!
Comment: I agree with #1 , 30 amps for a work shop is just enough to have you kicking yourself every time you have to reset the breaker and the work putting this in is the real cost.


Why do we have OS names like Mountain Lion, Jellybean, and Quantal Quetzal instead of numbers?

Question: Less of a pressing question and more a "what happened here"?
At some point in the past decade (most) OS's have switched over to these codenames for their versions with names like Mountain Lion, Jellybean, etc. After a heated discussion with my Dad (who prefers version numbers) about why the names would be done like this, it dawned on me to ask if there was a (valid) UX reason for it vs. just a marketing/trademark one.
I don't think this idea has been explored all that well, just because we have such scattered implementations of it -- Android and Ubuntu are the only ones who use alphabetized naming conventions as a reinforcement of version numbering, Apple uses it for OSX (Snow Leopard, Lion...) but not for iOS (iOS4, iOS5...), and Windows isn't consistent about this stuff at all (XP, then Vista, then 7, then 8...)
Is there any rhyme / reason to all of this?
Comment: ...isn't that more a matter of *marketing* than one of UX?
Comment: That's at least part of why I'm asking the question. Besides, there's a healthy overlap between the two.
Comment: Don't forget the earlier versions of Windows:  3.1, 98, etc...  Microsoft _really_ can't seem to decide...
Answer: A few of my guesses:

Numbers are harder to anthropomorphize - we've reached a point with our understanding of computers where we regularly refer to the computer as another being we regularly interact with. It's much easier to give this creature some kind of name vs. a number, especially given that numbers are often used to "dehumanize" things and make them impersonal -- so giving "inhuman" things a name should produce the opposite result.
Names are more memorable than numbers - A huge problem in dealing with all these different devices and builds is that remembering your given OS's version number is... difficult, especially for less dedicated users. Remembering the name of an OS means that people providing tech support can more quickly ID a product version and tailor their advice accordingly.
Names are easier to search for (and provide information on) - Google may have caused this trend inadvertently. Because we search using words as opposed to numbers for most things, there's a much higher noise-to-signal ratio when looking for Something Something 7 (because we also get stuff for Something Something 6, and Something Something 5, and...) vs. SSSSSSSomething. Yes, Google does have some safeguards for this problem, such as relevancy and recency of data, but names still work as a good shortcut, which leads to...
Named Versions are harder to get confused with than Numbered Versions -- You can imagine that confusing something like 10.3.2 and 10.3.3 is easy enough, because they sound very similar, but not so much with Ice Cream Sandwich vs. Jellybean, because they don't sound (or produce mental images of) the same things.

I'm not sure whose approach I like better at this point, Android's vs. Ubuntu's -- The reinforced alliteration in Ubuntu's system (e.g. Quantal Quetzal) makes it produce more unique names while reinforcing the numbering system, but at the risk of making the names harder to memorize. Android's system is better geared towards an easy visual representation (which makes it easier to remember), but a less unique name.
Comment: Contra arguments: Everybody can deduce, that version 7 was earlier than version 9, but 'Lion' and 'Leopard'? More so, if the numbers indicate years: Ubuntu 10.04 arrived in April 2010. But I can't remember which version had which name.
Comment: And don't forget: numbers aren't patent-able...
Comment: @MarjanVenema or trademark-able (which is what I think you meant)
Comment: Working on it... If you'd like to help me, I'd appreciate it.
Comment: @ratchetfreak: yes, you are right, that's what I meant.
Comment: @MarjanVenema: They are in [the United States](http://www.freepatentsonline.com/5373560.html). *(the generator and a few primes are covered in the patent)*
Comment: @Justinᚅᚔᚈᚄᚒᚔ yeah well, anything and everyone is patent-able in the US.
Comment: Good answer, especially so since you asked the question. It would be even better with **references**. Do you have any?
Answer: These are some UX factors:
(human factors as well as marketing reasons)

Names are more "human friendly" than numbers. ("Windows Vista" feels friendlier than "Windows 3.0")
Names can be conveyed in more intuitive way than numbers (I just got Ice-cream Sandwich on my phone)
Names/Things can be something people feel passionate about. ("I like Lion" feels better than "I like 10.x.x"). This promotes indirect marketing.
Can be used intuitively in manuals, tutorials, guides etc., in more human way.

Some less important factors:

Names can convey creativity of company producing software
Names are more interesting and enjoyable than numbers. (e.g. Windows Millennium Edition)
Strong/Bizarre names can create instant identity.
Comment: @userunknown: People are good at remembering names because from our child ages, names are used when talking about other people. And since we're social creatures, that happens a lot.
Comment: @userunknown How are Names more friendly than numbers?
1. Names generally have some meaningful context associated with them, while number usually dont have. (windows 3.0 have no meaningful context associated, while Jelly Bean have.)
2. Also, since every software out there uses similar numbers scheme like 1.0, 4.1 etc. its difficult to remember the association. While names can be different serieses (Desserts, Animal families etc ).
3. Easy to remember. We use eclipse and MSOffice. Everybody remembers its eclipse "Juno", while hardly anybody remembers which office they have.
Comment: How are Names more friendly than numbers? In which way is "Vista" friendly? Or "3.0" unfriendly (shouldn't 3.0 be Windows'95 and Vista something like 9?). Numbers have a natural ordering, which is more userfriendly than zillions of names. Note too, that names can be distracting as well (think about dogs).
Comment: People are good at remembering numbers, and a lot of people don't remember names very well; many do, but not all. And numbers from a child age as well or even better. I can't remember a single Ubuntu release name and there are 14 or 15 since 05.04. Of course it is easy to remember all those numbers, which are ordered and in regular intervals - except for 6.06 which was late.
Comment: @NitinJadhav: If you don't know the meaning of a number, you should revisit elementary school. 'Jelly Bean' has some meaning, but from a `different` context, not from software, which makes it totally arbitrary. What is the meaning of `hardy heron` in context of software? It's arbitrary. But 6.10 is the follower of 6.04 and predecessor of 7.04, and was released 2006 in month no. 10. And since many software uses similar schemes, it is more easy to remember - not harder.
Answer: My best answer is that it's easier to market, especially since it exacerbates the difference between different versions. It only really works for products where the newer version is always better/improved over the previous version, and generally only where the product stands alone/doesn't have substantially different variations (e.g. Windows XP, which had totally separate releases for desktops, media centres and tablet PCs).
In the early releases of MacOS and Mac OS X, Apple didn't use the project codenames publicly. When Apple acquired NeXT and started working on a Unix-based MacOS, they began using codenames like "Yellow Box", "Blue Box", "Red Box" and "Rhapsody". That seemed to have been a deliberate decision to break from the purely numerical OS versions that had preceded it (System 6, System 7, System 7.5, MacOS 8, MacOS 8.1, MacOS 8.5, MacOS 9, MacOS 9.1, MacOS 9.2), and probably to hedge their bets a little bit after what had happened with Copland.
Once Mac OS X was released to the public, it was branded simply "Mac OS X" (at least after the Public Beta period). The codenames for the first two commercial releases of Mac OS X (Cheetah and Puma) were not used anywhere in their marketing. It wasn't until Mac OS X 10.2 (Jaguar) that Apple started to really use the codename in their marketing. While I don't have any real proof of the reasoning, as a user it made sense to me; Jaguar was the first Mac OS X release that many people felt was mature enough to migrate to from MacOS 9. It was fast, pretty and substantially more stable than its predecessor. It seemed Apple had really begun telling people about Jaguar by name since it let them reduce confusion (while only Puma was commercially available). By calling Puma "10.1" and Jaguar by its name, the two products where more easily distinguished.
Ask yourself; if you're running Mac OS X v10.3 and Apple releases v10.4, do you feel compelled to upgrade? That's not even a full number! Compare "Panther" to "Tiger", though, and it's easier for laypeople to distinguish.
There are other advantages too: as a software vendor you can give "names" to any release you like, and skip others. That allows you to present minor releases as major ones to the public. Look at Android's naming scheme:

Android beta (no name)
Android 1.0 (no name)
Android 1.1 (no public name; called "Petit Four" internally)
Android 1.5 (Cupcake)
Android 1.6 (Donut)
Android 2.0/2.1 (Eclair)
Android 2.2 (Froyo)
Android 2.3 (Gingerbread)
Android 3 (Honeycomb)
Android 4.0 (Ice Cream Sandwich)
Android 4.1/4.2 (Jelly Bean)

By using names instead of numerals, Google has been able to bundle multiple point releases under one title (e.g. Eclair and Jelly Bean), and while some names like Gingerbread represented only a minor release over its predecessor, other names like Honeycomb or Ice Cream Sandwich represented full major releases. That flexibility is very useful for marketing.
It's worth mentioning that Windows has recently returned to using version numbers in their release names after a period of not doing so (2000, XP, Vista), but have only ever used their codename in one public release (Millennium; which became Windows Millennium Edition or Windows Me). The codenames, for other those other releases, incidentally, were Janus, Whistler and Longhorn.
One explanation for why they might choose not to use the project's codename is that it allows releases to share one brand even if the internal project teams were given vastly different names (e.g. Windows XP has 7 versions released under the "Windows XP" masthead, but their internal codenames were "Whistler", "Mantis", "Freestyle", "Harmony", "Symphony", "Emerald", and "Lonestar"). Those names also don't communicate any meaningful difference between versions, which makes them very difficult to communicate to customers.
Comment: Wait, you might have missed the details of [what windows did with its version numbering schemes](http://en.wikipedia.org/wiki/Windows_NT#Releases). Windows 2000 is NT 5.0; XP is NT 5.1; Vista is NT 6.0; **Windows 7 is NT 6.1**, (!!!) and **Windows 8 is NT 6.2**! (You get *why* they did that? I don't)
Comment: @ZJR: AFAIK, those are the kernel version numbers, which is why Windows Server 2008 R2 is also NT 6.1. So Windows 7 isn't the same as NT 6.1, it just uses v6.1 of the NT kernel (and by that logic, the numbering actually makes sense). Mind you, it's sensible that MS doesn't expose that to the end-user on the packaging!
Comment: ... is this an admission that everyone is really just buying the same Windows over and over?
Answer: They are using alphabets because it's easier to understand. Look in the case of android, each version is named after a food item and they are named in alphabetical order like cubcake, donuts, eclair, froyo, gingerbread, honeycomb, ice-cream sandwich, jelly bean. You can see how easy it is to be remembered like C, D, E, F, G, H, I.
Comment: I presume you're referring to natural sort ordering. Is that really a scenario OS marketing people need to address? If anything, letters are harder to parse ordering from, because they serve a purpose other than ordering (why aren't people confused that XP came before Vista)?
Comment: But why is alphabetical order easier to understand than numerical order (C, D, E, F compared to 3, 4, 5, 6)?
Comment: If you have previously programming experience you better know why alphabetical order are chosen over numerical..
Answer: In fact they all have version numbers, OS names are generally called "codename".
They are more friendly so their main purpose is to remember it.
Some version numbers:

Windows family
OS X


Are there any guidelines concerning the use of Alt, Ctrl and Shift keys?

Question: I'm designing a complex product to be used in a professional setting, and I'd like to create keyboard shortcuts to the various functions. Are there any guidelines to help me decide when should I use each of the PC modifier keys?
Comment: @nigel222 There is nothing civilised in searching for the mouse, clicking and repositioning your hand on the keyboard. It's only annoying.
Comment: @nigel222 How lucky that this domain is not based on personal prejudices then :).
Comment: @nigel222 This makes no sense. You don't *have* to use keyboard shortcuts, and for any GUI app, there's always a way to do the same thing using the mouse. So what's your problem with them?
Comment: If you have that much of a problem accidentally hitting the keyboard, just unplug it :).  But seriously, keyboard shortcuts are absolutely necessary for many users (especially those of us that have been using computers since before there were mice).
Comment: I've had the opposite problem with randomly firing off mouse gestures while fidgeting with the mouse.
Comment: All of the "I've just pressed a key and broken something with no idea what" problems can and should be solved by global undo. Which should also be on a shortcut (usually Ctrl-Z).
Comment: Desktop or browser application ?
Comment: What platform(s)?
Comment: @nigel222, can you describe exactly how you expect a visually impaired user to use a mouse? Keyboard shortcuts and keyboard support in general are absolutely required for accessibility. Mouse support, on the other hand, is not.
Comment: You don't have to use them but in general you can't turn them off so you can't avoid *accidentally* triggering them. How much I hate them depends on how horrible are the consequences of the worst possible accidental keyboard shortcut. I prefer to think about the *work* and let my fingers handle the *typing* without thought, and randomly activated shortcuts get horribly in my way, especially if I am several keystrokes in before I notice that something has gone awry, and then my productive thought is destroyed while I work out what mess just happened. I'll sign off now.
Comment: Re. @nigel222's (valid) frustration(s), I would say that keyboard shortcuts aren't the problem. *Poorly chosen* keyboard shortcuts are the problem. (Such as single-key hotkeys that "post" or otherwise trigger irreversible events — how I *hate* text input forms that hijack the Return/Enter key for "Submit" rather than using the de-facto Ctrl/Cmd + Return/Enter combo…) Which is why questions like this are *good,* and good UX folks 1) do proper research before choosing random "makes-sense-to-me!" keys, and 2) ask around when in doubt. It promotes sanity (or at least uniformity) between apps. :-)
Comment: I'll accept zzzBov and Tripehound have good points (above) so I'll modify my position. By all means make keyboard shortcuts available to people who want them, but please give me a menu option to turn the horrid things *off*. Global undo is a pipe-dream ... some operations are irreversible (like the e-mail send button), and some mistakes go unnoticed for too long for undo all the way back to be useful, even if it is possible.
Comment: @nigel222 I don't believe I've ever accidentally activated a keyboard shortcut during normal typing. The CTRL and ALT keys are just too far away to accidentally hit them when only attempting to access the central area of a QWERTY keyboard - letters, space, punctuation, and Shift. I have accidentally pressed CTRL when attempting to press Fn or vice versa on a small laptop, or interchanged the Windows key with the key to either side of it, but in all of those scenarios I'm already trying to use a keyboard shortcut - just a different one. I wonder what keyboard layout causes you this problem.
Comment: @MarkG., absolutely agree with that. In the same vein though, it even seems browsers aren't really getting true UI consideration at times. Such as some obscure close commands (that few users likely use) troublingly dropped amidst high use shortcuts... apparently Ctrl+Shift+Q now instructs browsers to quit and forget the tabs you had open, without confirmation!?! Ctrl+W and Ctrl+Q were already damagingly close to the Ctrl+Tab/Ctrl+Shift+Tab often used for moving between tabs... and where my left hand commonly rests when heavily editing text (due to the vital Ctrl+arrow and Ctrl+Shift+arrow)
Comment: Is there a subfield for choosing shortcuts?  It seems one of the least considered UI topics around... even as their layout is very vital to top-level productivity. :-/
Comment: A desktop application.
Comment: My personal prejudice is one word. **Don't**. I loathe keyboard shortcuts, they are like mines waiting to explode under the fingers of a poor typist who does not know the short-cuts. Right-mouse-click menus are so much more civilized and discoverable.
Comment: My view is that it's a whole lot less annoying than pressing (say) Ctrl instead of Shift, and ending up in some other software "room" you have never seen before, with no idea how you got there, what it does, or how to get out with your work unscathed. Or discovering later that what you were working on has been mangled by a single mistaken keystroke which you did not notice at the time. However, I recognise that this is a minority view at present :-(
Comment: @nigel222 Several years ago, when a fairly major ERP system brought out their first Windows client (to a Unix-hosted sever) they put all sorts of "friendly" menus, mouse-clicks etc. Managers loved it because it was "easy to use". Habitual users (used to Ctrl and Fn key shortcuts throughout) saw productivity plummet by a third because they kept having to switch between mouse and keyboard... The next version added shortcuts galore :-)
Comment: Could somebody add a list of standard shortcuts, such as Control C, Control S, etc? It would be nice to have a comprehensive list here as an answer
Comment: Lucky you. CTRL is vertically next to SHIFT. The least of my disasters is hitting CTRL/V when trying for SHIFT/V and getting whatever randomness is in the paste buffer, pasted. At least that one is un-doable, but I don't always notice just a random word or two, or (say) a line/page break,  in time to undo.
Answer: The Microsoft's Guidelines for Keyboard User Interface Design says:

Use the following guidelines for designing shortcut keys:

Assign simple and consistent key combinations.
Make shortcut keys customizable.
Use a shortcut with the CTRL key for actions that represent a large-scale effect, such as CTRL+S for save current document.
Use the SHIFT+ key combination for actions that extend or complement the actions of the standard shortcut key. For example, the
  ALT+TAB shortcut key displays the primary window of a running
  application. Alternatively, the SHIFT+ALT+TAB key combination allows
  you to navigate backward through currently running applications that
  have been previously accessed.
Use the SPACEBAR key as the default action of a control, such as for pressing a button control or toggling the status of a check box
  control. This is similar to clicking the left or primary mouse button.
Use the ENTER key for the default action of a dialog box, if available.
Use the ESC key to stop or cancel an operation.
Avoid modified or case-sensitive letters for shortcuts.
Avoid using the following characters for shortcut keys: @ {} [] \ ~ | ^ ' < >
Avoid ALT+ letter combinations because they may conflict with access keys. In addition, the system uses many specific key
  combinations for specialized input; for example, ALT+~ invokes an
  input editor for the Japanese language.
Avoid CTRL+ALT combinations because the system interprets this combination in some language versions as an ALTGR key, which generates
  alphanumeric characters.*
Avoid assigning combinations that are reserved or defined by the system or are commonly used by other applications.
Do not use the Windows logo key as a modifier key for non-system-level functions.

Thanks @Kristiyan
macOS Human Interface Guidelines for Keyboard Shortcuts
Always respect the system-reserved keyboard shortcuts in your app so that users aren't confused when the shortcuts they know work differently in your app.

Avoid creating a shortcut by adding a modifier key to an existing shortcut, unless the shortcuts are related.
As much as possible, use the Command key as the main modifier key in a keyboard shortcut.
Use the Option key sparingly.
As much as possible, avoid using the Control key.
List multiple modifier keys in the correct order.
Identify a key with two characters by the lower character, unless Shift is part of the shortcut.
Comment: [Don't forget Mac OS.](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/OSXHIGuidelines/Keyboard.html)
Comment: +1 for "Avoid assigning combinations that are reserved or defined by the system or are commonly used by other applications."
Comment: Blender too, for pretty much taking over all of the keyboard except task switching. Do note that on windows at least, you don't create alt shrotcuts per se, you do set up your menus with accelerator keys that create de facto shrotcuts. Also please do your best to keep those shortcuts unique, it's no end of annoying to hit ALT, I, C and have it merely select &Crop or &Color Management because it's not sure which you meant. (Doubly so if submenus are involved.)
Comment: Cue CLion, where ALT is used in a lot of default short-cuts, which are unusable because intercepted by the OS/Desktop... (example: with a Gnome Desktop ALT+F7 grabs the window so you can move it).
Comment: Think of **Shift** as enhancing or further specifying an operation, while **Alt** is an alternate variant on the operation. So if a shortcut is to, for example, perform the opposite or inverse of the standard function, Alt should be used. If an operation is to be done in finer increments, constrained to a grid, or something similar but modified, Shift is the better choice.
Comment: As for ALT, it's crucial to differ between right and left ALT, since the right ALT is used to produce national characters (please correct me, if in some national layouts right ALT is effective too).
Comment: *"Always respect the system-reserved keyboard shortcuts in your app so that users aren't confused when the shortcuts they know work differently in your app."* This is so important, I can't stress it enough. When Adobe assigned Cmd H to Extras in Photoshop, overriding the standard OS X Hide functionality, they committed an unforgivable sin. Every time I install Photoshop I have to go into Preferences and un-f*** this.
Comment: @StarWeaver Blender shortcuts are another world of a topic. They are for the most part logical and intuitive, and considering the large number of shortcuts required, I think they've done a really good job. However, my frustration comes with Windows shortcuts using the Alt key where there is some overlap that causes a conflict. For example, on my Macs I have no problem using Alt S to Shrink/Fatten geometry, but while trying to teach this to a student using Windows it triggered a random Windows function that completely overrode Blender. I disagree with Windows' use of Alt for access shortcuts.
Comment: @9ilsdx9rvj0lo I think that's the AltGr(ave)/Alternate Engraving key, which replaces or is added to the area of the Right Alt key on some(most?) non-US keyboards which I have zero experience with. (Also if the AutoHotKey docs are right it's actually coded under the hood as a sort of macro key for LeftShift+RightAlt or RightAlt+LeftShift (forget which) so as to extend the keyboard interface without changing the signal spec and possibly to provide a worst-case workaround for people stuck with a US keyboard)
Comment: @Mentalist Blender's UX is definatly a matter of internet debate to rival the epics of the *nix text editor wars; really confused about the alt-s though, that's not even been a feature of windows that i've encountered at all myself (through 7). It also occurs to me that programs like blender, photoshop, audacity, etc that exist in a primarially "manipulation" context have a much broader license to interpret the metaphorical space of the shift key than those which are always in "text context" where shift can only ever be used in shortcuts that already include another modkey because, well, caps.
Comment: @StarWeaver Ah, you're right. I was remembering incorrectly about Alt S. It wasn't being used by Windows itself, but by some junkware that was either bundled with Windows or installed by a user (perhaps inadvertently) in that household. There were other problems with conflicting shortcuts too, but Alt S sticks in my mind the most. And good point about software centered around manipulation.
Comment: Of historical interest: Microsoft's guidelines are the distant descendant of IBM's [Common User Access](https://en.wikipedia.org/wiki/IBM_Common_User_Access) standard, which introduced such things as F1 help, Alt+letter menus, and the File menu.
Comment: @9ilsdx9rvj0lo that's the [AltGr](https://en.wikipedia.org/wiki/AltGr_key) which only exists in some keyboard layouts. In languages that I'm using there's absolutely no AltGr key
Comment: @LưuVĩnhPhúc yes, it exists only in some languages, but for their users it's very annoying if you don't differ between right and left alt.
Comment: *"Avoid using the following characters for shortcut keys: @ {} [] \ ~ | ^ ' < >"* -- Proceeds to assign `]` to quick-task list in both Visual Studio and Visual Studio Code on 101-button keyboards. I don't even...
Answer: The UI guidelines are a great start - but are also just that - guidelines. You need to do your research as well.

Standards: Research what are accepted standards. e.g. Ctrl+S for Save.
Familiarity: Research what is being done in similar, competitor, or otherwise comparable applications that your target audience is using.
Multitasking: Research what is being done in other applications that your target audience may be using frequently alongside your product. It can be constantly frustrating when you have to continually remember that Ctrl+D deletes something in one application but duplicates something in another.

This will get you to some starting point - a researched evidence-based starting point.

Association: Next you may be able to pair up corresponding actions. e.g. if two actions are to be performed in succession and one is Ctrl+D, it will be easier for the user if they don't have to switch modifier all the time. Ctrl+D and Ctrl+F is way easier than Ctrl+D and then Ctrl+Alt+F.
Compromise: For complex applications you will have to compromise - you can't make everything a higher priority Ctrl action, and Ctrl+G can only do one thing, so if you have lots of G-actions, the shortcuts are going to be less memorable than 'first letter' associations.
Choose your next shortcut wisely Mister Bond. Choosing shortcuts is a critical part of progressing users from novice to expert and not something to be taken lightly. It's easy to get it wrong in places. Even with a lot of thought you can't cater for everyone's different environments. Lots of applications allow shortcut customization to help get users out of conflicts with other applications.
Get creative: For very complex applications with hundreds of actions, the modifier keys tend to get used for only the most major high level actions.

It's not uncommon to make Ctrl+Q trigger a 'Quick access' input where you can type a couple of (unmodified) characters to achieve an action.
Another option is Ctrl+K (for Key or Key sequence) followed by more control keys e.g. Ctrl+K,Ctrl+W to bookmark a window or Ctrl+K,Ctrl+D to format a document - Microsoft take this approach in complex applications.
In some graphical applications (e.g. CAD/CAM) keyboard input is continually parsed (without a trigger) looking for multi-character mnemonics.

Guidelines: And of course - don't forget to use those guidelines
Test: As you can probably tell from above, keyboard shortcuts are as big a part of the UX as any other design aspect. You still need to test properly + refine.
Comment: One thing I might add is that in some programs where text entry is not the primary task, it can make sense to use plain old un-modified letter keys as shortcuts, as well. For example, in Adobe Illustrator `P` activates the pen tool, `/` removes the active colour, and `X` switches between the fill and stroke colour. Using these is much faster than multi-key shortcuts. Also, don't forget the `F#` keys.
Comment: *> Another option is Ctrl+K (for Key or Key sequence) followed by more control keys* -- in Microsoft-land, this is known as a *chord*, e.g. https://code.visualstudio.com/docs/customization/keybindings#_keyboard-rules "keybindings using chords (two separate keypress actions)"
Comment: @Bob Someone should tell Microsoft that's really more of an [arpeggio](https://en.wikipedia.org/wiki/Arpeggio)
Comment: Wow, I never thought of Ctrl D as anything except "end of file" and Ctrl G as "Bell". I suppose the newline character can go away now, because web pages have paragraph and break tags. Interesting substituting several characters for just one. Unicode! *Doh!*
Comment: @nocomprende `Ctrl+D` is double in Notepad++, delete in Eclipse, deselect in Photoshop. `Ctrl+G` is often go to line in editors, or find next. No one uses it for bell anymore, except in command line
Comment: @thunderblaster It is always interesting watching new users try to hit Ctrl and a letter at the same moment. I try to explain, then they hold the letter down and hit Ctrl... Always a learning curve.
Comment: And localization/standardization? Do you pick a "letter" from the action name, what if this letter is missing after translation? Bold is Gras in French, but still `Ctrl+B`.
Answer: IBM's Common User Access guidelines had great influence in the Windows world, especially in regard to keyboard usage.  Even though developers of a lot of newer applications have never heard of it, they ended up copying keyboard commands from older apps that did.
Answer: The WAI-ARIA spec includes a document detailing best practices for accessible internet applications. The majority of it applies to software in general.


OpenCL global array

Question: I'm new to OpenCL and I've got a problem.
In my program I need an 2 dimensional array. I copied an 1 dimensional array to the graphic card.
As I don't need the 1-dimensional array I've wrote a method which shoudl initialize all needes values. The 2 dimensional array should be __global --- I only have read operations on this array.
Here is my code
typedef struct{
    unsigned char r;
    unsigned char g;
    unsigned char b;
    unsigned char a;
} ColorRGBA;

__constant ColorRGBA array[4096];

__kernel void marchingCubes(__global unsigned char* output)
{
    // DO SOMETHING WITH array

}

__kernel void initValues(__global unsigned char* input){
    // FILL array MAKE 1-dimensional to 2-dimensional (4096,4)
    array = (ColorRGBA*) input;
}

When compiling the OpenCL Program, I get the following error:
:28:8: error: array type 'ColorRGBA __attribute__((address_space(2))) [4096]' is not assignable
        array = (ColorRGBA*) input;

How can I have access to the reshaped array in every thread?
Thanks
Glethien
Answer: I'm not sure about the cast you have, but you cannot assign a pointer to an entire array.  You should do this:
for (int x = 0; x < size_of_input; ++x)
  {
    array[x].r = input[x];
    array[x].g = input[x];
    array[x].b = input[x];
    array[x].a = input[x];
  }

You will need to pass in the size of the input array of your function.
this assumes that your input pixels are in that order throughout the entire array.  RGBARGBARGBA, etc.
Comment: input is an array of length: 16384 unsigned chars.
I want to convert this into an array of shape (4096,4) and store it in  a global array.

If i use your way, wouldn't it create an array with shape(0,x,y)?
Comment: @glethien I've made some edits to my answer, let me know if that is what you're looking for?
Comment: not really.... In python I do it this way:

        self.grid = numpy.load("./testData.npy")
        self.grid = self.grid.reshape((4096,4))

In the original input each block of 4 is one ColorRGBA
Comment: @glethen, you can't do that, because it's strongly typed, where Python doesn't care so much about types. This is the only way I know of to do this.
Answer: I would not bother explicitly recording your data - just deal with it as a 1D buffer.  You can pass the row_width as a kernel argument, and then calculate the appropriate index with index = y * row_width + x.
Comment: I solved it in a dirty way but it will work for me. As I am new to stackOverflow I cant post an answer to my question...
Comment: Well, keep participating and revisit this question once you have the ability to self-answer.  Glad you found a solution.

OpenCL global array


C++ No Appropriate Default Constructor I am lost

Question: I am stuck on a problem involving Polymorphism. My code keeps telling me that there is no default constructor for my class in this case I named creature, even though I did instantiate a constructor that takes a string in the creature class. I have a feeling I am missing something very small here and was hoping someone could help me with this. The code is as follows below.
class Creature
{
public:

Creature(string);
virtual void DoAction() = 0;
virtual void DrawOnScreen() = 0;

protected:
string CreatureName;
};

Creature::Creature(string pname)
{
this->CreatureName = pname;
};

class Monster : public Creature
{

Monster(string CreatureName);
void DoAction();

protected:
string CreatureName;

};

Monster::Monster(string pname)
{
this->CreatureName = pname;
};

class Player : public Creature
{
Player(string CreatureName);
void DoAction();

protected:
string CreatureName;
};

Player::Player(string pname)
{
this->CreatureName = pname;
}

class WildPig : public Creature
{
WildPig(string CreatureName);
void DoAction();
protected:
string CreatureName;
};

WildPig::WildPig(string pname)
{
this->CreatureName = pname;
}

class Dragon : public Creature
{
Dragon(string CreatureName);
void DoAction();
protected:
string CreatureName;
};

Dragon::Dragon(string pname)
{
this->CreatureName = pname;
}

I only included the classes within this snippet to keep it short and focused on where I believe the problem lies. Any help would be greatly appreciated.
Comment: Your subclass constructors should call the parent class constructor with the `string` parameter. `Monster(string pname) : Creature(pname) { }`
Comment: You say "even though", but you did not mention a contradiction. You defined a constructor taking a parameter. There is no constructor that takes no parameters (a.k.a. a default constructor).
Comment: Derived classes don't need to have `string CreatureName;` as it is already inherited from base class.
Answer: Monster::Monster(string pname)
{
    this->CreatureName = pname;
}

is equivalent to
Monster::Monster(string pname) : Creature()
{
    this->CreatureName = pname;
}

And Creature doesn't have default constructor. You need:
Monster::Monster(string pname) : Creature(pname) {}


Problems with VNC in gnome ubuntu 16.04

Question: I'm having some strange issues with a fresh VNC server install. I recently built a new Plex server, and it's running gnome Ubuntu 16.04. So far, I've gotten the openSSH server up and running with Google 2FA authentication. Now I'm working on getting vnc working so that I can ultimately run this headless, and remote into it with vnc through SSH when need be.
I started out running just:
sudo apt-get install vnc4server

then, ran vncserver to configure it and set the password, so far, so good.
I then went to my client PC (Windows 10), and attempted to connect without SSH, just to make sure it's working. That's the first issue, upon connecting, I'm getting just a grey screen, which I think is due to the desktop environment not coming up correctly with the connection is made, which I think I can fix by modifying the ~/.vnc/xstartup file.
So back on the server, I ran:
sudo gedit ~/.vnc/xstartup

Now I'm receiving an error, anytime I try to open a gui application as sudo, that error is:
[sudo] password for username:
No protocol specified
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:12145): Gtk-WARNING **: cannot open display: :0

Now I'm lost. I'm 100% sure this is related to VNC, but even shutting down the VNC server doesn't fix it.
Anyone got any ideas? I'm just spinning my wheels and getting frustrated at this point.
Comment: See [Why should users never use normal sudo to start graphical applications?](http://askubuntu.com/questions/270006/why-should-users-never-use-normal-sudo-to-start-graphical-applications) - in particular, you **certainly** shouldn't be using `sudo` to edit your `~/.vnc/xstartup` file
Answer: Recently I have been struggling with VNC on a Raspberry Pi. I got similar errors like you at the client side.
I decided to install TightVNCserver instead of the default, since TightVNC got many good reviews.
You can install TightVNC on your server (sudo apt-get install tightvncserver).
First stop the other VNC server software or remove it.
Then to test TightVNC, you log in as normal user, and set a VNC password.
$ tightvncpasswd
After that start tightvnc as normal user on your server.
$ tightvncserver
That would start VNC on your server.
Then on your local machine do the following, to build an ssh tunnel :
$ ssh -v remote-username@remote-hostname -L 5901:localhost:5901
This needed because VNC runs at localhost by default, but also needed
to prevent plain text traffic.
After that start Remmina client, and configure it to connect to localhost:5901 with the remote username and the VNC password you created.
When this test works fine, you can continue to create a start-up script
for boot time on your server, or decide to use it manually after each reboot.
Apart from VNC, the x2go is in my opinion nicer and easier to use.
A very cool solution for a remote desktop.
X2go is available in the Ubuntu repositories. For more info have a look here :
http://wiki.x2go.org/doku.php/start
Comment: Thanks for the suggestion, I tried removing vnc4server, and installing tightvnc, but I'm still getting the grey screen issue when attempting to connect, however a reboot did appear to fix the sudo issue I was having.

Problems with VNC in gnome ubuntu 16.04


Save commandline commands for Python

Question: I have a tool that's in Python- it resides in a git repository.
Whenever this tool is started (say, $mytool start is the command that starts the tool)- I want to save all the following command line commands in a history file in the current directory.
unix terminal/shell:
<code>   $pwd
   $xyx
   $mytool start
   $abc
   $abc1
   $abc2
</code>
In the history.txt should have:
<code>   $mytool start
   $abc
   $abc1
   $abc2
</code>
What code can I add in my tool (in Python) to save the cmdline commands (not the cmdline output) in a file?
Comment: To save all the output on the terminal, you could use  [`script(1)` utility](http://man7.org/linux/man-pages/man1/script.1.html).
Answer: This is already done for you by bash history. Its stored in .bash_history in your home dir
Comment: I know about bash history and this is not what I want. I only want a portion of the commandlines to be saved, the ones that are related to mytool, so that if someone else pulls my repo, they get my command history.
Comment: so open the file in python and take out the bits you need then put them in your log file

Save commandline commands for Python


How much trade data is enough for mission?

Question: I accepted this mission

After travelling to Kini, I found the shattered remains of a ship and scooped up a canister of "trade data". I then returned to Aristotle gateway.

However the Missions screen didn't offer me a chance to receive my reward.
Why?
Comment: I haven't done one of these sorts of missions, but my guess is you picked up a non-unique instance of "Trade Data" which does not apply for this mission.
Answer: I believe that "these goods are unique to this mission" means you're looking for a mission-specific signal source, not just any signal source holding trade data.
Sometimes scanning the nav beacon (drop in and get a scan of the actual beacon) can help (leads to a mission update message giving you a more specific location).
Scan all the signal sources until you find a mission-specific one. It will be really obvious after you scan it (different color, clearly says it's for your mission, etc).
It's also possible that you found a bugged mission. Sometimes that happens, and there's no way to actually complete it.
I'm not sure I've actually done a "trade data" mission, but I have definitely done some "exploration data" missions, so the mechanics should be similar.


How much old termite damage is acceptable?

Question: Renovating a house. We confirmed with a pest company that there was a prior termite infestation but no current termite infestation. We are replacing some baseboards and I saw evidence of the old infestation and cut out some drywall to have a closer look. There are no issues with the wall but obvious termite damage on the bottom plate of this exterior wall. How risky would it be to just cover it up with some drywall and continue the baseboard project or do I need to hit pause/are we in a more drastic situation. The damage does not appear to cross through the full width of each floor plate.
Comment: I added a comment up here, since it wasn't part of the process, but get this right, this is most likely a bearing wall. After you get the floor done well then you can get about 10-2X4 to temp. hold the wall up to do the other work, It is actually easy, just tedious.  Here is a video from This Old House on the type of shoring to use. It may not even require cutting the studs to length. I have used this method and it really goes in fast and picks up a lot of weight.    https://www.youtube.com/watch?v=rZsS_4HiHT8    It is all in the first few minutes of the video the rest is not applicable.
Comment: Glad to se you got the drywall cut a little higher. With the video link in the prior comment and get the wall shored up about 1 ft away from the outside wall, you could take out the whole plate, cutting the rotted stud bottoms off first with a circular saw which will cut about 1/2 way through. That will establish a straight, square cut to follow the rest of the depth with an oscillating saw. Remove those cutoffs and the bad plate will practically lift out. Set the new lower plate in place, nail it down, then drive in the upper plate and release the temporary wall. The nail off the bottoms.
Comment: Since my shoring wall will be sitting on perpendicular floor joists shouldn't I build a second shoring wall directly below in the basement so that the load transfer goes directly to the basement floor and not entirely to the joists? If that's what I need to do what is a good way to ensure my to support walls are exactly on top of each other without drilling through my nice oak floors?
Comment: @Chris yes, you should have a 2nd wall in the basement to take the weight of the wall on the first floor. Odds are good that this is specified in the TOH video in the first comment (though I haven't watched _this_ specific one, I've watched enough TOH to know that they will ensure temp walls line up all the way from the floor requiring work to the lowest level in the house).
Comment: What about the damage under my front door. I assume the plate runs under that too? See new photo
Comment: Help me get the whole "picture".... you have a basement, the first floor where the pictures of the damaged plate are, and perhaps a second floor? If there is no second floor, and the reason I asked you made sure the joists are in great shape was so you could shore up only the level where the work is needed. Walls are cantilevered quite often when building a house up to 2 feet. A 1 foot offset will work on its own, but if you feel you need to do the basement too.... This was also assuming a single floor house.
Comment: Two story house With an unfinished basement with exposed ceiling joists directly beneath this area so building a second support wall would be straightforward I assume
Comment: New photo added showing same side of house from the basement view
Comment: Since there is a floor above the one with the damage, It may take more than 10 - 2X4s. you will need enough to place each "prop" or angled stud so they will be somewhere about 16 to 20" apart at the top. If there is a bathroom over the area, more shoring for sure. If there is a bedroom over the area it will not be so critical.
Answer: The plate should be replaced. The stud bottoms are seriously affected too. If possible, investigate the damage in the crawlspace too. The repairs may need to start there. Termites, in most cases enter from the ground and start eating their way up.
Not knowing what the condition of the rim joist or the joist ends for that matter, all I can suggest is what I see in your pictures. The walls can be temporarily supported by another wall added to the inside so the plate can be removed without the wall dropping anymore. The damaged studs may only need 1 1/2" cut off the bottoms to get back to solid wood, then when the plates go back in, they can go back in doubled to make up what has been cut off the studs.
Comment: +1 for mentioning the crawl space and all the elements down there like rim joists, etc. The exterior wall is acting like a giant beam, but when a giant load is placed on it , it will crush those studs, plate, etc. causing cracks in the wall board.
Comment: You can replace it in sections as small as 4 feet, but larger the better for the actual sill plate. The "filler plate" can be smaller sections like 4 feet long but do not let the joints in the lower run of plate line up with the joints with the upper. I would not hold my breath on what the plywood subfloor looks like under the plate. Termites are attracted to moisture. If the wood was bone dry, it would be less attractive to the pests.  I say that since windows are there in the area, and a leaky window may be the culprit to bring the termites there. Landscaping close to the siding will is bad
Comment: The sill plate needs to be bolted down, no exceptions, as per code. Depending on where you are located it may need additional bolts for high wind conditions or seismic loading.
Comment: If you are certain that is all there is a block will do. If you take a scratch awl or ice pick down with you, stick it in what is known to be solid wood and compare it with the areas that have a small bit of VISIBLE damage. It may give you a better idea of the damage you don't see. Either way, it is better to cover more area in your repair when you are working a "one sided" view of the damage A BIG plus if none of the joist ends are affected. Please confirm.
Comment: Can I replace the seal plate in sections or does it need to be 112 foot continuous piece for the entire damaged area
Comment: Yes that's probably it. We replaced all the windows since this termite damage happened and we cut down two trees that were near the house so hopefully we've addressed that part of the issue at least.
Comment: Earlier I did realize I used the wrong term for the bottom or sole plate, calling it the sill plate.  Speaking of the sill plate now that is on top of the foundation, absolutely, it will need to be bolted down at least, should the damage go down that far. Usually, sill plates, real sill plates, not what I mistakenly called sill plates are either pressure treated to resist pests or at least regular framing set on top of a layer of copper to deter termites. That's not much protection, but it what was used back in the day, possibly still these days.
Comment: Inspected the crawlspace. Plywood subfloor looks OK but won't know until we remove the sole plates And have a look from above. Some minor damage to about 6 inch section of the rim joist assume I could just add some blocking in between the perpendicular floor joists and take care of that that way?
Comment: Gave all the visible rim joists a good whack with hammer, everything seems solid minus the one 6" area that butts up to the rotted end of the floor joist. I actually think this was water not termites. No visible termite damage really at all from the crawl space/ basement view. I think the primary termite issue is on the first floor at that sole plate. Assume nonissue if I install rim joist blocking across full length of house, just for peace of mind?
Comment: Yes that will work. Typically rim joists are only one 2X on edge. With the sole plate being a minimum of 3 1/2" adding the row you speak of will pick up the width of the sole plate above very handily. Now if I may make one last suggestion regarding the added blocking... LVL (laminated veneer lumber) is much much less prone to shrinkage than dimensional lumber. It is more costly but it is stable. One hint on the installation of the blocks. Do not cut them really snug on the length, you may need to rip them to width. Make sure the height is snug, more than snug, so they need to be driven (Cont.)
Comment: (Cont.) in, using a scrap block to protect the driven end, setting the block in vertically, driving it in and "rotating it into place as you drive it in.  Another approach for the same purpose is after ripping the LVL to width, bevel the edge about 10 degrees+ approx. 1/3 the 1 3/4" edge so it does not hang on the bottom sill plate when the block is paced into the upper corner where the rim joist meets the subfloor and driven in along the bottom edge. Still use a protector block. Make sure the sill plate is really clean before either approach is used


VLC Plays Local Files, Does not Play Files on SMB Share

Question: VLC Media player is not playing files on my SMB Network Share, although it plays local media fine. I get this error when I try to play from the share:
Your input can't be opened:
VLC is unable to open the MRL 'smb://email@example.com/Files/Caden/Music/FINALE.mp3'. Check the log for details.
But, when I download the file, it plays it fine. Help?
EDIT: This is VLC's output when opened in the terminal:
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
[0000000001c21148] core libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
KSambaShare: Could not find smb.conf!
libdvdnav: Using dvdnav version 5.0.3
libdvdread: Couldn't find device name.
libdvdread:DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFilePath:findDVDFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[0000000001cefd68] core playlist: stopping playba

Comment: Seems to be a file path issue, just mount your filesystem without using ubuntu's native gui. see https://gist.github.com/ipbastola/eaa107b4640262a108fcc3ef57d24836
Answer: That's a known VLC issue.  It never did.  When you mount your network share, its files are also shown in the /run/user/your_user_id/gvfs folder.  Locate the file you want to play in that folder and play it from there.
Comment: 1. I cannot find the files there. 2. VLC for Windows plays the files just fine.
Answer: i set in smb.conf

min protocol = SMB1
max protocol = SMB1

and works fine
Comment: Worked at first on my Feren OS (Ubuntu 20 based) then stopped working... so weird
Comment: probably a bad idea, see https://www.google.com/search?channel=fs&client=ubuntu&q=smb1+security+issues
Answer: I had issues with VLC not playing from my NAS. It gave 'Bad file descriptor' error. The solution was to switch off some advanced SMB parameters on the NAS file sharing setting.
By the way, regardless of the settings, the Windows Media Player could play those videos.
Answer: I had issues with VLC installed via snap on Ubuntu 20, I switch to regular apt install and now it works as expected :
sudo snap remove vlc
sudo apt install vlc

Comment: This made no difference to me on u22.04


jQuery: show and hide list elements of equivalent position in other list

Question: I'm stuck on something that I think should be easy... I've got a ul of links, and ul below that with a list of descriptions relating to each link. When I hover over a link in the first ul, I want to hide all the descriptions in the second ul, and just show the relevant one.
So I basically want to tell jQuery, for each link: "On hover, find my position in the list, then show the li at the equivalent position in the other list". I've got as far as:
$("ul#links li").hover(
    function () {
        $("ul#descriptions li").hide();
        /* need to show the relevant one here! */
    },
    function () {
        $("ul#descriptions li").hide();
    }
);

Any help would be greatly appreciated!
Answer: Try using index and eq:
$("ul#descriptions li").hide();
var index = $(this).index();
$("ul#descriptions li").eq(index).show();

Working example: http://jsfiddle.net/mdamC/


How to customize LXQt theming on 16.04

Question: I have installed LXQt via the lxqt-metapackage and while it seems like a grand desktop environment, I can't seem to customize it. I Google searched for ways to customize its themes and such and found this link. It suggested that LXQt has some configuration centre, which I can't seem to find on Ubuntu. I have tried searching /usr/bin for lxqt (using ls /usr/bin | grep lxqt) and the closest command I could find to a configuration centre was lxqt-config-session, which has no theming options.
I also ran sudo apt-cache search lxqt | grep config and found the lxqt-config package which I attempted to install, but this failed leading to this error:
E: Unable to correct problems, you have held broken packages.

No files to download.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 lxqt-config : Depends: libkf5screen6 (>= 5.1.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I have Kubuntu also installed, and from what I can gather libkf5screen6
conflicts with libkf5screen7 which I have installed.
Answer: Well yes if you have 16.04 installed and want libkfscreen7 installed which is not in the regular ubuntu repos I think you might have backported it for a more recent version of kde as I know the kubuntu team does backports.
And yes the configuration center is part of the lxqt-config package. This is a danger of installing PPAs on your system in that you can have other packages with conflicts from new versions https://help.ubuntu.com/community/PPA . However lxqt-config in yakkety is http://packages.ubuntu.com/xenial/lxqt-config shows the dependences in xenial and http://packages.ubuntu.com/yakkety/lxqt-config shows the dependencies. If you have other packages that depend on libkf5screen7 then you will not run into this problem on yakkety. I don't see a reason you would install the the libkf5screen7 on xenial without dependencies on it as it a library then you could  sudo apt-get remove libkfscreen7. Although you can see if you use anything that depends on it with apt-cache rdepends libkf5screen7 and if you don't have anything you can remove it. This is a case of https://en.wikipedia.org/wiki/Dependency_hell. If you remove the things that depend on libkf5screen7 you then can remove it and then install lxqt-config. However this will not happen on yakkety but yakkety is not a long term support release.

How to customize LXQt theming on 16.04


PHP Parse Error syntax error, unexpected '[', expecting ')'

Question: I am facing the following error:
PHP Parse error:  syntax error, unexpected '[', expecting ')'

The line of code throwing the error is:
$contents = str_replace(["\r\n","\r","\t","\n",'  ','    ','     '], '', $contents);

This PHP is within Magento 1.9. I am not familiar with PHP, so I wonder what this code is trying to do or why it would be throwing an error.
Comment: You could have Google'd the error, really.
Comment: What PHP version are you running?
Comment: I am running 5.6.33
Comment: @FunkFortyNiner thanks but I already did that. Although some things may come easier to you, I need a little more help on this topic.
Comment: either try escaping the brackets `str_replace(\["\r\n","\r","\t","\n",'  ','    ','     '\],` or remove them entirely `("\r\n","\r","\t","\n",'  ','    ','     ',` - at this point, it's hard to tell what you're really wanting to do here.
Answer: Are you running this with a PHP version prior to 5.4? There did not know the short array syntax yet, so you have to write array(\r\n","\r","\t","\n",'  ','    ','     ') instead
Comment: You beat me to it
Comment: 5.6.33 is the version of PHP. Sorry for not including.
Comment: Technically, `array(\r\n"` is missing a double quote.
Comment: Yeah, lost that on copying...


Restocking my house

Question: Is it possible (or does it happen automatically) to restock the stuff in my house? I bought the Solitude house with alchemy table and took all the ingredients around. Is there a way to get them there again?
Thanks
Comment: Other than trying to drop them in place from your inventory, I see no other way to restock the house.
Answer: In past games they've never restocked themselves, I'm also assuming this is the case here also. I've got no hard evidence of it, but at the same time, logically it isn't a shop and you've bought a house/upgrades with contents already in it as part of that package. Why should it restock unless you bought another upgrade or put items inside chests yourself/dropped items in your house? Or if an anti-thief walked in and basically decided "I know! I'll place items in this dude's house and make it look REALLY cool!" which isn't going to happen :). Does this make sense? :)
Comment: A smart thief asks "*Can you refill the house so I can steal even more stuff?*"
Comment: It doesn't make sense to automatically restock it, no. That's why I mainly asked if it was possible to somehow restock it (i.e. buy a refill-upgrade from the house seller etc.)
Comment: Good point. I never thought of it that way. Well from what I remember there's never been a way to do that, it might be a new feature in Skyrim though :).

Restocking my house


Ubuntu14.04: UNE 4G LTE mobile modem not connecting

Question: I recently upgraded Ubuntu from 12.04 to 14.04 and as a result I lost my 4G LTE connection. (It is working ok in windows. I have dual booting). When I try to connect via the UNE icon Ubuntu replies with:

The device has been disconnected or is unavailable

The output from lsusb indicates that the 4G mobile modem (HUAWEI E398) is recognized, see below:
Bus 002 Device 005: ID 0951:1642 Kingston Technology DT101 G2
Bus 002 Device 004: ID 046d:c019 Logitech, Inc. Optical Tilt Wheel Mouse
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 1bcf:288a Sunplus Innovation Technology Inc.
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I uninstalled the driver (provided by the vendor) and tried to install it again but Ubuntu 14.04 replies with some error messages, the output from
"./install" in dir: /usr/local/UNE_4G_LTE is:
Installed version: 21.005.22.05.570
Installing version: 21.005.22.05.570

The software is exist. Do you want overwrite it? ([Y]/N):Y

Local path is: /usr/local/UNE_4G_LTE

Installing UNE 4G LTE...DRIVER COPY START
STA_PATH_FLAG=.
STA_PATH_FULL=/usr/local/UNE_4G_LTE/driver/install
START_PATH_DRIVER=/usr/local/UNE_4G_LTE/driver
CURRENT install from ./driver/install
INSTALL_PATH=/usr/local/UNE_4G_LTE
DRIVER COPY END
modinfo: ERROR: missing module or filename.
rmmod: ERROR: ../libkmod/libkmod-module.c:769 kmod_module_remove_module() could not remove 'cdc_ether': No such file or directory
rmmod: ERROR: could not remove module cdc_ether: No such file or directory
rmmod: ERROR: ../libkmod/libkmod-module.c:769 kmod_module_remove_module() could not remove 'usbnet': Resource temporarily unavailable
rmmod: ERROR: could not remove module usbnet: Resource temporarily unavailable
rmmod: ERROR: ../libkmod/libkmod-module.c:769 kmod_module_remove_module() could not remove 'hw_cdc_driver': No such file or directory
rmmod: ERROR: could not remove module hw_cdc_driver: No such file or directory
make -C src/ clean
make[1]: Entering directory `/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src'
rm -rf *.o *.ko *~ core* .dep* .*.d .*.cmd *.mod.c *.a *.s .*.flags .tmp_versions Module.symvers Modules.symvers *.order
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/add_header.sh  "clean" "/lib/modules/3.13.0-55-generic/build/include/linux/usb"
rmmod -f hw_cdc_driver
rmmod: ERROR: ../libkmod/libkmod-module.c:769 kmod_module_remove_module() could not remove 'hw_cdc_driver': No such file or directory
rmmod: ERROR: could not remove module hw_cdc_driver: No such file or directory
make[1]: *** [clean] Error 1
make[1]: Leaving directory `/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src'
make: *** [clean] Error 2
make -C src/ modules
make[1]: Entering directory `/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src'
#/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/add_header.sh  "modules" "/lib/modules/3.13.0-55-generic/build/include/linux/usb"
make -C /lib/modules/3.13.0-55-generic/build SUBDIRS=/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src modules
make[2]: Entering directory `/usr/src/linux-headers-3.13.0-55-generic'
  CC [M]  /usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.o
In file included from include/linux/module.h:17:0,
                 from /usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:23:
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c: In function '__check_ncm_prefer_32':
include/linux/moduleparam.h:349:45: warning: return from incompatible pointer type [enabled by default]
  static inline type *__check_##name(void) { return(p); }
                                             ^
include/linux/moduleparam.h:395:35: note: in expansion of macro '__param_check'
 #define param_check_bool(name, p) __param_check(name, p, bool)
                                   ^
include/linux/moduleparam.h:127:2: note: in expansion of macro 'param_check_bool'
  param_check_##type(name, &(value));       \
  ^
include/linux/moduleparam.h:113:2: note: in expansion of macro 'module_param_named'
  module_param_named(name, name, type, perm)
  ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:113:1: note: in expansion of macro 'module_param'
 module_param(ncm_prefer_32, bool, S_IRUGO);
 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c: In function '__check_ncm_prefer_crc':
include/linux/moduleparam.h:349:45: warning: return from incompatible pointer type [enabled by default]
  static inline type *__check_##name(void) { return(p); }
                                             ^
include/linux/moduleparam.h:395:35: note: in expansion of macro '__param_check'
 #define param_check_bool(name, p) __param_check(name, p, bool)
                                   ^
include/linux/moduleparam.h:127:2: note: in expansion of macro 'param_check_bool'
  param_check_##type(name, &(value));       \
  ^
include/linux/moduleparam.h:113:2: note: in expansion of macro 'module_param_named'
  module_param_named(name, name, type, perm)
  ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:116:1: note: in expansion of macro 'module_param'
 module_param(ncm_prefer_crc, bool, S_IRUGO);
 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c: In function '__check_rt_debug':
include/linux/moduleparam.h:349:45: warning: return from incompatible pointer type [enabled by default]
  static inline type *__check_##name(void) { return(p); }
                                             ^
include/linux/moduleparam.h:395:35: note: in expansion of macro '__param_check'
 #define param_check_bool(name, p) __param_check(name, p, bool)
                                   ^
include/linux/moduleparam.h:127:2: note: in expansion of macro 'param_check_bool'
  param_check_##type(name, &(value));       \
  ^
include/linux/moduleparam.h:113:2: note: in expansion of macro 'module_param_named'
  module_param_named(name, name, type, perm)
  ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:128:1: note: in expansion of macro 'module_param'
 module_param(rt_debug, bool, S_IRUGO|S_IWUSR);
 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c: In function 'rx_tlp_parse':
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:1085:7: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
       unsigned char *ptr = (unsigned char *)kmalloc(dev->hw_tlp_tmp_buf.bytesneeded + dev->hw_tlp_tmp_buf.pktlength
       ^
In file included from include/linux/cache.h:4:0,
                 from include/linux/time.h:4,
                 from include/linux/stat.h:18,
                 from include/linux/module.h:10,
                 from /usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:23:
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c: In function 'cdc_ncm_config':
include/linux/kernel.h:678:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
  (void) (&_max1 == &_max2);  \
                 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:488:41: note: in expansion of macro 'max'
 #define NCM_NTB_HARD_MAX_IN_SIZE ((u32)(max(16,ncm_read_size_in1k) * 1024))
                                         ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:2037:24: note: in expansion of macro 'NCM_NTB_HARD_MAX_IN_SIZE'
  if (ctx->rx_max_ntb > NCM_NTB_HARD_MAX_IN_SIZE) {
                        ^
include/linux/kernel.h:678:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
  (void) (&_max1 == &_max2);  \
                 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:488:41: note: in expansion of macro 'max'
 #define NCM_NTB_HARD_MAX_IN_SIZE ((u32)(max(16,ncm_read_size_in1k) * 1024))
                                         ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:655:76: note: in expansion of macro 'NCM_NTB_HARD_MAX_IN_SIZE'
  ((void)(rt_debug && printk(KERN_ERR "Hw_cdc_driver######: " fmt "\n" , ## arg)))
                                                                            ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:2038:3: note: in expansion of macro 'devdbg'
   devdbg(ctx->ndev, "dwNtbInMaxSize (%u) must be at most %u "
   ^
include/linux/kernel.h:678:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
  (void) (&_max1 == &_max2);  \
                 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:488:41: note: in expansion of macro 'max'
 #define NCM_NTB_HARD_MAX_IN_SIZE ((u32)(max(16,ncm_read_size_in1k) * 1024))
                                         ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:655:76: note: in expansion of macro 'NCM_NTB_HARD_MAX_IN_SIZE'
  ((void)(rt_debug && printk(KERN_ERR "Hw_cdc_driver######: " fmt "\n" , ## arg)))
                                                                            ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:2038:3: note: in expansion of macro 'devdbg'
   devdbg(ctx->ndev, "dwNtbInMaxSize (%u) must be at most %u "
   ^
include/linux/kernel.h:678:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
  (void) (&_max1 == &_max2);  \
                 ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:488:41: note: in expansion of macro 'max'
 #define NCM_NTB_HARD_MAX_IN_SIZE ((u32)(max(16,ncm_read_size_in1k) * 1024))
                                         ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:2042:21: note: in expansion of macro 'NCM_NTB_HARD_MAX_IN_SIZE'
   ctx->rx_max_ntb = NCM_NTB_HARD_MAX_IN_SIZE;
                     ^
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c: In function 'hw_cdc_probe':
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.c:2590:3: error: implicit declaration of function 'dbg' [-Werror=implicit-function-declaration]
   dbg ("can't kmalloc dev");
   ^
cc1: some warnings being treated as errors
make[3]: *** [/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/hw_cdc_driver.o] Error 1
make[2]: *** [_module_/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src] Error 2
make[2]: Leaving directory `/usr/src/linux-headers-3.13.0-55-generic'
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src'
make: *** [modules] Error 2
make -C src/ install
make[1]: Entering directory `/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src'
#install -m 744 -c hw_cdc_driver.o /lib/modules/3.13.0-55-generic/kernel/drivers/usb/net
#depmod -a
#modprobe hw_cdc_driver
/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src/add_header.sh  "install"
modprobe hw_cdc_driver
modprobe: FATAL: Module hw_cdc_driver not found.
make[1]: *** [install] Error 1
make[1]: Leaving directory `/usr/local/UNE_4G_LTE/driver/ndis_driver/ndis_src/src'
make: *** [install] Error 2

Install NDIS driver failed.
The compiling environment is not all ready.
Please check gcc, make and kernel buid(/lib/modules/3.13.0-55-generic/build) to be all installed?
Now please enter any key to finish other installations.

I cannot understand what is going on, I had no problem compiling and connecting the 4G mobile model in Ubuntu 12.04, I wish I could go back to 12.04! Is there any person who has faced a similar problem and solved it?
This one is driving me crazy, any help would be greatly appreciated.
Answer: Please, do not use vendor drivers from Une, Tigo, and the rest of the Movile broadband devices vendors. That drivers cause a lot of problems and can simply break your internet connection. I had a similar problem with a ZTE modem from Movistar, i tried to install the driver, but that let me wihout internet and borke my modem manager. Check if you have installed  GCC, g++ and cmake. You can install the Modem manager GUI, which is designed for Ubuntu.
Comment: Thank you very much for the suggestion. The mobile modem is now working fine using 'modem manager'. Cheers,
Answer: You can switch your modem to only modem mode by running in terminal
echo -e 'AT^SETPORT="A1,A2;10,12,13,A2"\r' | sudo tee  /dev/ttyUSB0

then re-plug the modem and wait for 30 seconds.
After this setting the modem may not work with vendor software in Windows. You may need to setup a telephone connection there.
This setting can be undone by
echo -e 'AT^SETPORT="A1,A2;12,16,A1,A2"\r' | sudo tee  /dev/ttyUSB0


Submersible well pump runs but won't pump

Question: Pulled my submersible well pump to check for shorts in the wires. Everything looked good. Turned on power and the pump started running. Lowered pump back in the well and it won't pump water. I don't have water line hooked back up to house. was gonna check and make sure pump was pumping water before i hooked water line back to house. I can feel the vibration of the pump running but not getting any water. The pump is about 12 years old.
Comment: Dry well?   Perhaps the pump is not submerged.
Answer: It's either not in water, or it's broken and does not pump water any more.


Size of class object in C++

Question: On what basis is size of class object shown as 12?
class testvector
{
    public : vector<int> test;
};
int main()
{
    testvector otestvector;
    cout<<"size :"<<sizeof(otestvector)<<"\n";
    cout<<"size of int :"<<sizeof(int);
}

Output:
size :12
size of int :4

Comment: It's up to whoever writes the standard library implementation you are using
Comment: There is no "logic". `sizeof(vector)` and `sizeof(T)` are practically unrelated.
Comment: @SuchinRaj, How is the comment to **selbie**s answer not providing an answer to that?
Comment: The size of an empty `vector` is 12.
Comment: if i create vector the size is printed as 20. on what basis is this size assigned.
Comment: On what basis do you believe there is a basis to assign a size to a class? Why can't it be merely an unimportant consequence of some other things?
Comment: yes its based on the standard library implementation, but there must be some logic based on the size of the type of vector that the bytes are allocated. For int the size is printed as 12, why is the size printed as 20 for vector. ( size of bool is one)
Comment: Actually, why not?
Comment: I can't merely accept that size of vector  is 12, when size of int is 4 and size of vector is 20 , when size of bool is 1. there must be some logic based on which these sizes for vector is assigned. M looking for that logic.
Comment: Yes sizeof (vector) and sizeof (T) are unrelated, and the size of vector is independent of the type of T, but then i expect sizeof (vector) and sizeof (vector) to be same, but they are different. what is the reason?
Comment: May be going through the template specialization concept will give me a clear picture of it.
Answer: Think of it like this. Let's imagine the standard C++ library didn't have a vector class.  And you decided it would be a good idea to have one.
You just might, at a very minimum, come up with something like this.  (Disclaimer: the actual vector class for C++ is far more complicated)
template <class T>
class vector
{
    T* items;        // array of items
    size_t length;   // number of items inserted
    size_t capacity; // how many items we've allocated

   public:
     void push_back(const T& item) {
         if (length >= capacity) {
             grow(length * 2); // double capacity
         }
        items[length] = item;
        length++;
     }

    ...
};

Let's break down an instance of my simple vector class down on a 32-bit system:
 sizeof(items) == 4   // pointers are 4 bytes on 32-bit systems
 sizeof(length) == 4; // since size_t is typically a long, it's 32-bits as well
 sizeof(capacity) == 4; // same as above

So there's 12 bytes of member variables just to start out. Hence sizeof(vector<T>) == 12 for my simple example.  And it doesn't matter what type T actually is.  The sizeof() operator just accounts for the member variables, not any heap allocations associated with each.
The above is just a crude example.  The actual vector class has a more complex structure, support for custom allocators, and other optimizations for efficient iterations, insertion, and removal. Hence, likely more member variables inside the class.
So at the very least, my minimum example is already 12 bytes long. Probably will be 24 bytes on a 64-bit compiler since sizeof(pointer) and sizeof(size_t) typically double on 64-bit.
Comment: `vector` is sometimes implemented as a bitmask (one bit per item) to be really efficient with memory. So the container might be a few bytes to have members for keeping track of bit packing state.
Comment: @selbie: It is not *sometimes* implemented as such, but *always*, at least assuming a standard-conforming implementation.
Comment: ok so i understand that type of T will not matter. But then the actual vector class must be a generic class independent of the type of T. so from my understanding i believe the members of the vector class will be same independent of the type of T. So in that context i expect size of vector and size of vector to be same. But they are different. what can be the reason for this?
Comment: @SuchinRaj, [`vector`](http://en.cppreference.com/w/cpp/container/vector_bool) is a [template specialization](http://en.cppreference.com/w/cpp/language/template_specialization). It isn't an instance of the primary template, and its implementation can be entirely different.
Comment: May be going through the template specialization concept will give me a clear picture of it.

Size of class object in C++