How to display dots (....) if content exceeds in html

Question: I have tried using   text-overflow: ellipsis; this syntax but it's not working can any one help me
Html

How to show dots if text is exceeds than the limit

Style that i have used
.product-desc{
    padding: 0.8em 1.5em;
    background: #337AB7;
    text-align: center;
     text-overflow: ellipsis;
}
.product-desc p{
    font-size: 1.2em;
    color: #fff;
    margin-bottom: 0.5em;
    font-family: 'Carrois Gothic', sans-serif;
}

Answer: Try the below:
.product-desc p{
    font-size: 1.2em;
    color: #fff;
    margin-bottom: 0.5em;
    font-family: 'Carrois Gothic', sans-serif;
    width:180px;
    white-space: nowrap;
    overflow:hidden !important;
    text-overflow: ellipsis;
}


Color theme change in Vuetify not working

Question: I am using vuejs with vuetify, I put a Basic vuetify template and tried to Change the Color theme but the Color will not Switch. I do not get any Errors in my console and my Cache is cleared aswell.
The main.js Code:
import Vue from 'vue';
import Vuetify from 'vuetify';
import 'vuetify/dist/vuetify.min.css';
import colors from 'vuetify/es5/util/colors';

Vue.use(Vuetify, {
  theme: {
    primary: colors.indigo.base, // #E53935
    secondary: colors.indigo.base, // #FFCDD2
    accent: colors.indigo.base // #3F51B5
  }
});

const app = new Vue({
    el: '#app',
    // ...
});

And this is how my template Looks like.

  <v-app light>
    <v-navigation-drawer
      fixed
      v-model="drawerRight"
      right
      clipped
      app
    >
    </v-navigation-drawer>
    <v-toolbar
      dark
      fixed
      app
      clipped-right
    >
      <v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
      <v-spacer></v-spacer>
      <v-toolbar-side-icon @click.stop="drawerRight = !drawerRight"></v-toolbar-side-icon>
    </v-toolbar>
    <v-content>
      <v-container fluid fill-height>
        <v-layout justify-center align-center>

        </v-layout>
      </v-container>
    </v-content>
  </v-app>

Comment: You're importing the minified css, you should instead be imported the stylus files. Try using `@import '~vuetify/src/stylus/main'`
Comment: Your `vuetify` version?
Comment: @Traxo the Version is 1.0.14
Comment: @DigitalDrifter did not work how would the app.js file look then?
Answer: in my case i had to wrap all my components in v-app

  <v-app>
// youre code here
  </v-app>

if you dont do this youre app use default theme.
reference from vuetify docs:

"In Vuetify, the v-app component and the app prop on components like v-navigation-drawer, v-app-bar, v-footer and more, help bootstrap your application with the proper sizing around  component. This allows you to create truly unique interfaces without the hassle of managing your layout sizing. The v-app component is REQUIRED for all applications. This is the mount point for many of Vuetify's components and functionality and ensures that it propagates the default application variant (dark/light) to children components and also ensures proper cross-browser support for certain click events in browsers like Safari. v-app should only be used within your application ONCE."
Comment: Thanks man thats worked,
But it still modified v-app container because of size and default background
Comment: for sizing problem of the page wrap with  the main content area just after v-app  "The key component to making your page content work together with layout elements is v-main"
Answer:
the Color will not Switch

The colour of what? You don't have any components that use theme colours there. If you want to change the background colour of the toolbar for example you have to do <v-toolbar color="primary">
Answer: @DigitalDrifter suggested @import '~vuetify/src/stylus/main'.
However, that's stylus code.
So you can create for example stylus folder and put main.styl in that folder, which is suggested so you can alter the default style easily.
Add that code to main.styl:
// main.styl
@import '~vuetify/src/stylus/main'

Then include main.styl in your app.js
// app.js
import './stylus/main.styl'

If you later want to override Vuetify default stylus variables inside (do it in main.styl), then your variables must be declared before the @import and then they will automatically override the Vuetify default variables.


Login to Facebook from another application

Question: I have a windows application. Users will login to my windows application. Once logged in, there will be a button as "Login to Facebook". The logged in users username and password for facebook is already stored in my DB and i can retrieve that information.
What I need is, once the user clicks on the "Login to Facebook" button, it should automatically go to facebook page with the User logged in by providing the Username and Password retrieved from my DB.
If this is not do-able, upon clicking the button, it should open the facebook login page and enter the Username and Password values retrieved from DB in their relevant textboxes.
This is a research project for my studies. Appreciate your help on this.
Comment: Storing a user's Facebook username and password is a direct violation of the Facebook TOS.
Comment: And because it is not allowed it is also not possible.
Answer: You need to go through the following to understand the facebook's login flow
https://developers.facebook.com/docs/facebook-login/web
For manualy building the login flow go through this
https://developers.facebook.com/docs/facebook-login


Why is it not possible for the vector $1$ to be an element in the following subspace of $P_2(R): U = \{f (x) ∈ P_2(R) | f (5) = 0\}$

Question: Consider the subspace of $P_2(R): U = \{f (x) ∈ P_2(R) | f (5) = 0\}$.
My textbook states: its clear that $U \neq P_2(R)$ since the vector $ 1 \notin U$ but $1 \in P_2$ Therefore $\dim(U) < 3$.
I am wondering why vector $1$ can't be in $U$, with a coefficient of $0$.
I know that the standard basis of $P_2(R)$ is $\{x^2, x, 1\}$.
So if we have coefficients a, b, and c in the form $ax^2 + bx + c(1)$ cant $f(5) = 0$ if $a = 0, b = 1, c = 0$?
Comment: Given $g(x)=0x^2+0x+1$ what is $g(5)$ equal to?  Is $g(5)=0$?  Is $0x^2+0x+1=0$ when $x=5$?  Is $0\cdot 5^2+0\cdot 5 + 1=0$?  What does that mean about $g$?  Is $g$ in your set?
Comment: Compare to the problem of talking about the subspace of $\Bbb R^3$ given as $U=\{(a,b,c)~:~25a+5b+c=0\}$ and asking if $(0,0,1)$ is an element of that subspace.
Comment: This is not saying anything about *multiples of $g$* being in or not being in your set.  Sure, $0\cdot g$ will be in your set... but the question is about $g$ itself being in or not being in your set.  Basic arithmetic and understanding shows that $1\neq 0$ and the result follows.
Answer: The vector $1$ here is $i(x)=0x^2+0x+1$. When you evaluate it in $5$ get $i(5)=1 \neq 0$ so the condition to be part of $U$ isn't fullfiled.


Converting from Java to Javascript, integer math issues

Question: For an assignment I have to create a sudoku board in JavaScript. I had the code in Java so I attempted to convert it, but the code for checking 3x3s utilizes Integer math, which broke the code in javascript. I don't have a whole lot of experience with Javascript and could use some help figuring this out.
We've been able to set up an array to hold boolean values that check the numbers found in a 3x3, but the problem seems to be within the for loops. They're used to jump from 3x3 to 3x3 without checking the wrong spot. However the java int math throws it for a bit of a loop.
function checkBlocks(board) {
   //check each 3*3 matrix

   for (var block = 0; block < 9; block++) {
    var m = [false,false,false,false,false,false,false,false,false];
        for (var i = block / 3 * 3; i < block / 3 * 3 + 3; i++) {
         for (var j = block % 3 * 3; j < block % 3 * 3 + 3; j++) {
       if (m[(board[i][j] - 1)]) {
        return false;
       }
       m[(board[i][j] - 1)] = true;
      }
     }
   }
   return true;
}

We expected it to check every 3x3, and only 3x3s, however, the math goes into decimals and becomes redundant. We just don't really know what to try. None of what we've found online has helped.
Comment: Have you tried with "Math.round(yourNumber)" to delete those decimals?
Answer: There is no specific type for integers in JavaScript. It has only one number type - Number that is double-precision 64 bit floating-point type. Therefore there is no integer division.
So you need to remove fractional part using Math.floor explicitly:
function checkBlocks(board) {
   //check each 3*3 matrix

   for (var block = 0; block < 9; block++) {
    var m = [false,false,false,false,false,false,false,false,false];
        for (var i = Math.floor(block / 3) * 3; i < Math.floor(block / 3) * 3 + 3; i++) {
         for (var j = block % 3 * 3; j < block % 3 * 3 + 3; j++) {
       if (m[(board[i][j] - 1)]) {
        return false;
       }
       m[(board[i][j] - 1)] = true;
      }
     }
   }
   return true;
 }


How does the address of stringstream buffer changes

Question: When i use << operator to put values in buffer sometimes the address of buffer changes. does it copy the values to new address or move them to a new address in memory and how can i know the address where data is stored in?
Also, I'd be interested in a book that covers about streams in c++.
Answer: If you put more data into a buffer then it can hold, the stream class will automatically reallocate a bigger buffer and move all the current data into the new one.
The entire point of the iostreams class is that you are not supposed to worry about those details.
For a book on just IOStream: Try  Standard C++ IOStreams and Locales: Advanced Programmer's Guide and Reference by Angelika Langer (who I've met and trust) (The forward is by Jerry Schwartz, who wrote the first implementation of iostreams.  He wrote a book on the topic as well, but it seems to be out of print)
Comment: Well you do if you saved the buffer address for something else _before_ adding some text in it.
EG: `ptr = s; s << "additionnaltext"; // ptr might be wrong now`
Answer: As far as books go, it all depends on the level of detail you want. The C++ Standard Library (Nicolai Josuttis) does a good job as far as using iostreams goes.
If you want to know about implementation details (e.g., you're out to implement your own iostreams), Standard C++ Iostreams and locales (Langer and Kreft) is the seminal work on the subject.
Answer: This is in the class of gotchas such as
std::vector<int> v;
v.push_back(1);
v.push_back(v.back());

or
std::string s("x");
s.append(s.c_str());

mutating and referring to an address within an STL container can cause memory errors as the container treats the memory location as a private resource but unfortunately in the name of performance the abstraction is not water-tight. I got bitten by the vector push back problem and it took me ages to figure out.
Answer: About the book, just to mention one, Thinking in C++, volume 2 (chapter 4. Iostreams), by Bruce Eckel.


Efficiency of Cloudinary, Imgix

Question: I want to build My blog with attracting images like Travellers and  image manipulations like amazon, ebay, flipkart,etc. I have been suggested to use services like Cloudinary, Imgix, etc to resize/Edit my images since it would be better to store one version of each image although I'd need several versions with different sizes. But I would like to know whether these services are much efficient. Are there any issues?
Answer: There is definitely an advantage to only loading images the size that you need them. The biggest bonus is going to be load times. We all know that users don't like to wait for pages to load. So if you have multiple copies or compress all of your images based on screen size, you will offer a better user experience. Google also bases search display on load times, which image size plays into.
I also suggest using a service that offers CDN for images so that you can take advantage of caching.
Comment: I do work for Filestack and I strongly recommend trying out our service. You can get a free account at filestack.com

Efficiency of Cloudinary, Imgix


Want to redesign an app but can't find its users

Question: There's an app I am really interested in. It's an app about rural journalism. In India we don't have news channels covering the issues of rural areas (well they do cover but it's not enough). The app which I want to redesign is actually doing something to raise the voice of rural india. The only problem is that it's still in the early stages and it only has 1k+ downloads. The app was released in 2020. Because of this I can't really find its users. The app doesn't   have any Discord, subreddit, etc. It has a Facebook page but the users are not there.
What should I do? I don't want to skip the user research part. Some people suggested that I should do some competitive analysis but is it enough?
Edit : I AM NOT WORKING WITH THE DEVELOPERS OF THE APP.
Answer: After reading through the other responses and your remarks, I feel like there are still things I can add.
1. User research
If you cannot reach actual users, the second best group to work with are potential (new) users. What would designers of a entirely new app do? They don't have any users at their disposal because they user base is simply non-existent yet. You could treat your project the same way and start recruiting potential users. To find out which people to recruit you can start by creating Personas and go as far as filling out a Business Model Canvas - whatever helps to get insights on who your potential users might be. A competitive analysis might also help here (e.g. to find out what are common or "bonus" features and maybe you can derive some user expectations from it).
2. Expert evaluation
One user is always available: you. While you should never focus too much on the "I-methodology", don't forget that you can still find out a lot on your own. Especially when there is already an existing product that you want to improve. In order to improve, you first need to find out what needs improvement - and that is where evaluation comes in. There is a number of methods that could be applied here, for example Heuristic Evaluation, a cognitive walkthrough, or other Usability Inspection methods.
These insights might also help you reflect on the characteristics of the app and you as its user, which might in turn help you to generate an informed definition of your target users, which you then can recruit for your user research -> back to step 1.

To follow up on that and what was also mentioned by Dan: You don't have to make it perfect on first try. UX and Usability Design are iterative procedures. The goal is not to be perfect, because it will never be perfect for everybody. The goal is to learn and then make it better on the next try. Once you get more insights, you will
adapt your target user definition or find out about real users and make more informed decisions in the next iteration.
Answer: Andrew gave a great response.
Taking everything into consideration, personal project, struggling to recruit participants, small audience — I'd probably look at some competitor research and create an app to get started. Then you can share it, get feedback from users and if it gains more traction you can do more research and iterate.
You won't launch the perfect product, going through phases of iteration will show a journey and how you listen to your user feedback to make updates but none of this will happen if you remain stuck at the beginning trying to recruit participants because you feel like you can't skip this step(you can always revisit it!).
Answer: It's not clear if you are working with the owners/developers of the app or not but, in any case, you appear to be going about this a bit upside down.
Finding a set of users for an app is much more difficult than building an app for a set of users.
It sounds, to me, like you're trying to sell a UX process to a business that already has an app with limited success. In my experience, an app with such a small number of downloads is either about to be deleted because it is considered unsuccessful, or it is run by a single developer as a pet project. Either way, I don't think you're going to get very much out of this. If it's an unsuccessful app then the company are going to want to cut their losses and walk away without spending any more than they have to. If it's a pet project then there won't be any money to invest in UX. To know for certain you can always contact the app owners via the app store.
It also sounds like this would be a passion project for you. In that case, I would suggest designing your own app, building on what you think the other app does that is so good. Then you can take it around looking for either a developer who aligns with your passions or someone who will put up the money for it to be developed and promoted. This would, of course, mean providing some market research which, in turn, would lead you to YOUR users.
Comment: In that case, I would suggest sending a message to the journalist asking if they're interested in improving the app through user research. Start by telling them how great you think the app is and how good you think its aims are and then ask if they are interested. If they say no, then go ahead and design your own app anyway!
Comment: first of all thanks. first thing I gonna clear here is that this is MY PERSONAL PROJECT. I am not working with the developers of the app.  Now about the app, the app is called **Gaon connection**. Basically its an initiative by a very famous journalist. I really liked the initiative  bc the mainstream media dose not give any reasonable space to rural news. They have a website too with the same features as the app.  I really liked the idea of designing my own app. Thanks again (:
Comment: I mailed him about this but he didn't responded.
Answer: I'm assuming you are working with the app developer and have the ability to request a small feature. Under that assumption, you could try running an in-app survey with a paid incentive (not sure what is possible or practical with your audience, but could they be entered into a drawing to win a Visa gift card or the like?) In the survey, you can ask demographic questions, research questions to supplement what you know about your users to date, and contact information for future research opportunities.
When you look at survey results, try to segment them into groups like "Fits into our target audience", "Fits into an audience we didn't know existed", and "Not here for the right reasons." The first two groups will help you determine some future direction, and if you get enough responses, you'll have a nice research pool for later studies.
Comment: I would suggest, then, that you consider designing a new app that solves the same problem vs. trying to redesign an app that might not be succeeding anyway. To find potential users for research, you might go where those users are getting information today. WhatsApp?
Comment: Thanks. I am not working with the developers of  the app. Its just my personal project that I am doing. I am interested in this app bc I really liked the idea of this app. Its one of a kind app or initiative in India. The problem is that I cant really find the users of the app. I am trying to hard. I even tried to contact the developers of the app but there email address is broken. Messaged them in their fb group but they did not responded. Twitted about my research with the proper hashtag still no luck. At this point I am feel like giving up. I don't know what I am gonna do now. Thanks again.


Are goals simply presets?

Question: Do I lose or gain anything from (dis)allowing my students to have new ones? Is there any significance when they ask me stupid questions where the class name is different but the weapon/goals are the same? (E.g. should I master class A axe/brawl or  class B axe/brawl?)
Answer:
Do I lose or gain anything from (dis)allowing my students to have new ones?

Goals are designed to help guide your characters by gaining experience in skills outside of battles and teaching sessions. At the end of each week, each unit will gain a set amount of experience in the skills they have goals in even if they are not promoted to the class that requires those skills.
For example: While a noble, Ferdinand's default skills, strengths, and goals1 lead him to become a horse-mounted unit such as a Cavalier and Paladin. If the defaults are kept, Ferdinand's riding skill will increase by teaching sessions and goals to allow him to promote to a horse-mounted unit when he reaches the appropriate level.
But what if you don't want Ferdinand to be a horse-mounted unit? What if you prefer armored units? This is where the goals come into play. By changing his goals, you can have his armored skill increase instead of riding to allow him to promote to an armored unit when he reaches the appropriate level.
So by changing (or not changing) your character's goals will effectively change how quickly they can be promoted to a different class.

Is there any significance when they ask me stupid questions where the class name is different but the weapon/goals are the same?

This really all depends on how you want to guide your units, and play style. While the weapon and goal focus may be the same, the class will provide different benefits
For example: The intermediate classes Mercenary and Thief both focus on and require C rank in Swords. However, these classes provide different stat boosts and abilities.

Mercenaries gain +1 HP, +1 Strength, and +1 Speed.
Thieves gain +2 Dexterity, +2 Speed, and the ability to open locked doors and chests.

So if your character wants to switch roles to a different class that utilize the same weapon and goals, it doesn't mean they will necessarily mean they will be played the same.
Personally, I like to take the suggested new route whenever the character asks as it generally will benefit them more based on their current skill levels.
If you change their goals when they request, either purposefully or accidentally, you can always change it by back going to Menu > Goals. This will display their default, custom, and requested goals to choose from

Sources

Kotaku
Polygon

1 I can't quite remember the default goals, so humor me :)
Answer:
Do I lose or gain anything from (dis)allowing my students to have new
  ones?

Not really, you can change their goals whenever you like, you don't lose or gain anything, they keep the progress of anything they were working on.
For example if you had Caspar working on Swords and Axes, but now want Swords and Lances, he will keep his Axe Experience if later on you decide to change back.
The only thing to watch out for is the characters preferred proficiency. You can simply search up a character on the wiki to quickly see their proficiency, or look them up in game. The proficiency determines how quickly that skill will grow with goals.
For example, Caspar has a good rating for Axes and Fists, but a bad rating for Bows, Reason, and Authority. This means that if his goals are set to Axes, and Bows for example, Axes will train much quicker than Bows, but he will still be gaining Bow skill.

Is there any significance when they ask me stupid questions where the
  class name is different but the weapon/goals are the same? (E.g.
  should I master class A axe/brawl or class B axe/brawl?)

Nope! When they come and ask you that, all it does it create a new "quick selection" when selecting their goals. It will not change how fast the skills train or anything else.
For example, I want Caspar to be a knight, so I go into the Goals menu, which would have his starting goal pair, and a selection for custom. I would set his 'Custom Goal' to Axes and Armor.
After a bit, he may come to me and say "Hey Professor, I'd like to learn Axes and Armor to excel at being a knight!", if I accept this, he will have a new preset goal.
So when I go back to into the Goals menu, and choose Caspar, I will now see his starting goal pair, and a new one for Axes and Armor, as well as the custom one, which can still be changed to anything.

Are goals simply presets?


One SSD, two computers (with different video cards). Best approach for video drivers?

Question: I have a single SSD I dual-boot with Windows 7 / Ubuntu 11.10. I switch this drive daily between two computers. One is a laptop with integrated Intel graphics. The other is a desktop with an NVIDIA video card.
I want the correct driver to be used and 3D acceleration to be enabled automatically when I boot into Ubuntu on either computer. How do I achieve this?
When I boot Ubuntu with my laptop most drivers start up normally, but GM965 video driver doesn't load, therefore 3D acceleration remains off. The logs show the NVIDIA driver issuing an error about unavailability (looks like it's forcing the NVIDIA driver).
Is normal that Ubuntu 11.10 & Xorg nowadays don't have the same behavior as Windows 7? When I boot Windows 7 the right driver is loaded by PCI identification, and resolution settings are loaded via DDC from the monitor. I think Xorg can do the same thing like when you boot a live CD.
In order to diagnose I need to know how to configure video driver on modern Xorg deployments that deprecates /etc/X11/xorg.conf
Does anyone have any ideas to help me?
Thanks in advance
Answer: Bodhi.zazens answer is a step in the right direction, but you'll possibly be unable to use GL capabilities of you Intel card (e.g. desktop effects).
A more polished script that uses the vendor ID of nVidia and corrects the GL library paths is shown below. Before installing this script, you need to save the nvidia xorg configuration to /etc/X11/xorg.conf.nvidia. On the nvidia machine, run the below commands:
sudo nvidia-xconfig
sudo mv /etc/X11/xorg.conf{,.nvidia}

The below script should be saved as /etc/init/auto-gfx-card.conf. When copying, be careful not to put spaces after the trailing backslashes.
description "autoconfigure graphics card settings"
start on (filesystem and (starting lightdm or starting kdm or starting gdm))
script
    # If any nVidia device is found, assume it to be a graphics card
    if [ -n "$(lspci -d10de:)" ]; then
        for arch in x86_64-linux-gnu i386-linux-gnu; do
            # since nvidia drivers have a higher priority, it'll
            # automatically selected as the best available version
            update-alternatives --quiet --force --auto ${arch}_gl_conf || true
        done
        # create the symlink, overwriting existing links if necessary
        ln -sf /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
    else
        # restore Intel GL capabilities
        for arch in x86_64-linux-gnu i386-linux-gnu; do
            update-alternatives --quiet --force --set \
                ${arch}_gl_conf /usr/lib/$arch/mesa/ld.so.conf 2>/dev/null || true
        done
        # remove the symlink if any
        rm -f /etc/X11/xorg.conf
    fi
end script

No further commands are necessary to activate this Upstart job.
Comment: This looks great too, I'm hoping OP tries one or the other and has success. Failing that, I'll do the bonus manually tomorrow based only on votes (This is all way past my skill level, I thought I'd throw some points around and see what happens).
Comment: @Lekensteyn Thank our for the upstart script. Once the video cards are working, an upstart script is a much better solution.
Comment: 4 votes to 3 after 24 hours so thanks to both for the great answers, bounty's over.
Answer: It is a messy hack, and there is probably a cleaner method (ie writing a nice upstart init script), but ...
Assuming both the nvidia driver and intel card are working ;)
Use a script in /etc/rc.local to use the correct xorg.conf. The intel card should not need a xorg.conf, so save the working nvidia xorg.conf at say /etc/X11/xorg.conf.nvida
While running the nvidia machine
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia

Then add this to /etc/rc.local
# determine if we have a nvidia card, $VIDEO will be an empty sting with the intel card
VIDEO=$(lspci | grep nVidia)

# test if $VIDEO is empty, and move xorg.conf if needed
if [ -n "$VIDEO" ]
    then
        # if xorg.conf exists, remove it.
        [[ -e /etc/X11/xorg.conf ]] && rm -f /etc/X11.xorg.conf
    else
        # if xorg.conf does not exist copy it
        [[ -e /etc/X11/xorg.conf ]] || cp /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
 fi

 # restart lightdm, need to modify for kdm or gdm
 /etc/init.d/lightdm restart

Depending on how fast rc.local runs you may be able to skip the lightdm restart altogether or if it runs too early you may need to add a sleep.
If you need an xorg.conf for the intel card, simply modify the script to put the correct xorg.conf into place.
The only other potential problem would be if the nvidia kernel module conflicts with the intel driver (unlikely), in that event we would need to blacklist drivers, which can be done with a custom stanza in grub.
Comment: Beautiful, thanks. I'll wait about 24 hours to see if this helps the OP, then do the bounty manually if needed. Side note - I've never seen anyone gain as many points as fast as you, but I'm glad to contribute to the total.
Comment: We really need input from Jairo Andres Velasco Ro (OP). My script can be modified (obviously) and perhaps someone will have a better solution. Thanks for the complement, I have always enjoyed helping people learn Ubuntu, been around for a while, just in other venues (new to ask ubuntu).
Comment: Think you should use `restart lightdm` in the last line (it's an Upstart job :)) or maybe just move it to `pre-start script ... end script` in `/etc/init/lightdm.conf`.
Comment: The idea is good, but you must keep in mind that `/etc/rc.local` is run with [dash](https://wiki.ubuntu.com/DashAsBinSh) and therefore cannot use bashism like `[[`. `lspci` returns multiple words. If you use `[ -n $VIDEO ]`, you'll get an error like "[: 1: 01:00.0: unexpected operator". Quote it properly: `[ -n "$VIDEO" ]`
Comment: thanks for your support, but xorg.conf switching not works because it is an empty file. Xorg is autodetecting hardware, the prob is that it is selecting i915 driver on laptop. I need confirm if someone has GM965 opengl 3d acceleration and which driver used.
Comment: @Jairo Andres Velasco Romero - Well, you need to start with a working X configuration for both cards. With the nvidia card, to use the nvidia driver you need an xorg.conf. This will be written by `nvidia-settings`. I can not tell from your post if your intel card is working or not.
Comment: @JairoAndresVelascoRomero Try running `sudo nvidia-xconfig` for the xorg configuration file. If the nvidia driver does not detect a nvidia card, it will unload itself so that cannot be an issue.
Comment: @JairoAndresVelascoRomero A quick search for that Intel graphics chip reveals a long list of Linux and Compiz problems as far back as 2007. I'd guess that you may need to forget it for now and have a good working configuration that handles both machines reliably.
Answer: This is probably a bad idea. You can't use the NVIDIA driver with your laptop's integrated Intel graphics. Since you have the unusual practice of sharing a single SSD between two different computers, you should probably stick with the 'lowest common denominator' here, which is the default video drivers.
If you still want to install and configure the restricted NVIDIA drivers, do so on the desktop, which has a compatible video card.
Click the gear icon, top right of your screen and choose 'System settings...' then click on 'Additional Drivers'. This will show you any available or enabled proprietary drivers from NVIDIA, like this:

To access the settings for the card after installing the drivers, type 'NVIDIA' in the dash, like this:

This brings up the driver's settings screen. Make any changes you want here and then click the 'Save to X configuration file, like shown here:

For more on configuring X here is the Ubuntu X/Config wiki page
Be aware that if you do this you may run into problems on the laptop, which does not have a NVIDIA card.
Comment: Thanks Tom, I have the nvidia driver enabled when I use my desktop, but I checked the log xorg and I look that driver loaded for my intel chipset is the 'i915' driver (thats the string shown) but my chipset is the GM965. Do I need something to install right 965 driver? it exists? 965 is pretty popular chip on many laptops today, doesnt ubuntu include it?
Comment: Probably it's supported. What you are trying to do is to install drivers for both video cards/chips and have the correct one used at boot, depending on which computer the drive is in. I don't know if that is possible. My advice above would only have your desktop working perfectly. You need to confirm that 3D acceleration is even possible with the integrated graphics on the laptop. There is some hardware support documentation online, but it is a work in progress and does not cover everything. Sorry I can't be more help. Let's try a bounty tomorrow and see what happens...
Comment: Is the GM965 working ?
Comment: @bodhi.zazen I'm hoping the OP returns and provides more info. I think the GM965 is working, but without 3D acceleration. I thought it was an interesting question anyway. My answer is rubbish so I'm hoping someone else can answer with the best practice for this situation.
Comment: Your answer is a good one, using the open source drivers is the way to go, would then work out of the box. If we are going to get into using nvidia and intel closed drivers we at a minimum are going to need 2 xorg.conf and a boot script to detect the graphics card in use and use one or the other xorg.conf. We may need custom grub entries to blacklist various drivers if they conflict. Would be nice to start with working X first ;)
Comment: @bodhi.zazen I've put the bounty up, so it's silly to accept my own answer. If you (or someone else) can explain the best practice for 1HDD swapping between 2 computers, with the best possible video performance, that would be great. I think the dual-boot here is irrelevant but I left it in just in case. The 100 point bounty is immune from the 200 point daily cap, btw.
Comment: yes @bodhi.zazen, GM965 is working but without 3d accel. I need confirm if GM965 has 3d support and what driver provides it. Because now i915 driver isnt good one.
Comment: @JairoAndresVelascoRomero have a look at which answer best fits your original question, and try to choose one. If you have a new question about the GM965 driver, create a new post for that. bodhi.zazen and Lekensteyn put some work into those answers and it would be good to know which one worked.


Creating a wordvector model combining words from other models

Question: I have two different word vector models created using word2vec algorithm . Now issue i am facing is few words from first model is not there in second model . I want to create a third model from two different word vectors models where i can use word vectors from both models without loosing meaning and the context of word vectors.
Can I do this, and if so, how?
Comment: And your question is?
Answer: You could potentially translate the vectors for the words only in one model to the other model's coordinate space, using other shared words to learn a translation-function.
There's a facility to do this in recent gensim versions – see the TranslationMatrix tool. There's a demo Jupyter notebook included in the docs/notebooks directory, viewable online at:
https://github.com/RaRe-Technologies/gensim/blob/develop/docs/notebooks/translation_matrix.ipynb
You'd presumably take the larger model (or whichever one is thought to be better, perhaps because it was trained on more data), and translate the smaller number of words its missing into its space. You'd use as many common-reference 'anchor' words as is practical.


Code review in answers

Question: This question Table 'watchdog' was not locked with LOCK TABLES on custom module has some good answers, but the top voted answer and comments as well as being a valid answer veer into coding standards comments.
While I support encouraging coding standards I worry that when people post code, the answers will tend towards pointing out standards errors in the code rather than answering the question. This could lead to people being reluctant to post code and questions.
What should we do about this? I think the focus should be on answering the question, with comments about the code in the comments section of the question, and perhaps limited to more serious (security) comments.
Answer: You answer is the accepted one, by the way. :)
Also, my answer (the comments not so much, but that's still important information imho) is about a security issue and using the API function would also resolve the issue of the read vs. write lock. :)
But in general I agree, coding style issues should be posted as comments instead.
Comment: Yours was a good answer and it was a good point about using placeholders in the query. I'm more worried about code style zealots putting people off. I know it has happened on D.org.
Answer: The first purpose of an answer is to answer the question being asked; anything not directly required from the question is a side note, and it could better suit a comment.
I agree; if all the answers would report what in the code written in the question doesn't follow the coding standards used for Drupal code, that would make Drupal Answers less interesting for the users. If the question is about how to write secure code, or code compatible with other modules (or Drupal), then reporting that would be acceptable.
There are other things that I think should be avoided, as ending an answer with "Why don't you use X instead of Y?" The user has probably his reasons to use module Y, and I don't think he should explain which those reasons are on any questions he asks about module Y.
Comment: Fortunately, we don't have yet any problem with answers that report what is wrong in the shown code, except for what is relevant for the question itself.

Code review in answers


Calling from a xlsx file I get attribute error but I do not when I create the dataframe pandas

Question: I am trying to do this with two dataframes:
df1 = df.copy()

df1['emails'] = df1.emails.apply(lambda x: ','.join(set(map(str.strip, x.split(','))) - set(blacklisted.email)))

df1 = df1[df1.emails != '']

when I create the dataframe with the same information myself, and it returns the same datatypes it works; for example if I create a dataframe that looks like this:
blacklisted=pd.DataFrame(columns=['email'],
                data=[['firstname.lastname@example.com'],['firstname.lastname@example.com'],['email@example.com'], ['email@example.com'],
                      ['firstname.lastname@example.com']])

blacklisted.head()

 email
0   firstname.lastname@example.com
1   firstname.lastname@example.com
2   firstname.lastname@example.com
3   firstname.lastname@example.com
4   firstname.lastname@example.com

and another dataframe that looks like this:
df=pd.DataFrame(columns=['customerId','full name','emails'],
                data=[['208863338', 'Brit Spear', 'email@example.com'],['086423367', 'Justin Bob', 'email@example.com,firstname.lastname@example.com'],['902626998', 'White Ice', 'firstname.lastname@example.com,firstname.lastname@example.com'], ['1000826799', 'Bear Lou', 'firstname.lastname@example.com'],
                      ['1609813339',   'Ariel Do', 'email@example.com, firstname.lastname@example.com']])
print(df)

customerId      full name       emails
0   208863338   Brit Spear  firstname.lastname@example.com
1   086423367   Justin Bob  email@example.com,firstname.lastname@example.com
2   902626998   White Ice   email@example.com,firstname.lastname@example.com
3   1000826799  Bear Lou    email@example.com
4   1609813339  Ariel Do    email@example.com, firstname.lastname@example.com

the above code works but when I try to call the same information from two files instead using code like this:
blacklisted = df1 = pd.read_excel(r'C:/Users/Administrator/Documents/sfiq/blacklisted.xlsx')
df = pd.read_excel(r'C:/Users/Administrator/Documents/customers.xlsx')

with the exact same information as the two dataframes I created above it wont work, I get an attribute error:
df1['emails'] = df1.emails.apply(lambda x: ','.join(set(map(str.strip, x.split(','))) - set(blacklisted.email)))

the error returned is:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-439d1f152f33> in <module>()
----> 1 df1['emails'] = df1.emails.apply(lambda x: ','.join(set(map(str.strip, x.split(','))) - set(blacklisted.email)))

C:\Program Files\Anaconda3\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds)
   2218         else:
   2219             values = self.asobject
-> 2220             mapped = lib.map_infer(values, f, convert=convert_dtype)
   2221
   2222         if len(mapped) and isinstance(mapped[0], Series):

pandas\src\inference.pyx in pandas.lib.map_infer (pandas\lib.c:62658)()

<ipython-input-22-439d1f152f33> in <lambda>(x)
----> 1 df1['emails'] = df1.emails.apply(lambda x: ','.join(set(map(str.strip, x.split(','))) - set(blacklisted.email)))

AttributeError: 'float' object has no attribute 'split'

Comment: Can you try `print(df.emails)` right before applying your function? One reason may be you have unexpected elements in your `df` coming from your excel. Worth to check.
Answer: Suppose you have:
In blacklisted.xlsx:

In customers.xlsx:

Use astype before apply function like this:
blacklisted = pd.read_excel(r'blacklisted.xlsx')
df = pd.read_excel(r'customers.xlsx')
df['emails'] = df.emails.astype(str).apply(lambda x: ','.join(set(map(str.strip, x.split(','))) - set(blacklisted.email)))
df

df will be:
    customerId  full name   emails
0   208863338   Brit Spear  email@example.com
1   86423367    Justin Bob  email@example.com,email@example.com
2   902626998   White Ice   firstname.lastname@example.com,firstname.lastname@example.com
3   1000826799  Bear Lou    firstname.lastname@example.com
4   1609813339  Ariel Do    email@example.com,email@example.com


Angular2 Get data from HTML data- attribute to component

Question: I have issue with getting data from HTML data attr to component.
In Template I have:
<button [attr.data-direction]="next" type="text" (click)="nextNotes()" [disabled]="checkPage(paginator)"> > </button>

And how can I call this data attr in class method after click? There is some ng workflow for that or purejs?
console.log(data)

Comment: you want to get the **data-direction** attribute ? try with this `<button #myBtn ...`, then in your TS class you can retrieve the attribute with `myBtn.getAttribute('data-direction')`
Comment: But what type has variable myBtn?
Comment: `ElementRef`, you can retrieve it like this `constructor(myBtn: ElementRef) { ... }`, then you can try with `myBtn.nativeElement.getAttribute(...)`
Answer: Not sure if I am 100 % capish here, but if you just want the value from data-directive, then you could pass the button as a local variable to nextNotes() and retrieve the value from there using getAttribute
Template:
<button #btn data-direction="next" type="text" (click)="nextNotes(btn)" [disabled]="checkPage(paginator)"></button>

Class method:
nextNotes(val) {
  console.log(val.getAttribute('data-direction'))
}


GNU screen: Running commands in different window when screen is started

Question: The .screenrc file allows the user to specify that they want multiple windows open when screen is first run.  Eg.
screen -t myWindowA 0 ""
screen -t myWindowB 1 "-${SHELL}"
screen -t myWindowC 2 "-${SHELL}"

What I would like is for each window to run some commands first, like:
screen -t myWindowA 0 "<go to directory a, source a.sh"
screen -t myWindowB 1 "-${SHELL} <go to directory b, source b.sh>"
screen -t myWindowC 2 "-${SHELL} <go to directoy c; start a watch on `ls -l`>"

Is there any way to do that?
Note this is similar to, but different from this issue.
Comment: It's a tiny bit off topic, but have you heard of byobu? It's screen, but a bit easier to use. If so, nevermind. :) If not: https://help.ubuntu.com/10.04/serverguide/C/byobu.html
Answer: Sure you can. On my servers i have a /etc/screenrc with:
screen -t TOP 0 top
screen -t ETC 1 cd /etc
screen -t Console 2

Comment: @Robert Gowland source is a bash builtin, so it can't be executed by scree... Your best option, IMHO, is to create some bash scripts and execute them instead.
Comment: the first example works great, but I can't seem to get it to work with sourced environments, eg "source env.sh".  I get "Cannot exec 'source': No such file or directory" then "[screen is terminating]".  When I try to "cd" as in your second example, I get the a similar error.
Comment: cool.  Thanks for helping me understand what will and won't work.


Is there a simple method to do LU decomposition by hand?

Question: Today my professor in numerical analysis pointed out that in the exam we will probably have to do LU decomposition by hand.
I understand how the decomposition works theoretically, but when it comes actually getting my hands dirty, I'm never sure, if I'm writing the row operation at the right place in the L matrix.
Do you know a mnemonic, which allows one to efficiently compute the LU decomposition by hand?
Answer: Note that I didn't write this answer; taken from: LU Decomposition Steps
This is also useful: Upper and Lower Triangular Matrices
Let's go step by step.  We want an equation of the following form: (An example is given below)
$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}\star&0&0&0\\\star&\star&0&0\\\star&\star&\star&0\\\star&\star&\star&\star\end{pmatrix}\begin{pmatrix}\star&\star&\star&\star\\0&\star&\star&\star\\0&0&\star&\star\\0&0&0&\star\end{pmatrix}$$
From the first column and first row of our known matrix, it's not too hard to see that we can start with this:
$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&\star&0&0\\1&\star&\star&0\\2&\star&\star&\star\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&\star&\star&\star\\0&0&\star&\star\\0&0&0&\star\end{pmatrix}$$
Next, we can choose the diagonal elements of our upper triangular matrix to be $1$, and fill in the lower triangular matrix column by column:
$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&-4&0&0\\1&-3&\star&0\\2&-3&\star&\star\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&1&\star&\star\\0&0&1&\star\\0&0&0&1\end{pmatrix}$$
$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&-4&0&0\\1&-3&5&0\\2&-3&1&\star\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&1&2&\star\\0&0&1&\star\\0&0&0&1\end{pmatrix}$$
$$\begin{pmatrix}1&2&3&4\\5&6&7&8\\1&-1&2&3\\2&1&1&2\end{pmatrix}=\begin{pmatrix}1&0&0&0\\5&-4&0&0\\1&-3&5&0\\2&-3&1&2/5\end{pmatrix}\begin{pmatrix}1&2&3&4\\0&1&2&3\\0&0&1&8/5\\0&0&0&1\end{pmatrix}$$
Comment: how about non square matrices?
Answer: If you remember how to do Gaussian elimination, you can just do that -- the $U$ matrix is precisely the upper triangular matrix you get from elimination, and each subdiagonal entry $L_{ij}$ of $L$ is the multiple of row $j$ you subtract from row $i$ to zero the element $A_{ij}$. The diagonal entries are just the scaling factors to give unit diagonal for $A$.
In fact, performing Gaussian elimination on the matrix in Sujaan Kunalan's example and comparing your steps with those in the example is probably a good way of getting a feel for the method (and more useful than memorizing indices).


sql for loop query to normal query

Question: I have a for loop query and i am trying to change it without looping and trying to one record to validate with out looping.
so, i am looking for normal query without looping.
<code><query name="validate2">
    <![CDATA[
    begin
        for rec in (
            select staging.profileId as sfId
            from staging_pricematch_adj staging
                left outer join client cl
                    on staging.profileId = cl.salesforce_Id
            where staging.rejectcode is null
                and cl.salesforce_Id is null
        ) loop
            update staging_pricematch_adj
            set rejectcode        = '002',
            rejectReason = 'INVALID_PROFILE_ID'
            where profileId = rec.sfId;
        end loop;
    end;
    ]]>
</query>
</code>
i am looking for noraml query without looping conditions.
Answer: Simplistically, this will work:
<code>      update staging_pricematch_adj
      set rejectcode        = '002',
      rejectReason = 'INVALID_PROFILE_ID'
      where profileId IN (

        select staging.profileId
        from staging_pricematch_adj staging
            left outer join client cl
                on staging.profileId = cl.salesforce_Id
        where staging.rejectcode is null
            and cl.salesforce_Id is null

      )
</code>

sql for loop query to normal query


Unable to select children element of tag  in tab of website

Question: I am using the below VB code on internet explorer to automate a web portal:
Dim MyBrowser As InternetExplore
Dim MyHTML_Element As IHTMLElement
Dim myURL As String

Dim htmlInput As HTMLInputElement
Dim htmlColl As IHTMLElementCollection
Dim p As String
Dim link As Object
Dim I As Integer
Dim ie As SHDocVw.InternetExplorer
Dim doc As MSHTML.HTMLDocument

On Error GoTo Err_Clear
myURL = "url............."
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate myURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.Document

HTMLDoc.getElementsByTagName("a").Item(7).Click    <-----Error

Err_Clear:
  If Err <> 0 Then
  Err.Clear
  Resume Next
  End If

But it gives an error on the highlighted line and below is my web inspects:

Please guide me where i am making a mistake to simply click on tab? thanks
Answer: You should put a doevents into your page loading loop.
Do
    doevents
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE

Get the li element by id then the child anchor within.
HTMLDoc.getElementById("current").getElementsByTagName("a")(0).Click

Comment: I really thankful to your guidance and get direct solution by your single respond, God gives you more success in your this knowledge and leads you to the right path. :)


Perl HTTP::Request HASH error?

Question: I'm having a bit of difficulty with HTTP::Request in Perl,
My script is set up like so:
use CGI;
use MIME::Base64;
use HTTP::Cookies;
use HTTP::Request;
use LWP::UserAgent;

$request = HTTP::Request->new(GET => 'http://www.example.com/');

 $ua = LWP::UserAgent->new;
 $response = $ua->request($request);

print "$response";

When I run the script on my website, I get a message like so:

HTTP::Response=HASH(0x987f8d8)

(I'm trying to get it to "print" example.com)
Comment: You can use `content` or `as_string`.  Check the [docs](https://metacpan.org/pod/HTTP::Request).
Answer: Yes its a hash. You have to access like below.
print $res->decoded_content(); ## if gziped

print $res->content();

print $res->status_line;

Also you can use the Data Dumper to print the whole $res and observe what actually it holds.
use Data::Dumper;
print Dumper $res;

Answer: http::Request returns indeed a hash.
$response->content has the result.
From the link:

$r->content( $bytes )
      This is used to get/set the content and it is inherited from the HTTP::Message base class. See HTTP::Message for details and other methods that can be used to access the content.
      Note that the content should be a string of bytes. Strings in perl can contain characters outside the range of a byte. The Encode module can be used to turn such strings into a string of bytes.
Answer: You need to do this ...
print $response->content();

... take a look at the docs http://metacpan.org/pod/LWP#An-Example

Perl HTTP::Request HASH error?


How do I deal with turrets as a Scout?

Question: Playing as scout I try to flank my enemies. My biggest problem is turrets.
I cant get close enough to take them out with a scattergun, but I cannot ignore them as they kill me so quickly.
What should I be doing about these turrets that block my path as a scout?
Comment: Turrets are the scout's natural enemy - if you've got Bonk! as your secondary, you can run past them while invulnerable, and perhaps get them to shoot their engineer.  You can also shoot them from afar with the pistol, assuming the engineer isn't guarding them.  In general, though, they're supposed to be the "scissors" to your "paper."
Comment: If you haven't yet watched Meet the Scout, here's a tip: skip everything before the Meet the Scout title card.
Comment: This makes sense. I am pretty new to TF2 and those turrets are such a pain. Thanks.
Answer: As a Scout, you aren't supposed to deal with sentries. Each class has its counters, and the Scout's high speed and mobility are easily countered by the computer-controlled Sentry.
The best way to get around sentries is to drink Bonk! Atomic Punch while your team is distracting the sentry. Rushing in without team support will cause the Sentry to push you away. Invulnerability does not protect you from knockback.
However, if you absolutely need to take down a sentry, you will need to take advantage of the fact that sentries take full damage from weapons (no loss of damage from distance). Your pistol could take down a Sentry due to its accuracy, but only if the Engineer is not repairing it.
Additionally, many maps have alternate routes you can take. For instance, on the third stage of Dustbowl, there is a tunnel you can take to get behind any sentry guns.
So it is really difficult to take out sentries as a scout. Try alerting your team to its presence, or switch to spy/soldier/demo and take it out yourself.
Answer: Here's what you can do to sentries as a scout if no engineer is around:

Pistol them down from outside their range (best way to deal with minisentries)
Approach them from behind then edge them (sentries need a while to turn around, use that to your advantage)

Here's what you can do to sentries as a scout if their engineer is around:

Approach them from behind in order to get the sentry to kill its engie.
Pick off his dispenser, forcing the engie to multitask (creating an opening for spies, e.g.)
Bonk past the nest altogether and go for their unguarded teleporter entrance at spawn.
Wait for a damage class to come by and drink bonk. Tank the sentry while the damage dealer stays safely behind you. (Countered by the wrangler, but again that creates an opening for spies.)
Answer: Your strategy is highly dependant on the map type that you're playing.  For instance, if you're playing 2Fort, my suggestion would be to ignore the sentries, pound back a Bonk, and make a run for the intelligence.  Actually, there are only a handful of cases where I wouldn't do that.  On cart maps, your goal might be to get behind Red's line, and Bonk can help you do that.  The only time I would take on a sentry as a scout is when it's in the wide open and is unguarded, which will give you room to maneuver around the sentry while taking minimal damage.  Sad to say, but that doesn't happen very often against good engineers.
Answer: A few additional ways to deal with sentries as a Scout that are more situational.

If a sentry is in the process of being built, run up to it and blast it with your shotgun/FaN/Shortstop.  They're much more vulnerable and easier to deal with when not fully set up.
Kill the Engie first.  Even if it's in the process of being built, it might be a better investment to kill the Engie and let a soldier/demo/other heavy damage class clean up the sentry.
For a Mini or a Level 1, you can strafe around it if you catch it from behind and fire your gun at it to take it down.  This takes a lot of skill and the proper orientation for both you AND the sentry so that you can approach it from behind or the sides and run around it, but can effectively take it out.
Or if you can't strafe it, and it's level 1 or a mini, make a team sacrifice and run the corner to take it down (If you can't pick it off with your pistol), overwhelming it with damage.

How do I deal with turrets as a Scout?


Input voltage drop to 190v after switching over load

Question: We have an Online-UPS connected as per the diagram. The output is given to a change-over switch.
So If we want to feed the computers direct AC we switch it to Source O (Top) for bypass and if we want to give it UPS-Output we switch to Source 1 (bottom on change-over).
If the Change-Over is set to Top (Bypass) the reading at the UPS Input Terminals are as follows

Across Point A and Point B : 230v
Across A and Ground : 230v
Across B and Ground : 0v

Now if the change-over is set to bottom (UPS Output), the voltages are as follows, Note the UPS output is still not switched on.

Across Point A and Point B : 190v
Across A and Ground : 230v
Across B and Ground : 40v

If I turn the UPS output ON, the UPS starts beeping saying Battery Voltage Very Low please turn off UPS.
Is the connection done wrongly?
Edit: Verified ground between terminals and building ground. All seems to be fine. The UPS is getting Ground from the building's ground.
Comment: I suspect your UPS is not grounded correctly. How is ground provided to your load (computers)? What is the change-over switch make and model?
Comment: verified ground connections. Computers are grounded with a wire that is connected to the building's ground terminal. Terminals are showing continuity between ground terminals (Wall Sockets/UPS Ground/Appliance Ground).
Comment: Sounds like you have a bad neutral connection between the UPS and supply. This is also likely stopping it charging, hence the low battery voltage.
Comment: Neutral is bad indeed. Thanks Someone Somewhere.
Answer: Previous Setup
So what was happening here is once the change-over was not set to AC, the common neutral was not linking to the UPS output.
Had the wiring reconfigured in the following way. Things are back to normal.


Overload of single method vs get/set for properties in C++?

Question: I have a class A with a property named prop of type int. Getters and setters are usually implemented as follows:
class A
{
    void set_prop(int value);   // set
    int get_prop() const;    // get
}

Is there a reason to prefer this design, instead of using two overloads with the same name, as follows?
class A
{
    void prop(int value);   // set
    int prop() const;    // get
}

I like the last form better (maybe it's just a matter of taste). But I have usually seen the first form. So I am wondering if there is a deep reason to prefer one over the other? That is, is this just a matter of style, or is there an Object Oriented principle that says one is better than the other?
Comment: It's best to avoid this silly pattern altogether... and where's your `const`?
Comment: @LightnessRacesinOrbit Ups, forgot the `const`. Fixed.
Comment: @becko: The close vote is mine and it's because you are asking for opinions on coding style. That is off-topic here.
Comment: @Jashaszun: Always..... A member function that does not mutate its class instance should be marked `const` so that it may be invoked on a `const` class instance (or otherwise through an expression of `const` class type). There is no point in prohibiting such a call (which you do by omitting `const`) if the function does not mutate its class instance. When do you use member-function `const` if not here?! And I have no idea what the return type has to do with it.
Comment: The first is more readable and more widely used in C++. The second is a more .NET, property-driven language type deal that is almost the same as making the value public. It is better to avoid it all together aforementioned.
Comment: Why the close vote? Please leave a comment.
Comment: @ZackAllen I would not say that the second is close to .NET, neither that it is close ti exposing backers.
Comment: Relevant: http://stackoverflow.com/questions/737409/are-get-and-set-functions-popular-with-c-programmers?rq=1
Comment: @LightnessRacesinOrbit Why is `const` needed? The getters work just fine without, don't they?
Comment: @Jashaszun: Not if your object is `const`, no... Why would you _not_ make a getter `const`?
Comment: @LightnessRacesinOrbit I'm not trying to be purposefully thick here, so sorry if it sounds dumb: the `int` that is getting returned isn't `const`, so why would you declare it as such (or declare the getter as a `const` function)? When *do* you want to make a getter `const`?
Comment: @LightnessRacesinOrbit You are partly right. I am not asking for opinion on coding style. Rather, I am asking if the difference between the two forms is *only* a matter of style. If it is, then I'll for the second one because I prefer it. But if there is a deeper reason than just style, I would like to know it. I edited to question to make that point clearer.
Comment: @becko: Of course it is. It's just a name. Though Anthony has a reasonable point about overload resolution.
Comment: @LightnessRacesinOrbit Oh... I guess I've never used this feature before. I just read http://stackoverflow.com/questions/3141087/what-is-meant-with-const-at-end-of-function-declaration and now it makes sense. I previously thought that "since functions are *already* const, the `const` must apply to the return type `int`, not the function itself, and what's the point of that?"
Comment: @Jashaszun: lol okay
Comment: @LightnessRacesinOrbit What's funny?
Comment: People keep voting to close without giving the reason. I tried to fix the question. Please, state the reason to close.
Answer: The rationale behind choosing the first style is one of semantics. A (member in this case) function represents an action and calling a function carries the meaning of requesting the associated action be executed. Because of this, they're typically named after verbs:

get_property()
create_foo()
compute_bar()
show_button()

It's also clearer what you're doing in some contexts, such as when taking the address of a member function:
auto foo = &A::property;
// Is property a member function or a member variable here?

No one is stopping you from going with the second option, in fact a lot of people use a mix of both but the first one definitely aligns better with what a function or method represents in a programming language.
Answer: The first form is much easier to understand from a maintenance perspective.
Remember, you're not just programming for you, but for every person who has to read/modify your code afterwards. So I would go with the first form since the function names easily say what they do.
Comment: What "standard"? The first form is actually _not_ what the C++ standard uses; the second form is. So, um..
Comment: Changed it. I meant "standard" as in the first form is the way I have seen it, and am willing to bet most others have seen also.
Comment: The 'standard' is pretty trivial over something like this. I agree, it's best to go with something readable.
Comment: Where is this "standard" written? If it's just a matter of readability, then it is a matter of taste, I think. I find the second form more readable. That's my opinion, anyway.
Comment: @LawrenceAiello: There is no meaning of "standard" that would have been correct there. That was my main point. The fact that the C++ standard happens to disagree with your viewpoint was an ironic added bonus ;)
Comment: @becko I respectfully disagree. Some programmers "taste" is to name every variable with a single character like `x` and `y`. You may think it makes sense to you, but to the poor sod who has to read it after you leave the company, it makes no sense.
Comment: @LawrenceAiello: Unless those variables represent co-ordinates in a Cartesian system, such programmers should be shot! The same goes for whoever allowed the code to escape code review.
Answer: You have two functions with the same name, but their responsibilities are discrete from each other. One of them has a side-effect of modifying the state of an object, the other one only reads and returns the state of an object. The underlying principle here, I believe, is simply separation of concern.


Translation works only in preview

Question: I have installed the translation package for drupal 7 on https://localize.drupal.org/translate.
Almost everything works fine, but when i add an article, the translation is only happening in the preview.
When I show a preview of the article, everyting is in Dutch, but when i actually post the article, it changes back to English.
Anyone an idea how to fix this?
Answer: Have you configured language detection at admin/config/regional/language/configure?  Assuming that URL is enabled there, try viewing your newly created article at
http://example.com/nl/node/1234
instead of
http://example.com/node/1234.

Translation works only in preview


How to pass appsetting and databind in gridview?

Question: i want to pass a appsetting value and sqldatasource value into gridview to generate a URL for user to click.
e.g.
  <appSettings>
    <add key="VirtualIP" value="http://192.168.1.1/wcm" />
  </appSettings>

  <asp:SqlDataSource ID="SqlDataSource1" runat="server"  meta:resourcekey="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:Test_ConnectionString %>"
            SelectCommand="select MeetingID, MeetName as MeetingName, MeetDate, Year(MeetDate) as MeetYear, Month(MeetDate) as MeetMth, MeetTime, convert(varchar, MeetDate, 111) + ' ' + convert(varchar, MeetTime, 108) AS ShowTime from Meeting where Status ='Recorded' order by MeetDate desc, Meettime desc ">

<asp:HyperLinkField DataNavigateUrlFields="MeetingID" DataNavigateUrlFormatString=""  DataTextField="MeetingID" DataTextFormatString="" />

moreover, i want to add MeetYear and MeetMth as folder in URL
how to assign value in DataNavigateUrlFormatString ?
<%appSettings: VirtualIP%> / MeetYear / MeetMth / {0}.wma

to become
http://192.168.1.1/wcm/2011/12/M11234.wma
regards,
Joe
Answer: Try <%# appSettings: VirtualIP%> / MeetYear / MeetMth / {0}.wma
# is missing.
Answer: You have to use $ expression.
<%$ appSettings: VirtualIP %>


Finding the general solution of a sixth degree differential equation

Question: Find a differential equation whose solutions are $y_1 = e^{2x} + e^{-4x}\sin(3x)$ and $y_2 =  e^{-2x} + 5e^{2x}$.
Am I supposed to assume that $y_1$ and $y_2$ can take the forms:
$y_1 = Ae^{2x} + e^{-4x}[C\cos(3x)+D\sin(3x)]$
$y_2 = Ee^{-2x} + Fe^{2x}$
I'm not sure where to go from here.  Any advice?
Thank you!
Comment: The title seems completely inappropriate. Would you like to edit it into something actually related to the question you ask?
Comment: @GerryMyerson: I agree.
Answer: You can use the annihilator method. For example, the function $ {\rm e}^{\alpha x} $ has the annihilator $D-\alpha $, where $D=\frac{d}{dx}$. That means
$$ (D-\alpha){\rm e}^{\alpha x}= \alpha {\rm e}^{\alpha x}-\alpha {\rm e}^{\alpha x} = 0 \,.  $$
Now, since $y_1$ and $y_2$ are solutions, then $y_1+y_2$ is a solution too.
$$ y(x) = 6e^{2x} + e^{-4x} \sin(3x) + e^{-2x}= 6e^{2x}+ \frac{1}{2i}e^{(-4+3i)x}- \frac{1}{2i}e^{(-4-3i)x} + e^{-2x}\,. $$
To annihilate the above equation, we apply the above annihilators to both sides of the equation
$$ (D+2)(D-(-4-3i))(D-(-4+3i))(D-2)y(x) = 0 \,. $$
Multiplying and simplifying the left hand side gives a differential equation of fourth order
$$ ({D}^{4}+8\,{D}^{3}+21\,{D}^{2}-32\,D-100)y(x)=0 $$
$$\Rightarrow y^{(4)}+8y^{(3)}+21y^{(2)}-32y'-100y=0\,. $$
Comment: this is so cool!
Answer: $$y_1=e^{2x}+\frac12\left(e^{(-4+3i)x}-e^{(-4-3i)x}\right)$$
Now take a differential equation of the form
$$ay+by'+cy''+y'''=0$$
Sub in $y=e^{rx}$:
$$e^{rx}(a+br+cr^2+r^3)=0$$
So we want to find a cubic $r^3+cr^2+br+a$ that has its roots as the coefficients in the above exponents. So we chose
$$(r-2)(r+4-3i)(r+4+3i)=0$$
which will generate each exponential in the expression for $y_1$ as solutions. Expanding, we get
$$r^3+6r^2+9r-50=0$$
So that $y_1$ is a solution of
$$-50y+9y'+6y''+y'''=0$$
The case for $y_2$ proceeds similarly, with a 2nd order differential equation instead.
Comment: I chose a linear differential equation of third order because linear differential equations generate combinations of exponentials, sines and cosines (really just exponential functions to complex powers) as solutions, and because we had three terms after expanding in terms of exponentials.
Comment: Where does the 1/2 come from in the first $y_1$?  Also, why do we substitute $e^{rx}$ into the differential equation?
Comment: It's an identity from complex analysis: $\sin(x)=\frac12(e^{ix}-e^{-ix})$. And the idea is that the derivative of an exponential is still an exponential: when we solve linear differential equations, we use this substitution to turn our problem into solving an *algebraic* equation (in $r$) instead, which we can do with known methods.
Comment: Ok, that makes sense.  But why is $i = -4\pm 3i$?  More specifically, why are we assigning $i$ the value of the complex root, is that what it represents?


Water pump that can shut down if no water from supplier

Question: Presently we are suffering water supply crisis in which there is not enough water supply for the population so water supply has to be turned on or off by the supplier.
What kind of water pump that can shut itself off if there is no water? Usually for normal water pump, it still pumps even if no water is flowing.
(note: I'll be using pressure tank, not storage tank so there is no float. One can't put it inside the pressure tank itself. So I need something that can detect water flow not by level.)
Comment: Ususally sensors are fitted to detect the amount or level of water upstream of the tank..
Comment: What kind of sensors? Are these independent from.the water pump?
Answer: The HC6000 can turn on an outlet at a certain water level and turn off the outlet at a certain water level.  Attach an AC pump and this is an example of a pump that can turn off when the water level is too low.
https://www.amazon.com/HC6000-Hi-Lo-Controller-Float-Switch/dp/B006AU4L4U/ref=sr_1_1?keywords=hc6000&qid=1554961547&s=gateway&sr=8-1
Comment: But I'll be using pressure tank, not storage tank so there is no float. One can't put it inside the pressure tank itself. So I need something that can detect water flow not by level.
Answer: We have a water treatment system that injects diluted chlorine into the piping when there is water flow detected. I used The Google to search for "water flow switch" which returned many results. I discovered that these switches are used for salt water pool systems as well as drinking water treatment systems.
The switch in our system is a vertical pipe in which gravity causes the "trigger" device to settle over the opening in the pipe. When water flows, the disk of the trigger lifts to the top of the enclosure, allowing water to exit at 90°, while simultaneously placing a magnet within range of a reed switch, triggering the pump.
For your application, if the switch you select does not have Normally Closed/Normally Open options, you may have to use a relay for pump control. That's a minor consideration, but is another point of failure overall.
One of the items (Amazon) from my search uses a hall effect sensor with a small propeller within the coupling, reading a magnet on one of the blades.

This type of switch would require a circuit to recognize the signal (or lack of) and trigger accordingly which could be accomplished with an Arduino or similar small-board-computer.
Coincidentally, I later searched for a booster pump to be able to wash solar panels from the ground. Amazon sells a booster pump to run on 110v house current (USA) and incorporates the switch noted above, which makes is a "turnkey" purchase, a stand-alone system that will likely perform as you've indicated.
Comment: I need a complete unit with plugs and outlets. Any ideas where to buy them?
Comment: Edited to add new information of value.
Comment: Well I live in asia and use 240v :) I guess options are so limited now as the only ones available at 110v or so


How do I replace a complex string in a column (Python)

Question: Background
I have a dataset, df, where I would like to replace the string: 'Connected to call (audio, video or screen sharing)'  with 'Connected', as well as replace 'Ended call' with 'Ended'
Connect                                                               End

Connected to call (audio, video or screen sharing)                    3/3/2020 2:00:01 PM
Ended call                                                            3/3/2020 2:05:00 PM

Desired Output:
Connect                                                              End

Connected                                                            3/3/2020 2:00:01 PM
Ended                                                                3/3/2020 2:05:00 PM

What I have tried:
df1 = df["Connect"] = df["Connect"].replace(Connected to call (audio, video, or screen sharing),      "Connected")

Furthermore, how would I replace strings if they are located within multiple columns? Connect and End? (As shown above)
Any suggestion is appreciated.
Comment: Are 'Connected to call (audio, video or screen sharing)' and 'Ended call' the only two possible values?
Comment: Please provide a [mcve]. _But how would I replace the strings of multiple columns?_ What does this have to do with multiple columns?
Comment: I am still very new and just trying to learn @AMC . I have updated my question.
Answer: numpy.select
# sample date
s = """Connect|End
Connected to call (audio, video or screen sharing)|3/3/2020 2:00:01 PM
Ended call|3/3/2020 2:05:00 PM"""
df = pd.read_csv(StringIO(s), sep='|')

# numpy.select with your conditions, choices and default value if condition is not met
df['Connect'] = np.select([df['Connect'].str.contains('Connected'), df['Connect'].str.contains('Ended')],
                          ['Connected', 'Ended'], df['Connect'])

     Connect                  End
0  Connected  3/3/2020 2:00:01 PM
1      Ended  3/3/2020 2:05:00 PM

Comment: Don't want it to be a big deal. Just saying that your solution kind of brushes away the main problem. It's more of a workaround which does not even bothers to tell OP the miss.
Comment: @Yo_Chris I guess the issue OP had was with replacing `parantheses`. That needed to be escaped.  This solution just searches for anything that contains `Connected`. I don't think this was intented.
Comment: @MayankPorwal, my understanding of the question was the the OP wanted to replace the string "Connected to call (audio, video or screen sharing)" with connected. This solution does only search for "Connected" but can be replaced with any string.
Answer: You need to escape parantheses with \ while replacing. That is what is creating problem.
So do something like this:
In [133]: df.Connect.str.replace("Connected to call \(audio, video or screen sharing\)", 'Connected')
Out[133]:
0     Connected
1    Ended call
Name: Connect, dtype: object

For all replacements together, you can do this:
In [142]: replacements= {'Connect' : {"Connected to call \(audio, video or screen sharing\)" : 'Connected', 'Ended call': 'Ended'}}

In [143]: df.replace(replacements, regex=True, inplace=True)

In [144]: df
Out[144]:
     Connect
0  Connected
1      Ended

Comment: Oh yes I have ! Thank you so much
Comment: ok thank you, is there a way to also replace 'ended call' in the same command?
Comment: Can I upvote two? I thought only one answer could be upvoted?
Comment: Ok I read your comment about the answer, I see what you're saying here. But I am not sure if it is polite to remove vote once it is set


If my air conditioner return line iced over and the fan stopped, is it broken?

Question: We've lived in our house for three summers and have never had any problems with the air conditioner. Today I noticed that there was ice on the coolant return line outside the house. I didn't think anything of it.
Later in the day (now), the system had shut off. Even though the temperature in the house was much higher than the thermostat setting, neither the air blower nor the fan in the AC unit outside was running.
I've read that the ice on the lines may mean that the system is low on coolant. Will simply having the coolant recharged fix the problem? Do I just need to wait for something to thaw?
Comment: How do you know the problem is the motor?  How do you know the problem isn't the controller electronics in the outdoor unit?  If you don't know what you are doing, call an HVAC person.
Comment: Ok, it looks like the iced-over line was a symptom, not the cause. The root of the problem seems to be that the fan is not spinning. I suppose the next steps for me would be to either call a professional or see if I can fix or replace the fan motor. Any thoughts on that?
Answer: ice usually means either your air handler isn't pushing enough air across the coil, or your system is out of refrigerant.
so first step is to set the cool/off switch to off. then set your fan switch to on. if the air handler fan does not turn on, then you have a problem with your air handler or thermostat. possibly cheap. possibly something you can fix yourself.
otherwise, you probably have a problem with refrigerant (which should not deplete, and if it does then you have a leak somewhere) or your compressor. in either case, you should leave your system off to avoid damaging your compressor until someone can come out and look at it.
Answer: I would check airflow. Have you closed and air vents, is any furniture blocking vents, has any work been done to the ducts, is the filter dirty, is the evaporate coil dirty, is the blower wheel dirty, is the blower spinning at the right speed. Once those things have been confirmed, THEN you check your refrigerant. 70% of the service calls for iced evaporators are from dirty filters/ restricted airflow AND/OR low on charge. Also check for any restrictions in the liquid line (small copper) such as a pinch or Kink. Feel if the line is hot before the kink and cool after. Service and Maintenance are generally based on how good your observations are.
Answer: A frozen suction line is generally more indicative of poor evaporator coil airflow rather than being low on charge.
Before you jump into checking pressures or troubleshooting the furnace/condenser controls, check to make sure your furnace fan is providing proper airflow, the filter is clean and the coil(s) are clean.
Answer: This is a long shot but check your electrical panel and make sure the circuit breaker for the air conditioner is not tripped.  I think the air conditioner unit will be on its own circuit separate from the blower that circulates air throughout your house (at least that is how it is set up in my house).  If the air conditioner circuit is tripped, then the AC unit will not go on but still you will be hearing your blower and think everything is working.
Comment: Your assumption is correct - the condenser unit is powered separate from the air handler.  There is normally a fused disconnect outside for the condenser fed from a its own breaker from the main panel.  However, if the condensing unit lost power (either breaker trip or fuse(s) blown) you won't get the symptoms OP described (icing).
Answer: My problem was a bad run capacitor for the blower, With the air handling unit fan (blower) not running properly this caused my suction line to freeze up.


start angular function without click?

Question: I have a function in angular:
$scope.getSessionsForSpeaker = function (id) {
    $scope.id = id;
    $scope.getAll = SessionService.getAll();
    $scope.sessionsFound = [];
    $scope.getAll.$promise.then(function(data) {
        for (var i = 0; i < data.length; i++) {
            if ([data[i].speakers[0]] == $scope.id) {
                console.log([data[i].subject]);
                $scope.sessionsFound += [[data[i].subject] + ", "];
            }
        }
    });
};

and from html i run it by clicking a link:

Is there a way to run this function without clicking? Thank you in advance!!
Comment: Just call it - after declaration add `$scope.getSessionsForSpeaker()`
Comment: What should be `speaker.id` in that case ?
Comment: You can do plenty. Do you want to call it on some event or from your code? You want it to run on when controller/link function runs etc.?
Comment: @Alexander is right. And you need to pass an `id `.
Comment: Chris, I want it to run when my page loads, or when I access a certain controller.
Answer: You can run it from your controller if you know the ID:
$scope.getSessionsForSpeaker(id);

You can use ng-init to run it when that element loads:

You can also use ng-mouseover if you want to run it when the mouse is over that element

All depends when you want to run it.
Comment: He can run it from anywhere he likes, I have no idea how he wants to run it, so I've presented him with every choice I could think of.
Comment: What's the point in creating a $scope method if a given function will only run in constructor function and will not get exposed as view model property?
Comment:  doesn't seem to work.
Answer: I found a solution that worked for me:

Thanks to everyone for contribution!

start angular function without click?


identify an instance in drag-and-drop

Question: I try hard to understand how to identify an instance of a class within drag and drop, but i need some help.
Beneath I add a sample from "http://zetcode.com/gui/pyqt5/dragdrop/" to explain.
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
ZetCode PyQt5 tutorial

In this program, we can press on a button with a left mouse
click or drag and drop the button with  the right mouse click.

Author: Jan Bodnar
Website: zetcode.com
Last edited: August 2017
"""

from PyQt5.QtWidgets import QPushButton, QWidget, QApplication
from PyQt5.QtCore import Qt, QMimeData
from PyQt5.QtGui import QDrag
import sys

class Button(QPushButton):

    def __init__(self, title, parent):
        super().__init__(title, parent)

    def mouseMoveEvent(self, e):

        if e.buttons() != Qt.RightButton:
            return

        mimeData = QMimeData()

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(e.pos() - self.rect().topLeft())

        dropAction = drag.exec_(Qt.MoveAction)

    def mousePressEvent(self, e):

        super().mousePressEvent(e)

        if e.button() == Qt.LeftButton:
            print('press')

class Example(QWidget):

    def __init__(self):
        super().__init__()

        self.initUI()

    def initUI(self):

        self.setAcceptDrops(True)

        self.button = Button('Button', self)
        self.button.move(100, 65)

        self.setWindowTitle('Click or Move')
        self.setGeometry(300, 300, 280, 150)

    def dragEnterEvent(self, e):

        e.accept()

    def dropEvent(self, e):

        position = e.pos()
        self.button.move(position)

        e.setDropAction(Qt.MoveAction)
        e.accept()

if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = Example()
    ex.show()
    app.exec_()

Here my questions:
if I instantiate a 2nd button
    self.button2 = Button('Button2', self)
    self.button2.move(100, 165)

i can also move the button2, but in the DropEvent the first button "button" is moved.
How is it possible to identify within DropEvent, that I move "button2" und place button2?
So: question is: how to identify, which button it is.
(i found only drag n drop examples, how to replace a label or a button by another element of same type)
And additional question: to create a new instance works with this type of code. If I create the buttons within QT5 designer, it is not possible to have them as an instance of this type of class Button in this code.
So, defining drag n drop in the QT5 designer, drag n drop of an item within a list to another list works, but i am not able to identify, which element I have dragged
Answer: If the object you are dragging from is a QWidget then you can get it through the QDropEvent source() method, and the QPushButton is a QWidget so it works in this case:
def dropEvent(self, e):
    if e.source() is not None:
        position = e.pos()
        e.source().move(position)
        e.setDropAction(Qt.MoveAction)
        e.accept()

Remember to verify that it is not None since the source may be another window that is not a QWidget so you would get an exception

If you want the buttons added through Qt Designer you want them to have the same functionality then the easiest solution is to promote the buttons, there are many examples in SO where they show how to do it:

Clear QLineEdit on click event
How to insert video in ui file which made at qt designer?
Painting in a QLabel with paintEvent, etc
Comment: this helps me to understand the source. The other way round, I have a source and several buttons from the same class, where i can drop the source, how can i then get the destination similar to e.source? is there something like e.destination? (i know, there is no destination in the documentation?
Comment: @user3367867 The dragEnterEvent method are those that indicate whether an element can be dropped.
Answer: You are always using self.button in your drop event, so it refers to the same button. Instead you can use QDropEvent.source() to get the correct widget.
def dropEvent(self, e):
    position = e.pos()
    e.source().move(position) # source widget

    e.setDropAction(Qt.MoveAction)
    e.accept()

identify an instance in drag-and-drop


Strings defined in strings.xml not displayed in "Resource chooser" in graphical layout (main.xml)

Question: Using this tutorial at section 5.5, I attempted to "Assign the 'celsius' string attribute to the 'text' property of the first radio button and "fahrenheit" to the second"
The "Resource Chooser" (called, by mistake (?), "Reference chooser" in the above article) is displayed but...I can choose only between two strings : "app_name" and "hello". "celsius" and "fahrenheit" attributes are not proposed.
How do you solve this issue?
Answer: In the res/values folder should be an XML file called strings.xml When you open this you will see the values you referred to ("app_name" and "hello"). Make an entry similar to them like this:
<code><string name="celsius">Celsius</string>
</code>
You could just hard code the text into the text property you are referring to but Android provides this way to store strings of text in an XML file so that they can be 1) easily found in one spot and 2) easily translated if required later. So it is recommended to do it "the Android Way." This is explained in section 5.3 of the tutorial you linked to.
Now you should be able to reference them by the element name (celsius) as you were trying to.
Comment: Thanks a lot for your useful answer. Actually, I found ths issue... The strings.xml file has to be SAVED once modified in order to have its modifications taken into account ! Sorry for my stupid question, I am (really) new at Android... (first day !) 1.5 year on iOS...not easy to restart from 0 !
Comment: hehe yeah I believe I've done that a least once along the way. Good luck and welcome!
Answer: The strings.xml file has to be SAVED once modified in order to have its modifications taken into account !


Mysql Driver not loaded on Qt5.4 OS X Yosemite

Question: I just did a fresh install of Yosemite on my mac.
Installed Xcode, Qt5.4and mysql CE
I'm unable to make my app to work, I always get
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

I checked the dylib :
otool -L /Users/myself/Qt/5.4/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

and this returns me :
libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
    /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /Users/myself/Qt/5.3/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.3.0, current version 5.3.2)
    /Users/myself/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.2)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

I did not have the /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib file, in fact I do not event have the /opt folder on my Yosemite mac.
Can this be?
I tried recreating the /opt/local/lib/mysql55/mysql/ folder myself and added the libmysqlclient.18.dylib in it but I still get the same issue.
I'm now completely clueless about how to resolve this, Am I doing something wrong? is this a Yosemite vs MySQL bug?
I think my .pro file and sources are ok as this used to work under my previous Mavericks config.
Comment: Did you ever get it working?
Comment: Yes, I just removed everything related to Qt and did a fresh reinstall, worked out of the box with the updated version, never knew what the issue was.
Answer: I know this is an old question, but I thought I'd share the solution I found (for those whose problem isn't solved by a fresh install).
Search your machine for libmysqlclient.18.dylib, and find where there is actually a copy of this file (mine was in /usr/local/Cellar/mysql56/5.6.32/lib/).  Then use the install_name_tool command with the -change flag to point your libqmysql.dylib at it. Example of command use below:
install_name_tool -change /incorrect/path/to/libmysqlclient.18.dylib /correct/path/to/libmysqlclient.18.dylib /path/to/libqsqlmysql.dylib
Make sure to run the same command for the debug version, libqsqlmysql_debug.dylib so your debug builds are pointed to the correct lib as well.


Finding one power wire to two lite switches. ugh!

Question: I bought this house one year ago, have had some problems with its electrical. My bathroom switch controls bathroom clothing closet light and the bathroom light. I notice it really sounded funny at times like a short buzz when I would flip them on.
I asked around and was told probably switch needs changing out sounded like it was arking.
so I bought a couple of switches to change it out. When I got the switch off, I noticed one wire with insulation cut to bare and hook to one switch and then the end of same wire connected to the other switch.
So I had one wire connecting both in a rough fashion. I disconnected it from the closet switch as I can manage without that for a while and then wrapped the bare spot with electrical tape then attached it back to the one switch for the bathroom light.
Now of course the closet light doesn't work but the bathroom light does and you don't get that buzz when you flip it.
So Im thinking this wasn't a good wiring but I do not see another power wire available although there are a lot of wires in that box.
Can someone tell me a safe way of connecting that one wire to both switches so my lights work but I don't have that arc?
I am a female diyer...Ive installed ceiling fans and stuff cuz its color coded...but every wire in this box is either white or black and there is one copper looking wade in there too.
thanks
Comment: Please add a photograph, and maybe fix up some of your sentences, it will help make things much more clear.  The bare wire connected to two switches is a ground.  Based on what I see so far you need to contact a qualified electrician.
Comment: Your instincts sound good, but your experience sounds limited. Given the bad wiring and the complexity of the box, I think you really would be better off calling in a pro (either an experienced electrical DIYer or an electrician). You need testing as well as wiring.
Answer: I think I know what's going on here, the solution is simple if the situation is as I understand it. I'll go over it again as confirmation.
The butchered wire should be the unswitched power from source that continues through the two switches, one for each light in turn, then on to the lights, then return via neutral. If you're in North America and the usual color codes were followed, this wire should be black. (Neutrals are white)  The original configuration had a short length of insulation stripped from the end and attached to a switch (closet?). A few inches away, the same wire had a length of insulation stripped, but with insulation left in between the stripped portions. The copper wire itself remained continuous, the non-end bare portion looped partly around the binding screw of the other switch (bathroom?). See sketch below "Original". Only the pertinent wiring is shown, all other wiring omitted for clarity.
You then taped up the inner stripped portion and reinstalled the wire end to one switch, leaving the other without power. Correct?
If so, this is a somewhat common bad practice, mainly because the unbroken partial loop cannot be properly bound to the terminal. The fix is easy. You need a wire nut sized for 3 conductors of whatever wire gauge is used (usually #12 or #14 AWG) and two short lengths of the same gauge black insulated solid copper wire.
Remove your taped patch and cut the wire so that the entire wire is completely insulated except for the final 5/8"-3/4" which remains bare. (See sketch "Cut") Attach this and the two short pieces (ends stripped in similar fashion) with the wire nut.
The other ends of the short pieces are attached, one per switch, to where the original wire was attached. (See sketch "New") There is a particular way to make binding screw connections which you may not see in the existing work. Do NOT make a simple U bend and hook it around the binding screw, you do not get adequate surface contact this way. (Sketch "NO!")
Instead, pre-bend the wire end into a nearly complete circle, so it is configured much like an eye bolt eye. (Sketch "Yes") Re-open the end gap just enough to slip the binding screw through. The loop must go clockwise around the screw so tightening the screw closes the end gap. Before tightening the screw, pre-close the gap as best you can with needle nose pliers. Firmly tighten the binding screw and it will draw the gap the rest of the way closed.
You can see electrically you have the exact same situation, but now you have used good quality methods to achieve the connections.
Comment: I like the sketches.
Comment: :) thx! I have access to all sorts of digital tools, still nothing like a quick freehand sketch to illustrate an idea.
Comment: There is nothing wrong with the first wiring method, as long as all the screw terminals are tightened properly.


Cloud function to convert a base64 string to zip and extract the contents

Question: I am currently trying to convert a base64 string to a zip file and then extract it.

Can you just decode a base64 string and then "save it" to whatever format you want and it will take or do you need to do it in different ways.

for example would decoding a base64 string to pdf and zip file be completly different process.

Are there any node libraries that help with these?
Comment: base64 doesn't care about the content. It just encodes bytes. When you know it's a zip, then save it as a zip file, when you know it's a pdf, save it as a pdf.
Answer: base64 is just a data encoding format. Whatever input data you encoded as base64, will come out on the other side when you decode it. So the process for encoding/decoding the file contents as base64 is the same, no matter what the file type is.
Asking for a recommendation of a node.js module to help with encoding/decoding is off-topic on Stack Overflow, but if you do a quick google search I'm quite sure multiple good options will show up, such as this highly upvoted answer: How to do Base64 encoding in node.js?
Comment: Thank you for the explanation. I have not used base64 strings in detail before. And I have been trying a few libraries for this over the past weeks with no results. I will try be more specific in future. again thank you for helping