How to return other values from from show dialog method?

Question: I have a winform in which I call this method:
frmIntegrationConfig frm = new frmIntegrationConfig();
DialogResult res = frm.ShowDialog();

The res is always returned as "Canceld".
how can I change it according to if the user click "Save" button o r just closed the form int ther close button ("X") ?
Answer: When you define your frmIntegrationConfig() window, you should set the "AcceptButton" and "CancelButton" properties on the form to the buttons you want to trigger the accept and cancel behaviours for your dialog.
You should also set the "DialogResult" properties on your buttons to control the specific DialogResult value that the button causes the dialog to return.
EG, amongst all the other stuff in your designer file for the dialog you need to end up with something like:
    this.accept = new System.Windows.Forms.Button();
    this.cancel = new System.Windows.Forms.Button();
    this.other = new System.Windows.Forms.Button();

    //
    // accept
    //
    this.accept.DialogResult = System.Windows.Forms.DialogResult.OK;

    //
    // cancel
    //
    this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;

    //
    // other
    //
    this.other.DialogResult = System.Windows.Forms.DialogResult.Ignore;

    //
    // Form2
    //
    this.AcceptButton = this.accept;
    this.CancelButton = this.cancel;

    this.Controls.Add(this.other);
    this.Controls.Add(this.cancel);
    this.Controls.Add(this.accept);

Answer: You need to set the frmIntegrationConfig's DialogResult.
You can do this by setting the DialogResult of the Save button to DialogResult.OK  or alternatively, which I prefer as it is evident what is happening, set the form's DialogResult to DialogResult.OK in the btnSave_Click() method:
private void btnSave_Click(object sender, EventArgs e)
{
     // closes form and returns value to ShowDialog
     this.DialogResult = DialogResult.OK;
}


How to Fix Mac Excel Weird Keyboard Entry Behavior

Question: If I want cell C1 to be the sum of A1 and B1, I do this on Windows Excel and it works as expected:
=←←+←ENTER
C1 formula shows =A1+B1
However, doing the same thing on Mac Excel (version 16.22 190211) fails. After
=←←
the C1 formula shows =A1
Upon typing +, the A1 reference gets overwritten and C1 formula becomes =+ instead of the expected =A1+
This happens consistently with different operator/operands sequence that I am unable to enter formulas properly. How does one perform "normal" keyboard entry with Mac Excel?
Answer: I have just done exactly what you suggest:
=←←+←ENTER
on a macbook pro, excel ver 16.38 and works perfectly
On an Imac, excel v 15.16 with a wired keyboard works perfectly
and same Imac with a wireless keyboard works perfectly.
Either a keyboard error or Operator error.
Comment: Thanks for the feedback. I upgraded my Excel to 16.26 and it is working perfectly now. Looks like the 16.22 version is buggy.


Difference between static and global variables

Question: What is the difference between the code below?
@implementation MyClass

static int myVar =0;
int _myVar =0;

I am getting same values for different objects of MyClass and both are visible to the all methods of MyClass...
Comment: I came here out of curiosity (not knowning Objective-C), but isn't that a basic OOP principle?
Answer: Static and global variable differ a lot in their behaviour to life and scope. First, let me distinguish between life and scope. Life of an object determines whether the object is still in the memory (of the process) whereas scope of the object is whether can I know the variable by its name at this position. It is possible that object is live, but not visible (not in scope) but not that object is not alive but in scope (except for dynamically allocated objects where you refer object through pointers).
Static variables are local in scope to their module in which they are defined, but life is throughout the program. Say for a static variable inside a function cannot be called from outside the function (because it's not in scope) but is alive and exists in memory. The next time this function is entered (within the same program) the same chunk of memory would be accessed now retaining the variables old value and no new memory is allocated this time for this variable like other variables in the function (automatic variables). So basically the variable persists throughout the program. Similarly if a static variable is defined in a global space (say at beginning of file) then this variable will be
accessible only in this file (file scope).
On the other hand global variables have to be defined globally, persists (life is) throughout the program, scope is also throughout the program. This means such variables can be accessed from any function, any file of the program.
So if you have a global variable and u r distributing ur files as a library and you want others to not access your global variable, you may make it static by just prefixing keyword static (of course if same variable is not required in other files of yours).
Comment: Thanks @Jaffer Wilson for your valuable comment
Answer: Neither of those variables are related to MyClass and both are global, which is why you are seeing the same value in all instances of MyClass.  If you wanted to make _myVar an instance variable then it needs to go between brackets:
@implementation MyClass {
    int _myVar;
}
...
@end

The difference between the variables in your code is that the static variable cannot be accessed outside the scope of the implementation file (which I assume is called MyClass.m), while the non-static one can be accessed from anywhere in the application, however you'd need to keep the compiler happy with an extern int _myVar; in any code that wants to access it; this is normally done by putting that extern declaration in a header file.
Answer: static limits the scope of your variable. In your case variable will be visible within MyClass file.
However, declaration of variable without static means that variable is automatic by default. It means that your static will live throughout all method calls and automatic will be allocated when you call a method and then at some point deallocated.


Can I manage my app and devices using AirWatch?

Question: We are developing iOS application and going to distribute it in Enterprise account. Want to integrate AirWatch and have several questions about this service:

Can we deliver some content to our App (Documents folder inside our
    App) using AirWatch and how? *
Can we schedule the update of new version of our app on devices?
Can we manage bluetooth and WiFi on
devices (turn on/off)?

for example load new photos to Apps Documents folder - to all, or some devices. If yes, how? - Does exist some UI interface for it?

Thank you!
Comment: You can use an MDM to deliver app configurations that are provided to the app through user defaults. You can't use MDM to deliver content. Your app should fetch the required content from a server. You can push new versions of your app via the MDM. You can distribute wifi network profiles (wifi settings/passwords).  You cannot turn wifi or Bluetooth on/off.
Answer: 1 No. You can deliver key-value data, not content. You could use push notifications to notify the app, and embed into your app an offline content manager to download new data
2 Yes. When a new version is ready you can push that to the devices. A notification will be sent and once they're online they'll and try to download the app. User will also be able to download apps manually, browsing a catalog of your enterprise-distributed apps
3 Yes and no. You can set policies to restart automatically the wifi and bluetooth after 1 hour, not completely turn them on/off
Comment: What is "offline content manager"? and how I can embed it in my app (if you mean that "offline content manager" is part of AirWatch)? Thank you @Luca!
Comment: It's not a part of AirWatch, I meant that we write our own custom code to download  a list of files hosted on our server, check if those files are already available on the mobile device file system and, if not , we provide software to download it. You should also consider the case where a new version of the same file is uploaded to the server, or even removed, etcetera.


How to install the richdocuments plugin on Owncloud?

Question: I'm trying to install this plugin: https://github.com/owncloud/richdocuments on Owncloud 9 on Ubuntu server 16.04 64bit.
Can someone tell me how to install this app?'
The main area of confusion for me is that it mentions LibreOffice Online WebSocket Daemon (loolwsd), but it isn't clear if this is included or not.
Comment: Hey that is like 50 USD...I'll take it!
Comment: On which part you struggle? compiling, packing or other?
Comment: @Videonauth time. I am too busy with other aspects of managing 3 servers to spend time figuring out this particular plugin which the developer SHOULD have posted on the standard repository like everyone else does...
Comment: Just give me the bounty :-P
Comment: @TheXed when you have delivered the fugitive!
Comment: I have, His name is @Videonauth. See below.
Comment: @TheXed okay I will give you the 10 000 dollars. Guyanese dollars }:>
Answer: For the following process I assume you have an already working and running owncloud-server installation on your server. I have tested this on a VM with 16.04 LTS server, so no fancy own configurations, you may have to adapt that to fit your situation.
1. Preparation:
sudo apt-get install build-essential git libtool m4 autoconf automake libpng12-dev libcap-dev libpoco-dev

2. Creation of the distribution:
cd ~
git clone https://github.com/owncloud/richdocuments.git
cd richdocuments/
make dist

3. Installation of what we just created:
sudo apt-get install php-apcu
cd /var/www/owncloud/apps/
sudo tar -xf ~/richdocuments/owncloud-collabora-online-0.15.1.tar.gz
sudo mv owncloud-collabora-online-0.15.1/ richdocuments/
cd ../../config
sudo nano config.php

Add this line:
'memcache.local' => '\OC\Memcache\APCu'

After that:
cd ..
sudo ./occ app:enable richdocuments

Note: loolwsd is not included in the bundle you can get it with git clone https://github.com/LibreOffice/online.git, please refer to the README in the loolwsd subdirectory on how to build and setup. After that build loleaflet as well.
You need to configure the WOPI Client URL, which is where the LibreOffice Online WebSocket Daemon (loolwsd) is listening.
sudo ./occ config:app:set --value='https://<hostname or IP address>:<port>' richdocuments wopi_url

Default port is 9980. If loolwsd was compiled without SSL, you have to write http instead of https. If you use SSL, and you get the following error:
cURL error 60: SSL certificate problem: self signed certificate in certificate chain

You have to add the CA cert manually to ownCloud trusted cert storage:
sudo cat ca-chain.cert.pem >> owncloud/resources/config/ca-bundle.crt

Comment: This not an answer since he is asking directly about that certain plugin.
Comment: He was asking if this plugin is included in richdocuments, and it is not. By the way a supercomplete build description on those twoo too would probably bust the 19,5k char limit on answers. So i rather wait untill i get a response from the OP.
Comment: That's where he points so he can get help to install the whole thing. But... he asked "Can someone tell me how to install this app?'" His process falls on both the scope of the LIbreOffice(WebSocket wtv) and OwnCloud(plugin). Actually the plugin is useless without the Libre Office Daemon.
Comment: Ah yes and the libreoffice daemon needs `libpoco` and this needs again something, what do you think where should it stop ? maybe building the whole toolchain again and make an own linux out of it ?
Comment: Okay will likely try this tomorrow. Thanks for your answer. I was going to try running through the instructions on the readme myself but I was busy with a lot of other things. Good on you for testing it btw.

I'll grant you the bounty if it works :)
Comment: If you need more detailed steps just drop me a line in AU general chat. I'll will work then on it.
Comment: Looks like I may be delayed in trying this - we'll see how it goes.
Comment: Just holler if your stuck or something.


How rare is it to get a Mending book from a villager for 7 emeralds on 3rd roll?

Question: I am on Bedrock edition and it was my first time doing this.
Answer: You had a 2.8% chance of rolling mending on your third villager.
Explanation: If I counted correctly, there are 106 possible enchanted books (including different levels) that a villager can trade. Thus mending has a 1 in 106 chance of appearing. Mending has a cost of between 10 and 38 emeralds, with the chance of cost evenly distributed.
7 emeralds is apparently impossible (without any trading discounts) according to the wiki, though the wiki is generally more accurate for java than bedrock.
Source: https://minecraft.wiki/w/Trading#cite_note-enchanted-book-8 (note 7)


How do I sort the content of the webpage under each other?

Question: I want to sort the content of this HTML page under each other as opposed to next to each other but I can't figure out why they stay side by side.
I tried putting
 between the
 elements but it did not do any good. I also tried playing around with the display and positioning parameters but that also did not give me any results.

body {
  background-color: #ffffff;
  color: #000000;
  font-family: Arial, sans-serif;
  min-height: 1000px;
}

#header {
  background-color: #000000;
  padding: 10px;
  text-align: center;
}

#header h1 {
  color: #FFFFFF;
  margin-top: 10px;
  padding-top: 10px;
}

#navbar {
  background-color: #000000;
  overflow: hidden;
  margin: auto;
  width: auto;
  text-align: center;
}

#navbar a {
  position: relative;
  display: inline-block;
  color: #FFFFFF;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

#navbar a:hover {
  background-color: #666666;
}

#content {
  margin-top: 20px;
  padding: 20px;
}

#about {
  margin-top: 20px;
  padding: 20px;
}

#footer {
  background-color: #000000;
  color: #ffffff;
  padding: 10px;
  text-align: center;
  position: fixed;
  bottom: 0;
  width: 100%;
}

label {
  display: block;
  margin-bottom: 10px;
}

input[type=text],
input[type=email],
textarea {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
  font-size: 16px;
}

textarea {
  height: 150px;
}

input[type=text],
input[type=password] {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
  font-size: 16px;
}

button[type=submit] {
  background-color: #000000;
  color: #FFFFFF;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

button[type=submit]:hover {
  background-color: #666666;
}

.container {
  background-color: #FFFFFF;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0px 0px 10px #333333;
  width: 400px;
  margin: 0 auto;
  display: inline-block;
}

.contact-info {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.contact-info div {
  flex-basis: calc(33.3% - 20px);
  margin: 0 10px;
}

.map-container {
  margin-top: 20px;
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}

.map-container iframe {
  position: absolute;
  display: inline-block;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.contact-info-container {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.contact-info-container div {
  flex-basis: calc(33.3% - 20px);
  margin: 0 10px;
}

.contact-info-container .map-container {
  flex-basis: 50%;
  margin-left: 10px;
}

Pavillion Architects

  Home
  About Us
  Login
  Contact Us

Contact Us

Contact Us

Address:
123 Main Street
New York, NY 10001
United States

Email:
firstname.lastname@example.com

Phone:
+1 (123) 456-7890

Send Us a Message

      <form>
        Name
        <input type="text" id="name" name="name" required>

        Email
        <input type="email" id="email" name="email" required>

        Message
        <textarea id="message" name="message" required></textarea>

        <button type="submit">Send</button>
      </form>

© 2023 Pavillion Architects. All rights reserved.

Answer: You can give the id content a display flex and flex-direction: column.

    body {
  background-color: #ffffff;
  color: #000000;
  font-family: Arial, sans-serif;
  min-height: 1000px;
}

#header {
  background-color: #000000;
  padding: 10px;
  text-align: center;
}

#header h1 {
  color: #FFFFFF;
  margin-top: 10px;
  padding-top: 10px;
}

#navbar {
  background-color: #000000;
  overflow: hidden;
  margin: auto;
  width: auto;
  text-align: center;
}

#navbar a {
  position: relative;
  display: inline-block;
  color: #FFFFFF;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

#navbar a:hover {
  background-color: #666666;
}

#content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-top: 20px;
  padding: 20px;
}

#about {
  margin-top: 20px;
  padding: 20px;
}

#footer {
  background-color: #000000;
  color: #ffffff;
  padding: 10px;
  text-align: center;
  position: fixed;
  bottom: 0;
  width: 100%;
}

label {
  display: block;
  margin-bottom: 10px;
}

input[type=text],
input[type=email],
textarea {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
  font-size: 16px;
}

textarea {
  height: 150px;
}

input[type=text],
input[type=password] {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
  font-size: 16px;
}

button[type=submit] {
  background-color: #000000;
  color: #FFFFFF;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

button[type=submit]:hover {
  background-color: #666666;
}

.container {
  background-color: #FFFFFF;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0px 0px 10px #333333;
  width: 400px;
  margin: 0 auto;
  display: inline-block;
}

.contact-info {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.contact-info div {
  flex-basis: calc(33.3% - 20px);
  margin: 0 10px;
}

.map-container {
  margin-top: 20px;
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}

.map-container iframe {
  position: absolute;
  display: inline-block;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.contact-info-container {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.contact-info-container div {
  flex-basis: calc(33.3% - 20px);
  margin: 0 10px;
}

.contact-info-container .map-container {
  flex-basis: 50%;
  margin-left: 10px;
}

Pavillion Architects

  Home
  About Us
  Login
  Contact Us

Contact Us

Contact Us

Address:
123 Main Street
New York, NY 10001
United States

Email:
firstname.lastname@example.com

Phone:
+1 (123) 456-7890

Send Us a Message

      <form>
        Name
        <input type="text" id="name" name="name" required>

        Email
        <input type="email" id="email" name="email" required>

        Message
        <textarea id="message" name="message" required></textarea>

        <button type="submit">Send</button>
      </form>

© 2023 Pavillion Architects. All rights reserved.

Answer: Remove the
 tags.  Where the first
 tag was, put a closing
 tag.  Also move the <link> tag to inside the  tags.
So the final html code looks like:
<!DOCTYPE html>

    <title>Pavillion Architects</title>
    <link rel="stylesheet" href="style.css" />

Pavillion Architects

      Home
      About Us
      Login
      Contact Us

Contact Us

Contact Us

            Address:
123 Main Street
New York, NY
            10001
United States

Email:
firstname.lastname@example.com

Phone:
+1 (123) 456-7890

        <iframe
          src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d13807.244846734851!2d31.379021!3d30.0995927!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x145815dcc3e4e599%3A0xc13091367d1af2a3!2zUGF2aWxsaW9uIEFyY2hpdGVjdHMgUy5BLkUg2KjYp9mB2YrZhNmK2YjZhiDYp9ix2YPZitiq2YPYqtiz!5e0!3m2!1sen!2seg!4v1679757425832!5m2!1sen!2seg"
          width="600"
          height="450"
          style="border: 0"
          allowfullscreen=""
          loading="lazy"
          referrerpolicy="no-referrer-when-downgrade"
        >

Send Us a Message

        <form>
          Name
          <input type="text" id="name" name="name" required />

          Email
          <input type="email" id="email" name="email" required />

          Message
          <textarea id="message" name="message" required></textarea>

          <button type="submit">Send</button>
        </form>

© 2023 Pavillion Architects. All rights reserved.


Enabling virtual consoles in Ubuntu 18.04

Question: I have used the virtual consoles (tty1-6) for decades in various Linuxes.  I recently installed Ubuntu 18.04 (Bionic Beaver) on an x86-64 box.  Everything is fine, except that the VCs don't work. As far as I can tell, it is by design that people are now only supposed to use the GUI (like in Windows). I would like to be able to use the VCs.
Note:
I've noticed (from ps output) that a lot of the GUI processes are running on tty1, so I assume that the GUI gets launched from there).
What I've tried:

Ctrl-Alt-F1 (or F2 or F3 or ...).  Nothing happens.  By "nothing happens", I mean, literally, nothing happens.
Note:
I am familiar with one system where you can switch to the virtual consoles (from the GUI), and it really does switch, but the screen stays on the GUI.  You can now type and you are typing on the virtual console, but the screen makes it look like you are still on the GUI.  I mention all this to say that, no, this is not the case here.  You are still typing into the GUI.
(as root) chvt 1.  Nothing happens.  Prompt comes right back and nothing has changed.
(as root) chvt 2.  Process hangs until you hit Ctrl/C.  Weird...!
(as root) strace chvt 2.  Lots of strace output, ending with something like:
ioctl(3,VT_WAITACTIVE ...)

and then it hangs (until you hit CTRL-C).
Next, following some advice I found on this board, I tried editing the file:
/etc/systemd/logind.conf

and uncommenting the first two active lines, which are:
NAutoVTs=6
ReserveVT=6

I tried first just uncommenting the first one, then rebooted, nothing changed.
So I then uncommented the second one as well, rebooted, again, no change.
So, what to do?
What is next?
Comment: Ctrl+Alt+F1 does nothing on my Ubuntu 18.04.1 because the gnome session is running there. Other Ctrl+Alt+Fx shortcut work as expected (I see linux console). Previously, (Ubuntu 16.04) GUI part (Unity) used Ctrl + Alt + F7.
Comment: Are you sure those keys are mapped as Fx keys? Nowadays on laptops those usually are used to VolUp/Down, airplane mode, etc. You'll need to press the Fn (_function_ but in other sense) key: Ctrp+Fn+Alt+F2.
Comment: Thank you, zx485, for editing my post.  It looks much nicer now.  I didn't know how to do any of those things.
Comment: One more piece of information regarding this.  I tried (as root): _open sleep 1000_          and then I can see (via _ps_) that _sleep_                                           is indeed running on tty2.  But, I still can't get to it...
Answer: Actually I had the same problem.
I changed the /etc/systemd/logind.conf file adding the line
NAutoVTs=6

And the VCs were not accessible till I had an idea!
On my laptop, a Lenovo T490, the default F keys are instead configured as Laptop keys. Therefore they are not usable a F keys directly.
To get the Fn keyboard working I have to press:
Fn + CTRL + ALT + F1-12

now with Fn + Ctrl + Alt + F3 key I can get to the tty3.
tty1 is the GDM login page, while tty2 is the current X session.
Comment: The author ran `chvt 2`, which precludes anything to do with his his F2 key status.
Answer: Note: This is now working as expected.  I assume that whatever system updates I've installed in the last year or so (as a result of the OS popping up a message telling me that new software is available for my computer...) has fixed the underlying problem.
Now, if I do Ctrl/Alt/F2, it takes me to a login prompt on tty2 (implicitly launching a getty there).  Ctrl/Alt/F1 takes me back to the GUI (Gnome session).  "chvt" also works as expected.
 So, I guess all is well.  BTW, note that in earlier versions of Debian/etc, the GUI was always running on tty7; now it is running on tty1.  This can throw you for a loop (and cause panic) if you expect Ctrl/Alt/F7 to take you back to the GUI.
But, modulo that, it is OK now.
Answer: Recently I had exactly the same problem with a newly acquired "old" notebook with xenial installed. The problem turned out to be in /etc/default/grub, the line GRUB_TERMINAL=console was uncommented, and the text mode was obviously not working (maybe the combination of KMS and my videocard?) In any case, grub did complain with booting in blind mode error message, but continued as usual, with the framebuffer seemingly enabled (kernel messages etc. were visible). As far as I can tell, virtual consoles and gettys were working well, but only the (unchanging) kernel boot messages were visible, in what looked like a native framebuffer mode (presumably the consoles were writing into a text-mode VGA memory).
After commenting out the GRUB_TERMINAL=console line, the virtual consoles now work as expected, in a framebuffer (vcs1 is unavailable, though).


Is there a way to install 14.04 using the LiveUSB drivers?

Question: I run into all kinds of problems with hardware not working after install (specifically the touchpad and wifi), but everything works perfectly on the LiveUSB. Is there a setting to install to disk with those basic drivers? I'd rather just have these general drivers working and update each device individually later than try to troubleshoot every problem Ubuntu ends up with after install, especially when those problems prevent me from having a mouse pointer and an Internet connection.
My hardware:

HP Probook 4720s (originally a Windows 7 64-bit machine)
Core i5 2.5 Ghz Processor
4GB of RAM
Radeon 530v GPU
Synaptics Touchpad
Atheros Wireless Adapter

Further details: I'm attempting to install the latest 64-bit version of Ubuntu 14.04. I have done this both with and without updates via wi-fi during installation, with the same results. I'm using a Live Image on a 4 GB USB drive made using UNetbootin.
Comment: Why? Why is that so strange? First of all, that's exactly what I end up having to do when I install normally (with wifi). A bunch of devices that were working fine on the Live CD are now nonfunctional and I have to troubleshoot each one individually. I would rather have some general but functional drivers than ones that don't work at all if I'm going to be scouring the web for my hadware's actual drivers. Also, if there is no general set of drivers that tend to work for more hardware, then what exactly is the LiveCD using that the full installation is not? That is all I meant by "catch-all".
Comment: The thing is, there is no such thing as catch-all drivers, and I hope you are not serious about updating each device individually, that's easier said then done. What wireless card is there and what touchpad?
Comment: I have a Synaptics touchpad and an Atheros wireless adapter, and I have gone over multiple solutions here that solved other people's similar problems without luck. I just don't get why the Live version can be so functional while the full install ends up making the OS unusable.
Answer: As far as wireless card, you could use Ndiswrapper , which is basically a way to use windows driver for Ubuntu.  Refer for more info to this page:
https://help.ubuntu.com/community/WifiDocs/Driver/Ndiswrapper
As touchpad , I can suggest only a workaround: when I installed Ubuntu on Acer C720 chromebook it turned out that touch pad at the moment has no linux drivers at all, so I bought a wireless mouse - those suckers typically are plug and play - no need to install no driver, and it works all the same on Ubuntu,  Fedora,  and Mint that I have on my two laptops.  And windows too.
If your programming and script-fu is powerful enough you may write your own driver,  but really there should be something decent available in Linux world already.  Or maybe you could try looking for something close to your model and install a driver for that instead


Optimisation/ operational research problem classifciation

Question: Hello I am new to operational research and would like help classify the following transport problem.
I have a model which simulates a taxi like service, it a has a range of inputs that can be changed (no. vehicles, starting times, vehicle capacity etc) and then the model spits out a set of outputs (time spent idol, time spent travelling with passengers, time passengers spend waiting) which I apply some kind of associated cost to both the inputs and the outputs.
What kind of techniques would you apply to this problem so that I can minimise the total cost?
I imagine some algorithm would iteratively run the model and adjust the inputs and measure the outputs to form the data. However this is just my uneducated guess.
Answer: Exactly, you probably want to use local search methods: begin with an arbitrary initial input (preferably good); then modify the current input with some random changes (change a vehicle, add one, remove one...), keep the best result and loop. You could look into simulated annealing.
If you need the best solution and your search space is large (and it probably is), a blackbox model should be inefficient. If you can have access to the model, you can formulate it as an optimization problem (minimize cost subject to constraints), for example with integer linear programming, or use more clever heuristics.
Comment: On the other hand, for a large model integer linear programming can be very slow, while local search methods may be able to get very good (if not optimal) solutions in a reasonable amount of time.
Comment: You're right: I saw a scheduling problem and got carried away. Without mentioning integer programming, however, improving the basic local search process will be beneficial. The first improvement you may add is to not evaluate the full model each time but calculate the effect of a change incrementally.


Installing Ubuntu 11.10 from LiveUSB

Question: I'm trying to install 11.10 on my computer to dual boot it with windows 7 and when I'm in the try Linux area and try to install Linux off of my liveusb I get to the point where its supposed to ask if i'd like to install it alongside windows 7, but it never shows that option it only shows the options to install over the entire hard drive and the advanced options one ie it never recognizes that I have anything else on my hard drive could someone help me?
Comment: Welcome to Ask Ubuntu! Have you tried the advanced partition editor?
Comment: Check if you already have 4 primary partitions on your hard drive; If you do, either remove one or move them into extended partitions.
Comment: It wont even let me get to the advanced partition editor and according to the windows 7 disk manager I only have 3 partitions (windows backup, windows 7, and a partition that i made for ubuntu)
Comment: the advanced partition editor should be the last option labeled as "something else" where you should be able to edit the partition table. You'll need to kill that last partition you made for Ubuntu, and create a swap and allocate the rest to Ubuntu, meaning you should have two NTFS partitions, a SWAP and an ext4 for Ubuntu (make "/" the mounting point for the ext4 partition).
Answer: Forget all these. Download Wubi and use the iso you already have to install Ubuntu. I dont think you need more than 30GB of installation space.
Here's how to install using Wubi.
<code> Log into windows.
 Create a new folder on desktop
 Download the Wubi installer and move the installer to "new folder"
 Copy and paste the Ubuntu ISO into the new folder.

 Double click on Wubi.exe to start the installation
 Give a password
</code>
Wait for the installation to complete.
Thats it.

Installing Ubuntu 11.10 from LiveUSB


How To Get The Line Count Of A RichTextBox

Question: Is there a simple way to simulate TextBox.LineCount for a RichTextBox? I've been looking at other posts and solutions but they're extremely outdated.
Other Posts:
Richtextbox lines count
How many Lines in RichTextBox
Answer: Get the text from the control and split it to an array with Environment.NewLine separator then you can check the length of the array to get the line count.
private void button_Click(object sender, RoutedEventArgs e)
{
    TextRange MyText = new TextRange(
    richTextBox1.Document.ContentStart,
    richTextBox1.Document.ContentEnd
     );

    string[] splittedLines = MyText.Text.Split(new[] { Environment.NewLine }
                                  , StringSplitOptions.None); // or StringSplitOptions.RemoveEmptyEntries

    MessageBox.Show(splittedLines.Length.ToString());
}

Comment: It looks good except I need the empty lines too. I want to capture all the lines with and without content. How would I do that?
Comment: Without the `StringSplitOptions.RemoveEmptyEntries`, it takes the `RichTextBox` Text - for example like "\r\n" - and turns it into two items, which the length of that is 2 and incorrect, it should be 1.
Comment: I just changed the `StringSplitOptions` you suggested to `StringSplitOptions.None` and handled the result on my own, thank you though!
Answer: If i'm understanding correctly, you want line count including cases in which multiple lines are rendered because of word wrapping. If that's the case, you'll need to count the frequency of a newline in the text of the richtextbox plus factor in the width of the richtextbox to detect wordwrap.
Comment: I have word wrapping off on my `RichTextBox`, and I've thought about counting the newline character in the string representation of the content within the `RichTextBox`, but RichTextBox's have this weird behavior where it automatically generates a "\r\n" when I specifically wanted to insert an empty string. I'm still new to using RichTextBox's but that's what I observed.
Comment: My post above was focused on what MSDN says about the behavior of TextBox.LineCount since you're looking to replicate that. The weird behavior in your comment above, is that indicating you want zero when the RichTextBox is empty but you still want to count empty lines when they're part of text that includes more than just that line that's empty?
Comment: Yes, let's say my `RichTextBox` is empty and it has focus, I want that first line to be considered as a line represented by an empty string, so in that case the LineCount will be 1.


Do I need to install libcurl source package to use it for development?

Question: I am working on a project that I used to use in a Windows environment. I recently migrated to KUbuntu and installed everything I needed (Qt, QtCreator and libcurl).
However, after installing libcurl, I see that libcurl doesn't come with header files that I need! I checked that this was not the case using
$ dpkg-query -L libcurl3
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libcurl3
/usr/share/doc/libcurl3/changelog.Debian.gz
/usr/share/doc/libcurl3/copyright
/usr/share/doc/libcurl3/NEWS.Debian.gz
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/libcurl3
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0
/usr/lib/x86_64-linux-gnu/libcurl.so.4
/usr/lib/x86_64-linux-gnu/libcurl.so.3

So, will I need to install libcurl sources in order to get back to work?
Answer: Header files are usually provided by -dev packages, in this case that would be libcurl3-dev, which is a virtual package now provided by libcurl4-ssl-dev, which looks like it has header files. So install libcurl3-dev.
Comment: So that's what I missed... Thank you for your answer!


Macready uses ammo supply differently when equipped in power armor

Question: I just told Macready to equip some power armor, and now he appears to use his ammo supply differently than when out of the armor.  Specifically, when out of the armor, I can equip him with a weapon and give him one unit of ammo for that weapon, and he'll have an infinite supply of ammo for that weapon.  When in the power armor, however, he'll take one shot with the weapon and immediately switch back to his default sniper rifle.  This occurs no matter what type of weapon I equip for him.  Is this a glitch, or is there something I'm missing?
EDIT
I've confirmed that when he's in the power armor and I give Macready more ammo with the weapon, he keeps the weapon equipped until he uses all of the ammo.  Again, glitch or by design?  I should add that I'm level 89, if that matters.
EDIT 2
Ok, so I don't know what I was thinking. I verified that I was wrong about Macready having infinite ammo when out of the power armor.  When traveling as my companion, his ammo is used up for any weapon I equip for him.  In any case, the answer provided gave a link which describes how companions differ from settlers, which was appreciated.
Comment: Is he functioning as a companion or as a settler?
Comment: He's a companion.
Answer: What you describe is not normal.
Source
A companion should be consuming ammo when these conditions are met:

The companion has a weapon equipped in their inventory (a weapon that can be seen equipped in their inventory when trading with them).
The companion has at least 1 (one) ammo that can be seen when trading with them used by the type of weapon equipped.
The companion is the current active follower companion.

The ammo consumption is expected when you give your companion a weapon.  Are you using any mods that is changing this?
Comment: @Alan In OP's post:  "when out of the armor, I can equip him with a weapon and give him one unit of ammo for that weapon, and he'll have an infinite supply of ammo for that weapon".  **This** isn't normal for a companion.  That's why I asked him if Macready is a companion or a settler.
Comment: Well today I learned that I don't need to give settlers more than one ammo, that simplifies things!
Comment: Actually, the source you provided indicates that this behavior IS normal.  That a companion will consume ammo until used up and then switch to their default weapon, whereas settlers will have an infinite supply when given only one unit of ammo.  How I did not notice that difference until now, boggles my mind...I don't recall ever having to supply my companions with ammo before when equipping them with a weapon.  Anyway, if you change the first line of this answer to "is normal" I will accept this as the answer.  Thanks for the link!
Comment: Right.  I've been focused on Macready being in the power armor, thinking THAT was the exception, when my first premise about him having infinite ammo when out of the armor was the exception.  I'm going to have to verify that part, maybe I'm wrong there.  In any case, you set me on the right track to understand what's supposed to happen, so thanks again.
Comment: @Robotnik The best part is the infinite grenades.  Handing everyone a single Frag/Plasma/Cryo/Nuka grenade makes them really strong already.  Add to that a rapid fire plasma/assault rifle/minigun makes for an amazing defense.  Provisioners are like this too.  I deck them out with Armored clothing Mk5, all the best armor, and they can hold their own pretty well across the supply lines.


How to obtain a list of available COM interfaces in Windows

Question: Is there any way of obtaining a list of registered COM interfaces on a windows machine, with GUIDs?
Before anybody thinks this isn't related to programming, I need this data in order to reference a COM interface in F# (or C#) for interfaces that tlbimp isn't exposing.
Answer: There have been a number of applications in this space over the years.

COMView
TypeLibrary Explorer from Embarcadero
Type Library Viewers and Conversion Tools (Microsoft)
PxPlus Type Library Browser

I used COMView recently. Still works.


(Java 1.16.2)My custom model data didn't work with files I added

Question: I want to make custom model textures for the wooden sword. Below is the wooden_sword.json:
<code>{
  "parent": "item/handheld",
  "textures": {
    "layer0": "item/wooden_sword"
  },

  "overrides":[
  {"predicate": {"custom_model_data":1}, "model":"item/iron_ingot"},
  {"predicate": {"custom_model_data":2}, "model":"item/gold"}
  ]
}
</code>
It showed the texture of "item/iron_ingot"(minecraft's original file) correctly, but it only showed error texture when using the "item/gold" that I added my own. I think it cannot detect the file.
Answer: Make sure the model you are calling is valid (the 'gold' model) for help you can look at default models in the default minecraft resource pack.  I also suggest turning on the debug window at launch of minecraft, it really helps.  It can be turned on in the launcher in settings under general.  Below is a video about custom model data you should probably watch.

You might be also miscalling the model.
I hope this helps.


pass the value from jtext to another frame

Question: i have to write a Cashier's program. Assuming that, if i have a JFrame that includes 2 JTextFields, to add the item kind and price. I have one JButton, to create if i want that item which is added by the user to be like JButton in new JFrame called Sell when i pressed that JButton will pass the value of price and item kind to JTable. Is there a way to achieve this!!!!
The code for getting the item from database and but the result in JTable but i dont know the code to create JButton
try {
    String host = "jdbc:derby://localhost:1527/PROCAT";
    String uName = "zain";
    String uPass = "zain";
    Connection con = DriverManager.getConnection( host, uName, uPass);
    String sql = "Select * from ITEMB where ITEM =2";
    stmt = con.createStatement();

    rs = stmt.executeQuery(sql);

    while (rs.next()) {
        String myNamatxt = rs.getString("PRISE");
        String myHargatxt = rs.getString("ITEMNAME");
        String satuan = rs.getString("ITEM");
        String[] data = {myNamatxt, myHargatxt, satuan,};
        tabMode.addRow(data);
        double price = Double.parseDouble(rs.getString("prise"));
        totalpay = price + totalpay;
        ++rowCount;
    }
} catch (Exception e) {
    //ignore
}
jTextField3.setText(String.valueOf(totalpay));

Comment: code line double price = Double.parseDouble(rs.getString("prise"));
             totalpay = price + totalpay;
            ++rowCount; should be job for SQL server, this value should be returned from Statement
Comment: You should use gramatically correct English instead of SMS language for your questions in this forum.
Comment: See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556)
Comment: `catch (Exception e) { //ignore }`  Change code of the form `catch (Exception e) { ..` to `catch (Exception e) { e.printStackTrace(); // very informative! ..`
Comment: The OP seems to have abandoned this, so voting to close.
Answer: The requirements of the question is still unclear, though if you be able to put some more light on it, then many of us be able to help you on the topic. Take the help of Google Translate, just in case English is not the language you comfortable with.
If I understood the question in the right sense, you want to enter two values in two fields, ITEM and PRICE. Now at the click of a JButton, you wanted to pass those items to the JTable. If that be the case, a small program for your help is as below:
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

public class JTableExample {

    private JFrame frame;
    private JTextField itemTField;
    private JFormattedTextField priceFTField;
    private NumberFormat priceFormat;
    private JButton submitButton;

    private Vector<String> columnNames = new Vector<String>();
    private JDialog sellingDialog;
    private JTable table;
    private DefaultTableModel model;

    private ActionListener buttonAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (!sellingDialog.isShowing()) {
                model.setRowCount(0);
                sellingDialog.setVisible(true);
            }
            Vector<Object> rowData = new Vector<Object>(2);
            String item = itemTField.getText().trim();
            double price = Double.parseDouble(
                            priceFTField.getText().trim());
            rowData.add(item);
            rowData.add(new Double(price));
            model.addRow(rowData);
        }
    };

    public JTableExample() {
        columnNames.add("Item");
        columnNames.add("Price");
    }

    private void displayGUI() {
        frame = new JFrame("Swing Worker Example");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        JPanel contentPane = new JPanel(new GridLayout(2, 1, 5, 5));

        JPanel headerPanel = new JPanel();
        itemTField = new JTextField(10);
        priceFormat = NumberFormat.getInstance();
        priceFormat.setMaximumFractionDigits(2);
        priceFTField = new JFormattedTextField(priceFormat);
        priceFTField.setColumns(10);
        headerPanel.add(itemTField);
        headerPanel.add(priceFTField);

        JPanel footerPanel = new JPanel();
        submitButton = new JButton("SUBMIT");
        submitButton.addActionListener(buttonAction);
        footerPanel.add(submitButton);

        contentPane.add(headerPanel);
        contentPane.add(footerPanel);

        frame.setContentPane(contentPane);
        frame.pack();
        frame.setLocationByPlatform(true);
        frame.setVisible(true);

        createDialog();
    }

    private void createDialog() {
        sellingDialog = new JDialog(frame, "Sell Items: ", false);
        JPanel contentPane = new JPanel(new BorderLayout(5, 5));
        model = new DefaultTableModel();
        model.setColumnIdentifiers(columnNames);
        table = new JTable(model);
        table.setPreferredScrollableViewportSize(
                                    new Dimension(200, 200));
        table.setFillsViewportHeight(true);
        JScrollPane itemScroller = new JScrollPane();
        itemScroller.setViewportView(table);
        contentPane.add(itemScroller);

        sellingDialog.setContentPane(contentPane);
        sellingDialog.pack();
    }

    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                new JTableExample().displayGUI();
            }
        };
        EventQueue.invokeLater(runnable);
    }
}

Though on a side note, restrain yourself from using multiple JFrame in a single application, do consider going through the link as already posted in the comments.


Hidden Custom option Magento

Question: I'm looking for the file name containing the implementation of the "Proceed to Checkout" button.
I have found that the sales_flat_quote_item table is being populated when the button is clicked.  I have added a field called fld_data and now I need to insert the field data, currently held in a session, when the "Proceed to Checkout" button is clicked, in the same insert statement.

Sorry for the misunderstanding actually i want to add a custom option textfield which is hidden from the user and process it till the order submitted and that value is accessable at the admin side along with the order.
Comment: wat? Please explain in english :) what you are trying to do and what you already have tried to get the result.
Answer: Hi Khaleel if I read your name correctly... you should get the template at
/app/design/frontend/base/default/template/checkout/onepage

and the layout for the template at:
/app/design/frontend/base/default/layout/checkout.xml

and the block at:
/app/code/core/Mage/Checkout/Block/Onepage/Link.php

Make sure you overwrite none of these core files but have a local version.
Answer: Overwriting or copying core files to the local folder isn't necessary here (if the additional data is related to the product)
Just create a custom module and in the mysql setup file, add a custom column to the required tables to hold your attribute value:
$installer->getConnection()->addColumn($installer->getTable('sales/quote_item'), 'your_attribute', "decimal(12,4) DEFAULT NULL AFTER `price`");
$installer->getConnection()->addColumn($installer->getTable('sales/order_item'), 'your_attribute', "decimal(12,4) DEFAULT NULL AFTER `price`");
$installer->getConnection()->addColumn($installer->getTable('sales/invoice_item'), 'your_attribute', "decimal(12,4) DEFAULT NULL AFTER `price`");
$installer->getConnection()->addColumn($installer->getTable('sales/shipment_item'), 'your_attribute', "decimal(12,4) DEFAULT NULL AFTER `price`");
$installer->getConnection()->addColumn($installer->getTable('sales/creditmemo_item'), 'your_attribute', "decimal(12,4) DEFAULT NULL AFTER `price`");

Then, in your custom modules config.xml file, inside the global tag, place the following
<fieldsets>
    <sales_convert_quote_item>
        <your_attribute><to_order_item>*</to_order_item></your_attribute>
    </sales_convert_quote_item>
    <sales_convert_order_item>
        <your_attribute>
            <to_invoice_item>*</to_invoice_item>
            <to_shipment_item>*</to_shipment_item>
            <to_cm_item>*</to_cm_item>
        </your_attribute>
    </sales_convert_order_item>
</fieldsets>

<sales>
    <quote>
        <item>
            <product_attributes>
                <your_attribute/>
            </product_attributes>
        </item>
    </quote>
</sales>

this should do the trick without modifying core code.
Comment: Could you expand on this a bit? Perhaps provide a structured view of how the extension would look? I can't seem to get it to "activate" and add the tables. Thank you!

Hidden Custom option Magento


Soldering AC wires to this PCB

Question: I'm working on a DIY Mirror Touch frame and am on the final stages connecting everything.
I have the issue where I was unable to find a deep enough aluminum frame and therefor have the issue where the power cable would protrude from the backside (see first image below and red line).
I've managed to disassemble the DVI connector and reduce the protrusion there.
For the power connector, I would appreciate support with soldering the Power adapter wires to the PCB - as I have no idea which solder point on the PCB should be associated with which wire (DC Live, Ground or DC neutral). I would de-solder and remove the power connector on the PCB and solder the wires directly (and then add a good amount of hot-glue).
Comment: You plan to hook mains power to those connector locations?   Can you promise to post a video of the initial powerup, no matter what happens??
Comment: Sorry, but electronics repair doesn't fall under "home improvement" as defined by this site. You might try https://electronics.stackexchange.com.
Comment: Thanks. My question might need improvement as it seem so many are focusing on the power adapter... that's not my concern as the power adapter is what came with the LCD (19V adapter). I looked for other Exchange sites and thought that this site (diy.stackexchange.com) would fit at I am doing a touch screen mirror by myself. I checked electronics but seemed far more technical than just "what wire goes where". Still appreciate the feedback.
Answer: I doubt that cable is carrying household voltage. It's probably DC voltage in the 12-24 volt range from a power supply brick.
Use your multimeter to figure out which part of the connector on the cable is positive and negative. Then you can desolder the socket from the board, cut the connector off the cord, use the multimeter to identify positive/negative in the cable and solder it to the circuit board.
If I had to guess, the two pins sharing a trace are probably positive, and the third pin looks to be attached to the ground plane and therefore probably negative.
Comment: They go in to the holes left behind by the connector when you desolder it.
Comment: Thank you @longneck. It is DC voltage and power adapter for LCD screen (19V).

I'm not concerned about the power cord end. I'm able to measure what which wire is.

it's the PCB side I'm not sure where the wires go once I remove the power connector from the PCB.
Comment: I guess what I could do is connect the power adapter as it is (stock) and then measure with a multi meter under the PCB (carefully). Didn´t think of that until I read your reply. Thank you again.
Answer: Mains electricity is not a toy!!  Low voltage DC is a toy, which is how you got misled.
Mains will steal your girlfriend, wreck your car, cancel your fire insurance, burn down your house and kill you. It is a completely different beast. (It's a very slightly less psychotic version of mid-voltage DC, which made a serious college try to kill 3 astronauts the last time it was trifled with. AC, at least, has a zero crossing that will often snuff arcs).
Anytime you get an urge to do something with mains electrical, put down the soldering iron (you'll never use it), come here and talk about what you want to do.  We'll run you through it the right way, that meets Code, will save your fire insurance, and will be safe.  Humanity's best-practices at handling mains power safety (Code) are so refined that it looks easy, and that makes mains AC seem harmless.  As such, Code can seem stupid.  It's not.
I'm sorry to give you the finger-wag, but you specifically asked how to connect AC  live, AC neutral and ground.
But you're in luck
That's a Barrel connector.  Mains power would never be on that because it wouldn't have the dielectric strength.  The weird lump in the power cord is not merely to annoy you, it's to knock AC mains power down to low voltage DC.
By the way, the reason so many manufacturers do that, the thing with the wall-wart, is it allows them to sidestep the bulk of the UL listing process. They only need to clear the low hurdle for low-voltage DC machines, then they toss in a commodity off-the-shelf wall-wart that somebody else already got UL listed.  That's why wall-warts almost never have any labeling to say which equipment they go with.
The Electrical Code has sweeping exemptions for low voltage devices under 30V (talking to you, NASA) that are also under 55 watts. Your device probably falls under that exemption.
You only need to figure out how to convert mains to the correct low voltage safely (e.g. By simply using the power block that came with the machine), how to site the power supply (plugged into a nearby receptacle is pretty safe), and how to connect the wires.
Comment: Shows how much I know about electricity and the correct terms :) I am NOT going to connect wall outlet/power AC to the PCB. I'm only planning to cut of the LCD screens included power adapter (19V) plug/jack off and solder those wires to the correct locations on the PCB. I was just unsure which wire from the power adapter should be soldered to which pin on the PCB.
Answer: First off as pointed out in another answer none of those pins are for AC mains, they are all for the outputs of a power brick.
What I would do is first check if the cable is visible asymmetric, if not use something (tippex may work nicely) to mark one side of it so you can tell which wire is which after cuttin cut the connector off the power brick, then use the multimeter on continuity to work out which wire in the cable connects to which solder pad on the board.

Soldering AC wires to this PCB


What metrics are used for deciding if a 3D object is visible?

Question: I'm wondering what metrics I could use to decide upon the visibility of a 3D object in VR or other 3D applications and what advantages each has.
Answer: Visibility for culling (or passing to the render pipeline) is very sensitive to false negatives. False positives are not a big deal because when rendering the Z buffer will take care of that.
This means that one very simple metric is simply assuming that it's always visible. If any other metric gives too much overhead than simply processing the object requires then this is a good fallback. For example in a redering api with command buffers rebuilding the command buffer would be too expensive compared to the processing required to render a single object to warrant it.
The next option is to see if the object is in front or behind the camera, This can be done with a dot product with the view vector and the forward most point of the bounding volume of the object. If it's negative then the object is behind the camera and you can skip it.
The next is using the view pyramid. From the camera you extrude the frustum and do a collision check between it and the object. If it collides then the object is visible. Instead of 1 plane you now check against 4 and the object must pass All 4 to be considered visible.
Next you can take into account when the object is fully occluded by another object. This can be done by various methods. With static geometry you can partition the world and say for each section which other sections you can see from it. You can also ask the GPU to do occlusion queries which basically means "did any fragments of these render commands pass the depth test". But getting the information back from the GPU typically has a decently long latency, by which time the camera may have moved.


Good method to compute product of the most common integers in a list?

Question: Let's say I have an array of n integers and I am supposed to return
the product of most common integers.
Example: (2,3,4,2,2,1,4)- returns 8.
I can use normal arrays to store the values.
If I want to have runtime optimization, should I use hashtable in C# or dictionary?
Will that help me have space optimization as well?
Or is there any other approach to have space optimization?
Comment: Protip: make it work first, _then_ optimize it.
Answer: This is so contrived that it looks like homework, so I'm just going to roughly describe how I'll do it. Then you can try something, and come back if you got any questions about it.
I would associate in a table of some sorts (a Dictionary<int, int> is the simplest choice) the numbers with how many times they were encountered. Then it's just a matter of taking the one with the highest count (let's call that count n from now on) and multiplying that number with itself n times.
Answer: You can have speed optimisation or space optimisation, but not both.
If you want space optimisation you can sort the array, then loop through it to look for the longest sequence of the same value. This will need very little storage except the array, but it will change the original array. Sorting would generally be O(n log n), and then looping would be O(n).
If you want speed optimisation, you can use a dictionary to count the occurances, then get the largest count. This would need by average n * 10 bytes for the dictionary, but it leaves the original array unchanged. Counting would be close to O(n), and finding the largest count would be O(n).
Comment: Thanks for all your answers. Could you please explain O(n logn) for the sorting a bit?
Comment: The `Array.Sort` method is O(n log n) by average: http://msdn.microsoft.com/en-us/library/kwx6zbd4.aspx


Error bars are rendered incorrectly when ymax exceeds Y axis scale

Question: I wanted to "crop" my Y axis by using limits in scale_y_continuous:
df1 <- data.frame(xx=c('a','b','c'),
                  yy=c(7, 10, 8),
                  se=c(2, 4, 2))
p <- ggplot(data=df1, mapping = aes(x=xx, y=yy)) +
  geom_bar(data = df1, position=position_dodge(), stat="identity") +
  geom_errorbar(aes(ymin=yy-se, ymax=yy+se), width=0.1, position=position_dodge())

p # left plot

p + scale_y_continuous(limits=c(0,11)) # middle plot
# Warning message:
# Removed 4 rows containing missing values (geom_path).

In this case one error bar exceeds upper limit of the Y axes, and I would like it to be just cropped (like plot on the right) but in fact the vertical line of error bar is just not rendered at all (cf. plot in the middle). Is there any way to overcome this, besides drawing error bars manually?
Answer: I believe that
library("scales")
p + scale_y_continuous(limits=c(0,11),oob=squish)

will do it (not tested); "oob" stands for "out of bounds"
The more standard answer is to use
coord_cartesian(ylim=c(0,11))

but that will also change the tick spacing etc.
Comment: great, thanks! (`oob=squish` did not worked for me but `oob=rescale_none` did the job)


How to write a query in spring for inserting records into 2 tables in Mysql database

Question: I want to write a query to insert data into two tables.
I am inserting data into two tables know as User and company.
User has foreign key company _id. Table structure is given blow
User table

int user_id;(AI)
int company_id; (foreign key)
String user_name;
String user_email;

Company table

int company_id;(AI)
String company_name;

-
void insert(String user){
    String query="insert into user(user_name,user_email,company_id,company_name) values
    (variable,variable, variable, variable)";
    //code to map using put method
}

I am getting an error
company_id cannot be null.

Comment: Please edit your question, so it'll be clear. It's not readable now.
Comment: thank you @Anna for editing question.Company_id is fk so its not null.so please let me know query changes
Answer: This probably because your company_id is set to not null in the user table. You have to remove not null from the company_id column in your table creation statement of the user table, if you want foreign key to be nullable. Otherwise you have to provide a value for the foreign key.
Comment: Company_id is fk so its not null.so please let me know query changes
Answer: As the foreign key company_id cannot be null, the company must exist in the DB and it's id must be known before you can insert the user.
UPDATE
To insert a new user you need:

a user name
an e-mail address
a company name

We first need to search the company_id for the given company name. If it is not found in the database, a new company is inserted.
public void insertUser(String userName, String userEmail, String companyName)
        throws SQLException {
    int companyId = getOrInsertCompany(companyName);
    try (PreparedStatement stmt = cnt.prepareStatement(
            "insert into User(company_id,user_name,user_email)"
            + " values(?,?,?)")) {
        stmt.setInt(1, companyId);
        stmt.setString(1, userName);
        stmt.setString(1, userEmail);
        stmt.executeUpdate();
    }
}

private int getOrInsertCompany(String companyName) throws SQLException {
    try (PreparedStatement stmt = cnt.prepareStatement(
            "select company_id from Company where company_name=?")) {
        stmt.setString(1, companyName);
        try (ResultSet rs = stmt.executeQuery()) {
            if (rs.next()) {
                return rs.getInt(1);
            }
        }
    }
    // the company was not found; insert it
    try (PreparedStatement stmt = cnt.prepareStatement(
            "insert into Company(company_name) values(?)")) {
        stmt.setString(1, companyName);
        stmt.execute();
        try (ResultSet rs = stmt.getGeneratedKeys()) {
            if (!rs.next()) {
                throw new SQLException(
                        "Could not get generated keys");
            }
            return rs.getInt(1);
        }
    }
}

Comment: Company_id is fk so its not null.so please let me know query changes
Comment: @Minakshi you need three actually
Comment: pls do let me know how to write query then
Comment: We don't have enough information to completely answer the question: what's the schema, how are IDs allocated? autoincrement? sequences?
Comment: Its simple database i have updated info (AI).. no sequences...
Comment: @Minakshi see my UPDATE
Comment: You may need to do a commit the insert
Answer: Check for the NOT NULL constraint
SELECT * FROM INFORMATION_SCHEMA.COLUMNS where table_name = 'user' and column_name = 'company_id';

If the value of is_nullable is NO, then you cannot insert null value.
Either, change the constraint to NULL, or validate (not null value) your value for company_id.
Syntax to change constraint from NOT NULL to NULL
ALTER TABLE YourTable ALTER COLUMN YourColumn columnType NULL


Can I overclock my cpu using cpupowerd?

Question: I've been trying to look for ways to overclock my rather old cpu, AMD Turion 64 x2 Tl-56 1.8ghz dual core. My Acer Aspire 5100 series bios does not give me the option to overclock. After referring to this question and this thread I found using google, I came to the conclusion the only utility that supports AMD's k8 processor family was cpupowerd. I downloaded the code here, compiled it with
make && sudo make install

loaded the msr kernel module with
sudo modprobe msr

and ran it with
sudo ./cpupowerd --freq "0|1900"

which returned the following message:
cpupowerd 0.2.1 written by Markus Strobl.
WARNING: This program could cause damage to your Hardware!
Frequency 1900 MHz not available!

I then did
sudo ./cpupowerd -s

which returned
cpupowerd 0.2.1 written by Markus Strobl.
WARNING: This program could cause damage to your Hardware!
Vendor                      : AMD
Family                      : K8
Model                       : 4
  Mastercpuid               : 0
    Affected cpuids         : 0 1
    Current voltage (VID)   : 1.1000 V (18)
    Current frequency (FID) : 1800 MHz (10)
    Supported frequencies   : 800 1600 1800 MHz

It doesn't want to set the frequency to something other that what's on the supported frequencies list. Is there any way for more to override it or alter it? Alternatively, is there another utility I could use to overclock my cpu on Ubuntu?
I am able to use cpupowerd as is to set the frequency to 800mhz and 1.6ghz.
Comment: Overclocking the AMD turion i dont think this is supported with ubuntu.
Comment: I think you have to use a certain multiples when setting clock speed. Like how bits come in multiples of 8 (8,32,64 etc.)
Answer:
Supported frequencies   : 800 1600 1800 MHz

This is telling you what frequencies the CPU core allows. If you don't use these, cpupowerd will refuse to change the frequencies. Try using instead:
sudo ./cpupowerd --freq "0|1800"
sudo ./cpupowerd --freq "0|1600"
sudo ./cpupowerd --freq "0|800"

Also, remember that not all cores allow overclocking, which is what I suspect it's happening.

Can I overclock my cpu using cpupowerd?


Do clicked cookies still count after a reset?

Question: I picked up cookie clicker again. I am trying to get some achievements as fast as possible.
One of those achievements is Make 1 quadrillion cookies from clicking..
Right now I am on 75.123 billion cookies clicked.
If I reset(not wipe) the game, do I have to start over again with clicking or does it continue where I left?
Comment: I suspect cookie clicker being a secret experiment by manufacturers of computer mice such as M$ or Logitech.
Answer: My extremely basic test involving 25 clicks resulted in an answer you won't like, resetting does wipe the stat "cookies clicked". The only thing that stays is cookies baked (all time), and "cookies forfeited" goes up with the amount of cookies you gave up.
So, just keep clicking without resetting.


Pentaho + apache Reverse Proxy + proxy SSL integration

Question: I have a problem with merging pentaho docker container into our internal infrastructure.
Overview:
Domain proxy is listening on port 443 (handles SSL and LDAP auth), and redirecting traffic to apache reverse proxy (standing as docker service in swarm with overlay network).
The reverse proxy is redirecting requests to the pentaho container (also docker service in same swarm as reverse proxy).
Config: (only relevant lines)
Domain proxy (not managed by us): listens on 443 and redirects to reverse proxy docker container
Reverse Proxy: Listen  80
<VirtualHost    *:80>
    ServerAlias     reverse-proxy
    ServerName      reverse-proxy
#pentaho redirect
<Location "/application/pentaho">
    ProxyPass               "ajp://pentaho_host:8009/application/pentaho" ttl=480
    ProxyPassReverse        "ajp://pentaho_host:8009/application/pentaho"
</Location>

Pentaho Container:
Pentaho runs with changed context with following settings:
system/server.properties file:
fully-qualified-server-url=https://example.com/application/pentaho

Tomcat config:
tomcat/conf/server.xml:
<Connector URIEncoding="UTF-8" port="8009" protocol="AJP/1.3" redirectPort="8443"
#Without ProxyName and ProxyPort tomcat redirects all app buttons to http://localhost:8009/
ProxyName="example.com"
ProxyPort="443" />

context change
<Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="true">
    <Context path="/application/pentaho" debug="0" docBase="pentaho" />
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>

The problem here is, that when I access https://example.com/application/pentaho, I get the pentaho login page (https://example.com/application/pentaho/Login),
and after I login with proper credentials I get redirected to same login page again (with ;JSESSION 32IBN4O1I23N21OI3...),
But in console I can see that after login, request passed j_spring_security_check (HTTP 302 OK), then it gets to https: //example.com/application/pentaho/Home .... (also with HTTP 302 Found)
and then back to login...
Access log:
x.x.x.x - - [21/Sep/2017:15:11:49 +0000] "GET /application/pentaho/Login HTTP/1.1" 200 7208
x.x.x.x - - [21/Sep/2017:15:11:49 +0000] "GET /application/pentaho/webcontext.js HTTP/1.1" 200 4472
x.x.x.x - - [21/Sep/2017:15:11:49 +0000] "GET /application/pentaho/content/sparkl/resources/sparkl-require-js-cfg.js HTTP/1.1" 200 1525
x.x.x.x - - [21/Sep/2017:15:11:49 +0000] "GET /application/pentaho/content/client-config-folder-enabler/client-config-enabler-require-js-cfg.js HTTP/1.1" 200 1019
x.x.x.x - - [21/Sep/2017:15:11:49 +0000] "GET /application/pentaho/js/themes.js HTTP/1.1" 200 1346
x.x.x.x - - [21/Sep/2017:15:11:49 +0000] "GET /application/pentaho/CacheExpirationService HTTP/1.1" 200 1161
x.x.x.x - - [21/Sep/2017:15:11:52 +0000] "POST /application/pentaho/j_spring_security_check HTTP/1.1" 302 -
x.x.x.x - - [21/Sep/2017:15:11:52 +0000] "GET /application/pentaho/Home;jsessionid=09D72F59187B02D027D4313EBDA645EA HTTP/1.1" 200 4928
x.x.x.x - - [21/Sep/2017:15:11:52 +0000] "GET /application/pentaho/Home?locale=en_US HTTP/1.1" 302 -
x.x.x.x - - [21/Sep/2017:15:11:52 +0000] "GET /application/pentaho/Login;jsessionid=B9B10CD32A3CD832C87243A5610C3B09 HTTP/1.1" 200 7301
x.x.x.x - - [21/Sep/2017:15:11:52 +0000] "GET /application/pentaho/webcontext.js HTTP/1.1" 200 4472

and over and over again...
Do you guys know what can be misconfigured here ?
Comment: my browser works fine but cannot connect PDI to repo https://stackoverflow.com/questions/59163762/pentaho-reverse-proxy-kette
Answer: You need to add pentaho-style reverse proxy directives:
<Location "/application/pentaho-style">
    ProxyPass               "ajp://pentaho_host:8009/application/pentaho-style" ttl=480
    ProxyPassReverse        "ajp://pentaho_host:8009/application/pentaho-style"
</Location>

and voila! :D


Refrigerator has to be on GFCI?

Question: I am original owner of 1986 house where the refrigerator was put on kitchen GFCI as it is 5' from the sink. I lived there 25 years and never had the GFCI trip for any reason. I had GE fridge, then Whirlpool fridge, then Samsung fridge.
18 months ago I gutted the house to bare studwalls and renovated it for a rental. With the walls open I had an electrician inspect the panel and all wiring, and had him replace all the GFCIs just because of age. I also asked him about a dedicated non-protected circuit for the fridge but he said it wasn't allowed because of being 5' from the sink. So he left it on the GFCI.
The first renters experienced one nuisance trip in over a year of renting, no idea if their fridge or something else caused it. The new renters' fridge, however, is tripping the GFCI several times a day (we have narrowed it down to the fridge). Their fridge is less than 10 years old and works fine on an extension cord to non-protected outlet as a temporary measure to preserve their food.
I'm replacing the GFCI just because it has been tripped so much. I doubt the existing GFCI is faulty but I guess we'll see after I replace it. If the new GFCI continues to trip, is there anything else I can do for them?  Thank you for your help.
EDIT to add: The fridge is on the last outlet in the circuit. In other posts I saw mention of a "snubber" - is that something I can add to the fridge's outlet and would it help stop the fridge from tripping the GFCI?
Comment: Your electrician was too rigid, or you were. The fridge **receptacle** almost certainly could have easily been made 6 feet 1 inch from the sink if it was 5 feet from the sink and you had the walls open.
Comment: Where do you live , what location? In Oregon a dedicated circuit is allowed for equipment like refrigerators, yes within 5' from a sink or in a garage or out building that if you only read the national code there are no exceptions but the state has a list of changes to the NEC , 26 pages and this is just 1 article, knowing the local jurisdiction may help as I find dozens of electricians that do not know the exceptions
Comment: The fridge is at the end of the cabinet run on a loadbearing wall that ends at the fridge. The receptacle is 8" away from the edge of the wall. I will go measure, but I believe that is where the 5' measurement comes from. It is a very tiny kitchen.
Comment: You haven't told us where you live, and the electrical code varies by country, and then within a country it can vary by city. So. But In general your electrician screwed up. The fridge should have been on a dedicated circuit — that is, with one outlet behind the fridge on a wire going back to a circuit breaker where the only thing on the circuit breaker is the wire to the fridge outlet. And most electrical codes in the USA and Canada have an explicit exception carved out for GFCI behind large appliances — they aren't required.
Comment: By hiring a licensed electrician, I *thought* I was getting the right info for my area.

But, for the sake of argument, let's say he was not correct and the fridge can be on an unprotected outlet (I don't think it applies in my case but I will surely check into it). If it can be unprotected, does it have to be a dedicated circuit or could it be chained off the GFCI line terminals on the same circuit? Due to the location of the panel and the vaulted ceilings, I don't think we could (very easily) pull a line while the house is occupied.
Comment: This question has been asked before, and as Ed notes it seems like it depends on the details of which version of the NEC your jurisdiction is using, and with what modifications: https://diy.stackexchange.com/questions/248420/does-nec-require-a-refrigerator-outlet-within-six-feet-of-a-sink-to-be-protected
Answer:
Replace it:

When you replace it use a different brand. In a quick search at Big Orange, I see mostly Leviton and some Legrand. Big Blue mostly Eaton. Big Green mostly Legrand and Smart Electrician (house brand?). Pick something of a different brand and, preferably, as little "smarts" as possible, though since they all (or nearly all) now have self-test, there are always some smarts in there. And then hope for the best. The big unknown is whether it is a truly faulty refrigerator or an overzealous GFCI.

Get rid of it:

This is where you run into a code issue, as you know. But at 5' away, is there any place that would be just over 6' where you could mount a receptacle? That would likely be the easiest fix.
Now one catch is "renter". In most places, a landlord can't do their own electrical work. I can see the argument for extremely simple stuff - e.g., straight receptacle swap. But certainly adding a receptacle at a different location (whether new circuit or chained off an old circuit) is "real work", which means that legally you most likely need to call a licensed electrician to do the work. $$$
Comment: I definitely would not use AFCI. While GFCI should be extremely simple, AFCI is inherently complex as it is looking for patterns and not just a simple comparison
Comment: Thank you. I have bought a Levitron AFCI/GFCI dual function to replace the existing Legrand one.

The side of the fridge is exposed as it is on a loadbearing wall that ends with the fridge, and the sink is the other direction from the fridge.
Comment: Thanks, I will exchange it for plain Leviton GFCI. I thought I had to have AFCI as well in this situation.
Comment: Quite the opposite. GFCI has to do with life safety, particularly in wet areas. That's why it has been required for a long time in bathrooms and kitchens and gradually expanded to outdoor receptacles, laundry rooms, etc. AFCI has to do primarily with fire prevention. It started in bedrooms (electric blankets) and gradually expanded to most other rooms (various wiring faults). It is quite possible that current code in your area requires AFCI *and* GFCI for kitchens/bathrooms/etc. and just AFCI in non-wet finished spaces. But generally speaking retrofit is not required. You can't lower the
Comment: protection though, which is why you can't simply remove GFCI from here. But you don't have to *add* AFCI and it would be counter-productive to your current problem. In addition, AFCI is actually far more useful when done at or near the breaker panel, as opposed to GFCI which can be anywhere up to and including point of use (exception: outdoor receptacles around pools, etc. should have GFCI at the panel; but indoors - point of use is fine.)
Comment: Thank you I will double check I can use stright GFCI here.

Refrigerator has to be on GFCI?


Getting user id from on table and counting them in another table

Question: I have to make a scores page for a game and one thing it has to display is the number of times the current user has played the game. Basically what i need to select ID and username from one table, link them together and count the corresponding user IDs from another table.
These are the tables I was given: Users --> ID, USERNAME and Times_Played --> ID, USER_ID
Thanks in advance
Comment: post both the table structure together with some sample data along with desired output
Answer:
You want to query something like this:
SELECT Users.USERNAME, Times_Played.User_ID
FROM Users
INNER JOIN Times_Played
ON Users.ID=Times_Played.ID;

EDIT
After re-reading the question and seeing the need to count the times played you could do this via PHP or via your SQL Query. Via PHP:
$result = mysqli_query(
"SELECT Users.USERNAME, Times_Played.User_ID
FROM Users
INNER JOIN Times_Played
ON Users.ID=Times_Played.ID"
);

$timesPlayed = mysqli_num_rows($result);

If it has to be done via the query, Anish has the correct solution.
I hope that helps.
Comment: what about Times_Played ?
Comment: Edited. Thanks for pointing that out. Misread the question at first.
Answer: Try this
select count(*) as Times_Played,Users.USERNAME,Users.ID
 from Users
 inner join Times_Played
 on Users.ID = Times_Played.USER_ID


Camel fetch data from http

Question: Im new to Apache Camel. Im trying to copy this file into a folder: https://www.dnb.no/portalfront/datafiles/miscellaneous/csv/kursliste_ws.xml
I get the error:

Exception in thread "main" java.lang.UnsupportedOperationException:
  Cannot consume from http endpoint

package route;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.log4j.BasicConfigurator;

public class CurrencyRoute {

        public static void main(String args[])  throws Exception {
            // Log 4j
            BasicConfigurator.configure();

            // Create camel context
            CamelContext context = new DefaultCamelContext();

            // New route
            context.addRoutes(new RouteBuilder() {
                public void configure() {
                    from("https://www.dnb.no/portalfront/datafiles/miscellaneous/csv/kursliste_ws.xml")
                            .log("Read file")
                            .to("file:src/main/resources/data/inbox");
                }
            });

            // start the route and let it do its work
            context.start();
            Thread.sleep(10000);

            // stop the CamelContext
            context.stop();

        }

}

So I know I have to define a route for it, but where should I define it (in what file??), and how should it be defined?
Updated code 13.10.2017 13:06
package route;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.log4j.BasicConfigurator;

public class CurrencyRoute {

        public static void main(String args[])  throws Exception {
            // Log 4j
            BasicConfigurator.configure();

            // Create camel context
            CamelContext context = new DefaultCamelContext();

            // Template
            ProducerTemplate template = context.createProducerTemplate();

            // New route
            context.addRoutes(new RouteBuilder() {
                public void configure() {
                    from("direct:start").setHeader(Exchange.HTTP_METHOD, constant("GET"))
                            .to("https://www.dnb.no/portalfront/datafiles/miscellaneous/csv/kursliste_ws.xml")
                            .to("file:src/main/resources/data/inbox/?autoCreate=true");
                }
            });

            // SendBody
            template.sendBody("direct:start", null);

            // start the route and let it do its work

            context.start();
            Thread.sleep(10000);

            // stop the CamelContext
            context.stop();

        }

}

Answer: For configuring routers in camel you can take a look at excellent examples provided by Camel here along with code on github. Also your route is not a valid, firstly the uri endpoint sysntax is wrong, secondly a http or http4 endpoint can only be used as a producer not consumer.

You can only produce to endpoints generated by the HTTP component.
  Therefore it should never be used as input into your camel Routes.

For your case take a look here. Basically you need to do something like this
from("direct:start").setHeader(Exchange.HTTP_METHOD, constant("GET"))
.to("https://www.dnb.no/portalfront/datafiles/miscellaneous/csv/kursliste_ws.xml")
.to("file:src/main/resources/data/inbox/?autoCreate=true");

and then call the direct endpoint
template.sendBody("direct:start", null);

or you may make use of a timer as explained here and your route as something like this
from(timer).to(http).to(file);

Comment: I dont have any variables named "template". Did you mean context.sendBody("direct:start", null); ?
Comment: You can create a simple ProducerTemplate using ProducerTemplate template = context.createProducerTemplate();
Comment: I updated the code with template (see my first post) then I got this error:
Exception in thread "main" org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: [Body is null]]
Comment: Set the body to some dummy string. Then you inside the route you can clear the body. The string is just to trigger the route. In any case I suggest you don't put your route code in your main method. Have a seperate RouteBuilder class for this. There are many examples online that show this.

Camel fetch data from http


Restore Xfce menu after installing program from flatpak

Question: I'm running Xubuntu (Ubuntu Studio which is based on Xubuntu), and I somehow messed up my applications menu. I had the original menu, with the favorites on the left side and the applications grouped by theme (accessories, education, games, internet, etc) on the right hand side.
I installed PiTiVi from flatpak (I know, I should have installed it using the synaptic package manager). Now, I still have my favorites on the left side, but the right side shows only "All".
How can I restore the default Xfce menu?
(Before and after attached. Before is from a virtual machine, with no personal favorites added.)
Comment: DK Bose - thanks for the suggestion. I thought that I was clarifying my request. Based on your comment, I actually made my question less clear.
Answer: I received an answer here. Though the whiskermenu-1.rc was part of the issue, it was a little more complicated than that. Here is the solution:

ToZ (moderator) #10 2019-01-20 15:00:53
Looks like you ran flatpak with root privileges and it somehow messed up your menu generation (the menu creation routines cannot access a directory in your $XDG_DATA_DIRS path).
To fix it, run the following:
sudo chown $USER:$USER $HOME/.local/share/flatpak

...and restart the panel:
xfce4-panel -r

Original thread: XFCE Forum - Restore XFCE menu


Setting up graphics on Ubuntu for gaming

Question: I would like to change from windows 10 to ubuntu on my "gaming" laptop. It has a core i5 with intel graphics and ATI Radeon HD 8850m graphics.

Do I need to install any driver for the Radeon?
Will I be able to swap processing on-the-fly between Intel graphics and Radeon graphics depending on my usage?

Thanks.
Comment: Highyly related but likely no duplicate due to the technical differences of Ubuntu Xenial: https://askubuntu.com/q/791249/175814
Answer:
You would have to get an open source AMD GPU driver I believe since there is no more official support for the HD Radeon AMD GPUs on linux anymore (ever since 15.10 or 16.04).
Always use your AMD GPU over your integrated graphics, not to mention integrated graphics relies on your system RAM which is slower than your VRAM (unless you have a horribly unbalanced setup). Even modern Intel integrated graphics can't beat that card in gaming, you shouldn't have to do any kind of processing swapping like that except where the CPU and GPU are meant to exchange tasks, obviously.

Wish you the best of luck! :)
Comment: Ok. But how to disable integrated graphics completely please?
Comment: If you have the driver installed and set up properly, you shouldn't have to, but I'll see if I can find anything on that.


Why is a second local player with an XBOX Live Silver account allowed to play online?

Question: This is typically not allowed on XBL, but I noticed Dungeon Defenders somehow got around this. I can't find any information online as to whether this was done as a promotion or some agreement between Microsoft and Trendy Entertainment.
I'm not talking about the second player playing as a guest under the first player's profile.
Comment: Gotcha - was unaware that actual usage of a secondary profile and items local to that profile was possible. However, I don't think this question is a good fit - a list of games that let you do this wouldn't be appropriate, and the question "Why did the devs let local profiles play online" isn't really answerable. I'd recommend asking about this [in chat](http://chat.stackexchange.com/rooms/35).
Comment: I should note that my account is the first player account and is XBL Gold
Comment: I'm not sure where you're getting the "this is not typically allowed" bit - the Halo series has always allowed guests to play alongside a main play with XBL Gold, as has Call of Duty and numerous other series.
Comment: I think this is the case when they are playing as a guest under your profile. But hasn't it always been the case that if the second player wants to use their own profile that they have to have XBL gold?
Comment: Carrying on with my research. No luck yet. I have been able to replicate this using my XBL Gold and friend's XBL Silver account several times. We can get in to an online match no problem. He gets to use his personal characters, bank mana, etc.

I'm not saying this is a bad thing, I just want to know if there are other such games so I can collect them.
Comment: @IanPugsley While in the comments it is mentioned that if this is the way things are a list of games that are also like it are the end goal, the overall question of this being something unique to Dungeon Defenders or not still seems valid to me.
Answer: The account type of the second account does not matter, and that is global across all games.
It only takes into account the person who is running the game, so to speak. The second local person could be using a gold, silver or even just a guest account and would still be able to enjoy the online matching brought about by the gold account.. They are just there for the ride, nothing more.
Comment: I think this is the case when they are playing as a guest under your profile. But hasn't it always been the case that if the second player wants to use their own profile that they have to have XBL gold?
Comment: I have never had that come up as a concern before in the years of playing XBL games.. As long as one account has the game unlocked with a gold account, the other accounts piggy back on that one.
Comment: Actually, COD MW2 doesn't allow this.


can't use pyqt default icons

Question: I'm trying to set pyqt default icons for my program but I get an error.
here is my function:
def show_pop(self):
        msg = QMessageBox()
        msg.setIcon(QMessageBox.Information)
        msg.setWindowTitle('mb demo')
        msg.setText('You Pressed Button')
        msg.exec()

The Error:
AttributeError: type object 'QMessageBox' has no attribute 'Information'. Did you mean: 'information'?

PN: I'm using pyqt6.
Answer: I just solved the problem:
in pyqt6 you have to set default icons like this Example:
msg.setIcon(QMessageBox.Icon.Information)

can't use pyqt default icons


CSS won't flip a unicode font icon and won't change it's color on hover

Question: I have 2 problems:

The unicode icon twitter won't flip
All unicode icons won't change color on hover (Only the background)

jsFiddle:
HTML
 Follow us

 Like us

CSS
[class^=icon] {
    font-family: Arial, Helvetica, Tahoma, Verdana, "Courier New", "Times New Roman", sans-serif;
    /* UNICODE only! No custom font files. No images */
}
[class^=icon-facebook]:before {
    content: "\024D5";
    content: "\00066";
    color: #0000FF;

    font-size: 1.5em;
    font-weight: bold;
}
[class^=icon-twitter]:before {
    content: "\01F426";
    color: #3366FF;
    font-size: 1em;

    transform: scale(-1, 1); /* Flips the text */
}
[class$=-circle] {
    display: inline-block;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    padding: 0.30em; /* Size of circle */
    margin: 0.10em 0.0em; /* Line spacing */
    border: 1px solid #000;

    line-height: 20px; /* Centers the character Horizontally, on it's Y-axis */
    text-align: center; /* Centers the character vertically, on it's X-axis */
}
[class^=icon-twitter]:hover {
    color: #fff;
    background-color: #3366FF;
}
[class^=icon-facebook]:hover {
    color: #fff;
    background-color: #0000FF;
}

Note
I just leaned and would like to point out that transform WON'T work unless the element is displayed display: block or display: inline-block. Hence, icon-twitter won't flip unless I add .icon-twitter {display: inline-block; ... transform...
Comment: yeah the answer below is right `[class^=icon-twitter]:hover:before {` is the selector you want but these characters won't take colors as they are multicolor on some systems (mac)
Comment: I want to point out that **`transform` WON'T work unless the element is displayed `display: block` or `display: inline-block`**. Hence, `icon-twitter` won't flip unless I add `.icon-twitter {display: inline-block`
Answer: your hover color doesnt work because you set the color on the :before pseudo-element, but you are trying to change the color on hover of the actual element. They are 2 different things.
target :hover:before instead.
Fixed here.
Changed code is:
[class^=icon-twitter]:hover,
[class^=icon-twitter]:hover:before {
    color: #fff;
    background-color: #3366FF;
}
[class^=icon-facebook]:hover,
[class^=icon-facebook]:hover:before {
    color: #fff;
    background-color: #0000FF;
}

Comment: I'll use `[class^=icon-facebook] { color:... }` rather than `[class^=icon-facebook]:hover:before`
Answer: You need to apply the color and flip to the main element, not the before element, OR you need to target the :hover:before instead of just :hover
Fixed code using first method.
Comment: I'll use `[class^=icon-facebook] { color:... }` rather than `[class^=icon-facebook]:hover:before`
Comment: Apologies, thought I had. Updated the link in the comment with the correct code.


How specialize (override) class fields in Dart?

Question: I would like to specialize fields (override) when a class is extended or implemented in Dart 2.
See the code:
abstract class Abase {
  String id;
  List<Bbase> bbases;
}

abstract class Bbase {
  String id;
}

class A implements Abase {
  String id;
  String name;

  List bbases; // 'A.bbases=' ('(List) → void') isn't a valid override of 'Abase.bbases=' ('(List<Bbase>) → void').
}

class B implements Bbase {
  String id;
}

class Abase has the generic field List<Bbase> bbase and in the class A I would like to specialize this field with List bbase.
But this is not possible. This error is presented on analyzer or build_runner:

'A.bbases=' ('(List) → void') isn't a valid override of
  'Abase.bbases=' ('(List) → void').

Is there a reason for does not accept this specialization of fields?
Is there another way to specializate fields on extends or
implements?
Comment: You can use generics but I find your code too confusing to do the actual implementation. something like `abstract class Abase {
  String id;
  List bbases;
}` and `class A implements Abase {`
Comment: Generics is the way. Great!
Answer: You have to use generics:
abstract class Abase<T extends Bbase> {
  String id;
  List<T> bbases;
}

abstract class Bbase {
  String id;
}

class A implements Abase {
  String id;
  String name;

  List bbases;
}

class B implements Bbase {
  String id;
}

Comment: Great, that's what I was looking for.


javascript:Display value in textarea

Question: I`m trying to display default value in textarea,on click it should clear existing data and onblur it should display default text.Following is my code->
<textarea class="TextArea" id="appfield" name="appfield" style="height:44px;" rows="2" onfocus="deletetext(this)" onblur="filltext(this)" value="defaulttext"></textarea>

value is not displaying in textarea.what`s wrong???We have similar case in this website in Title textbox.I have to implement the same in my case.
Please suggest an answer.
Comment: Are you missing a quote here? `style="height:44px;" rows="2"` and +1 @elias94xx
Comment: Textareas are supposed to hold their values inside/between their tagname.
Comment: Sounds like you might be trying to replicate the functionality of the `placeholder` attribute. Why not just use that? There are numerous [polyfills](https://github.com/jamesallardice/Placeholders.js) to make it work in older browsers.
Comment: @JamesAllardice:I`m using IE8,placeholder doesn`t work. I have to implement the same case as the Title box of this site have.onBlur, onfocus have to do.But the prob is vallue='default text' itself not displaying.
Comment: @user1495475 - As I mentioned, you can [use a polyfill](https://github.com/jamesallardice/Placeholders.js) to make `placeholder` work in older browsers. As has already been stated, you need to put the value *inside* the `` tags, and get rid of the `value` attribute.
Comment: @JamesAllardice:I got it.I fixed it.By using default value only.Thank you.
Answer: the correct way is
<textarea ...>defaulttext</textarea>

but you should set up a working fiddle (functions included) to reproduce the issue.
Comment: @fabrizo:I`m sorry,wat`s working fiddle??i`m using IE8.placeholder doesn`t work.
Comment: jsfiddle.net or jsbin.com : you could write and share an example demo including markup, css, javascript reproducing your code in short.
Comment: That is the correct way to set the default value, but it won't imitate the placeholder attribute. And much better to post the code here than on another site.
Answer: If you have an option and want to use HTML5 you can do it by using placeholder attribute.
<textarea
    class="TextArea"
    id="appfield"
    name="appfield"
    style="height:44px;
    rows="2"
    placeholder="default text"
    value=""></textarea>

Other option is
<textarea
    onfocus="if(this.value==this.defaultValue)this.value='';"
    onblur="if(this.value=='')this.value=this.defaultValue;"
    class="TextArea"
    id="appfield"
    name="appfield"
    style="height:44px;
    rows="2">default text</textarea>

Comment: :Thanks for the answer.It worked.I didnt know that defaultValue will be the text entered between tags.Thanks a lot again.
Answer: You can use this
 <textarea  id="username"  name="username"
onfocus="if(this.value=='somevalue') { this.value='';this.style.color='#333333';}"

onblur="if(this.value=='') {this.value='somevalue'; this.style.color='#B2B2B2';}">
somevalue
</textarea>

Comment: :I`m sorry I still have a problem of the value="somevalue",it`s not displaying this value.default value worked for me.
Comment: see the edited answer.I wrote a/c to `input type="text"`.i didn't see the textbox
Comment: what font,family is that this website is using in Title textbox?that textbox you`ll get when you click on "Ask Questions".This should apply only for Default Text.Please suggest me.
Comment: `textarea {
    border: 1px solid #999999;
    font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;}` this is for stackoverflow
Comment: but this is not only for default text.Can`t we separate?
Answer: Instead of using JavaScript you can use placeholder. jsfiddle.
but placeholder not supported by older browsers. you can use jquery libratry.
<textarea class="FullTextArea" id="applyfieldscontrol" name="applyfieldscontrol" style="height:44px"  placeholder="defaulttext"></textarea>

javascript:Display value in textarea