text:
Q: Run matlab command line and automate running unix server bjobs I'm running a chunk of matlab code called fit.m this way,
clear all;
load('/pathtomatfile/alldata.mat')
count = rxw1;
count = double(count);
x_cov = ltgbd;

alldata.mat has several data of interest, i.e.,
rxw1
rbg2
rfd1
wop3,
ltgbd,
etc.

I can run such script from the command line for a given data of interest (in my example count=rxw1),
matlab -nodisplay -nojvm -nosplash -r ${pathtoscript}fit -logfile lfile.txt

However, I need to automate the running so I can tell matlab to make count = any of the other datasets in the mat file.  I.e., I'd like to the script in parallel for different datasets but I'd need something like:
matlab -nodisplay -nojvm -nosplash -r ${pathtoscript}fit -logfile lfile.txt DATAOFINTERESTHERE (i.e., rxw1 count will equal rxw1, etc.)

Is it possible to do what I am suggesting?  How would I automate the script to run for any of the datasets I choose by giving the name of the dataset as an input parameter when I call the script?
Once I have that  I plan to actually run them all in parallel by submitting jobs through LSF but giving the name of the data of interest as an input, something like this in mind:
bsub -q week -R'rusage[mem=8000]' \
"matlab -nodisplay -nojvm -nosplash -r ${pathtoscript}fit -logfile lfile.txt DATAOFINTEREST"

Sorry if it's too basic of a Q but I am not familiar with running matlab command line.

A: You can make fit a function, instead of script. The fit function can have a single input variable pointing to the right data file.
Then you can run
matlab -nodisplay -nojvm -nosplash -r "cd ${pathtoscript}; fit('${dataofinterest}');exit;"

EDIT: added this detailed fit fun.
Your fit function should look something like
function fit( variableName )
%
% run fit for a specific variable from the mat file
% variableName is a string, e.g. variableName = 'rgb1';
%

ld = load('/pathtomatfile/alldata.mat');
count = ld.(variableName); % access variables in mat file as struct fields
count = double( count );
% and I believe you can take it from here...

EDIT:
Similar solution loading mat file into a struct to handle the loaded variables
can be found here with some more details.


text:
Q: Ichimoku box - moving moving box on chart (Pinescript)!!
how can moveing box on the chart?!(TNX)
@version=5

indicator("box", overlay = true)

lowest9 = ta.lowest(low, 9)

highest9 = ta.highest(high, 9)

mybox9= box.new(left = bar_index[8], top = highest9 , right = bar_index[0], bottom = lowest9, border_color = color.rgb(59, 241, 99), border_width = 1, border_style = line.style_solid, bgcolor=na)

box.delete(mybox9[1])

redpajama_set_name: RedPajamaStackExchange


text:
Q: Keymaps in Light Table are not working I just started learning Python with "A Byte of Python". I'm currently learning Light Table, the editor that the tutorial suggested.
This may be very amateurish but I have no experience whatsoever and this is all new to me.
I want to open console with cmd-shift-c so this is what my keymap looks like:
{:+ {:app {"cmd-shift-t" [:workspace.show]
           "cmd-shift-c" [:toggle-console]}

I click ctrl+shift+c and nothing happens, even after I save my keymaps file.
My editor commands work, though, when I unindent a line.

A: Since you said you clicked ctrl+shift+c I'm going to guess you're not on a Mac and should probably change your settings. I just tried the same thing as you have on my machine and it doesn't work.
However, changing it to {"ctrl-shift-c" [:toggle-console]} worked fine for me.


text:
Q: Continuity on $[a,b]$ implies uniform continuity on $[a,b]$
I don't understand the step underlined in green.
I understand that for any $n$ , $|f(x_n)-f(y_n)|\geq \varepsilon$ where $x_n, y_n$ satisfy the conditions given regarding a function being not uniformly continuous.
However if say $x_n=\frac{1}{2n}, y_n=\frac{1}{3n} $ then $|x_n-y_n|=\frac{1}{6n}$ and $|f(\frac{1}{2n})-f(\frac{1}{3n})|\geq \varepsilon$
so if we take $n=1$ , $|f(\frac{1}{2})-f(\frac{1}{3})|\geq \varepsilon$
but what if  $|x_{k_n}-y_{k_n}|\geq\frac{1}{n}?$

A: Your problem stems from the somewhat unfortunate circumstance that the author denotes a subsequence of the sequence $(x_n)_{n\geq1}$ by $(x_{k_n})$ instead of
$(x_{n_k})_{k\geq1}$.
He  begins with two sequences $(x_n)_{n\geq1}$, $(y_n)_{n\geq1}$ behaving badly insofar as $|f(x_n)-f(y_n)|\geq\epsilon_0$ for all $n$, even though $|x_n-y_n|\to0$ as $n\to \infty$. In order to be able to invoke the continuity of $f$ we'd like to   have all $x_n$, $y_n$ near some point $\xi\in[a,b]$. Bolzano's theorem guarantees that there is some  $\xi\in[a,b]$ such that "infinitely many" $x_n$, $y_n$ are in the immediate neighborhood of $\xi$. To be exact: There is a selection function $$\sigma:\quad{\mathbb N}\to{\mathbb N}, \qquad k\mapsto n_k$$
such that the "good" $x_n$, namely the selected $x_{n_k}$ $\>(k\geq1)$, actually converge to $\xi$. It is then easily seen that
$$\lim_{k\to\infty} x_{n_k}=\lim_{k\to\infty} y_{n_k}=\xi\ .$$
Since $f$ is continuous at $\xi$ this implies
$$\lim_{k\to\infty} \left(f\bigl(x_{n_k}\bigr)-f\bigl(y_{n_k}\bigr)\right)=f(\xi)-f(\xi)=0\ .$$
On the other hand, we have $|f(x_n)-f(y_n|\geq\epsilon_0$ for all $n$, good or bad, so that we arrive at a contradiction.

A: Complete Proof:
To obtain a contradiction assume that $ f $ is not uniformly continuous on $ [a,b] $. Then there exists $ \epsilon _{0}>0 $ such that for any $ \delta >0 $, there exist $ x_{\delta},y_{\delta}\in [a,b] $ such that $ \vert x_{\delta}-y_{\delta}\vert <\delta $ and $ \vert f(x_{\delta})-f(y_{\delta})\vert \geq \epsilon _{0} $.
Therefore for any $ n\in \mathbb{N} $, there exists $ x_{n},y_{n}\in [a,b] $ such that $ \vert x_{n}-y_{n}\vert <1/n $ and $ \vert f(x_{n})-f(y_{n})\vert \geq \epsilon _{0} $. (A)
Since for any $ n\in \mathbb{N} $,  $ x_{n}\in [a,b] $ we have $ (x_{n}) $ is a bounded sequence. Then by Bolzano-Weieistrass theorem, $ (x_{n}) $ has a convergent sub sequence $ (x_{n_{k}}) $. Then there exists $ u\in \mathbb{R} $ such that $ (x_{n_{k}}) $ converges to $ u $.($ u\in [a,b] $ since $ [a,b] $ is complete)
Now we need to show $ (y_{n_{k}}) $ also converges to $ u $.
Let $ \epsilon >0 $ be given. Then there exists $ K_{\epsilon}\in \mathbb{N} $ such that for each $ k>K_{\epsilon} $, $ \vert x_{n_{k}}-u\vert <\dfrac{\epsilon}{2} $. Observe that there exists $ K_{0}\in \mathbb{N} $ such that for each $ k>K_{0} $, $ n_{k}>\dfrac{2}{\epsilon} $. Choose $ K=\max \{K_{\epsilon},K_{0}\} $. Now let $ k>K $. Then $$ \vert y_{n_{k}}-u\vert =\vert y_{n_{k}}-x_{n_{k}}+x_{n_{k}}-u\vert \leq \vert y_{n_{k}}-x_{n_{k}}\vert + \vert x_{n_{k}}-u\vert <\dfrac{1}{n_{k}}+\dfrac{\epsilon}{2} < \dfrac{\epsilon}{2}+\dfrac{\epsilon}{2}=\epsilon .$$ Therefore $ (y_{n_{k}}) $ converges to $ u $.
Since $ f $ is a continuous function on $ [a,b] $ we have that both sequences $ f(x_{n_{k}}) $ and $ f(y_{n_{k}}) $ converge to $ f(u) $. Then obviously the sequence $ (f(x_{n_{k}})-f(y_{n_{k}})) $ converges to $ 0 $.
Hence there exists $ K_{\epsilon _{0}}\in \mathbb{N} $ such that for each $ k>K_{\epsilon _{0}} $, $$ \vert f(x_{n_{k}})-f(y_{n_{k}})-0\vert = \vert f(x_{n_{k}})-f(y_{n_{k}})\vert < \epsilon _{0}. $$  Now substitute $ {n_{k}} $ for $ n $ in the statement (A). Then we have that $$ \vert f(x_{n_{k}})-f(y_{n_{k}})\vert \geq \epsilon _{0}. $$ But this is a contradiction and hence $ f $ is uniformly continuous on $ [a,b] $. $ \square $
Note : Since $ f $ is a continuous function on $ [a,b] $, the only thing we can say is there exists $ \epsilon _{0}>0 $ such that for any $ n\in \mathbb{N} $, there exist $ x_{n},y_{n}\in [a,b] $ such that $ \vert x_{n}-y_{n}\vert <1/n $ and $ \vert f(x_{n})-f(y_{n})\vert \geq \epsilon _{0} $. Therefore you can't put $ x_{n}=\dfrac{1}{2n} $ and $ y_{n}=\dfrac{1}{3n} $ and like this. Actually it is not needed for the proof.


text:
Q: Mechanical equivalent of heat => transfer from work $W$ to heat $Q$ Consider the following experiment to determine the mechanical equivalent of heat $\mu = \frac{\Delta W}{\Delta Q}$

Not seen in the picture is a weight with a known mass hanging down the cord. When you start cranking, you compensate the weight force $F_G$ with the friction $F_F$. Its value is the difference of $F_G$ and the force held by the dynamometer.
One can calculate the work put into the system via $\Delta W = F_F \cdot\Delta s = (F_G - F_D) \cdot 2\pi rn$, with $r$ the cylinder radius and $n$ the number of revolutions. (you don't have to consider vectors calculating $\Delta W$, because $F_F$ and $s$ always point to the same direction $\Rightarrow$ $\phi = 0 \Rightarrow \cos(\phi) = 1$)
By measuring the temperature, one can obtain $\Delta Q = C_{total}\cdot\Delta T$.
To the questions. What are the possible outcomes for $\mu$? In an idealized case, where no energy gets lost/dissipated, one can clearly assume $\mu = 1$. What's the meaning behind $\mu > 1$ and $\mu < 1$?
My ideas and assertions:

*

*In a closed, ideal system, one can completely transfer all mechanical energy $W$ in heat energy $Q$

*One cannot transfer all heat $Q$ back into $W$ (Perpetuum mobile 2nd kind)

This yields, $\Delta Q$ must always be greater than $\Delta W$, because you can't transfer everything into mechanical work $\Rightarrow \mu \leq 1$. But, viewed the other way round, if $\Delta W$ is less than $\Delta Q$, where does the energy to raise $Q$ come from? The cylinder is in thermal equilibrium with the room temperature before one starts to crank, so there is no input from another warmth bath.

A: First, I should say that $\Delta W$ and $\Delta Q$ don't have meaning. $\Delta$ exists for state functions, but work and heat are path functions. A system doesn't have heat or work. Heat and work are recognized when they are transmitted through system's boundary.
Second, the correct equation is $\Delta U=mC\Delta T$. So, I assume that you want to determine $\large{\frac W{\Delta U}}$

What's the meaning behind $\mu\gt1$ and $\mu\lt1$?

$\mu\gt1$ means some portion of work has been used for another purpose (for example, increasing surrounding temperature) except increasing the internal energy of your sightly system.
$\mu\lt1$ means the system has received some heat from surrounding.

In a closed, ideal system, one can completely transfer all mechanical energy $W$ in heat energy $Q$
One cannot transfer all heat $Q$ back into $W$ (Perpetuum mobile 2nd kind)

I cannot understand what is the $Q$. As I mentioned a system doesn't have heat. During the first experiment, work is converted to internal energy of the system. Now, there is no heat here. System has a internal energy bigger than its initial state.


text:
Q: VPN Windows 2012 r2 Resources (share drivers or rdp connection) not available after connection I hope everyone is keeping safe!!. I was wondering if I can get some pointers into an issue that I have been experiencing for a day or so now. I am trying to implement a VPN solution so that people now working from home can access some very specific share drivers and also being able to rdp to their own machines.
The server has been running for years and it has two NICs, but the nicss are for redundancy and balance only (both nics are connecting to the firewall and router facing the internet, please do not kill the messenger, that is how it has been working for ages and no it was not me).
I followed the instructions in order to install the VPN Routing and Remote Access. I also implemented the Network Policy Server to allow MS-Chap V2 (extensible authentication protocol (EAP)) connection.
I started the service and it seems working fine as I can VPN to the machine from the wan outside, the laptop obtain the "correct" IP from the dhcp server and I can see the laptop in the remote Access clients, however I can not access the share drivers (they have a red x on the drive and upon click I get the "An error occurred while reconnecting..." and also RDP to the local machines takes me no where. I believe the setup is okay but I also think I am missing a route somewhere or setting. I have been reading everywhere and change lots of the setup including adding the Ipv4 router (Local are network(LAN) routing only), etc, etc but no Joy, also I have to admit that routing and routes are not my strong point hence I am a bit loss.
Any help will be appreciated.
(below some screenshots of what I think can be useful infor but please let me know if you need more )

ip-routing in both nics looks like

the routing in the laptop looks like

Any help will be greatly appreciated!!!

A: I ended up deleting the whole Remote Control and reinstall, that somehow did the trick


text:
Q: TFS Custom Build Template - Value Description I have gotten a custom form and category and all that working perfectly in my build definitions. The only thing I cannot seem to figure out is how to set the description to what I want it to be.
For example, in the default template (under Build process parameters) there is a section called Automated Tests. In the description value column it says 'Run tests in assemblies matching **\ test.dll'.
How do I control this text for my own properties?
CLARIFICATION (example of what I am referring to):

*

*Create a new build definition using the default template.

*Go to the Process tab and add some projects (or a solution with some projects).

*Observe that the text next to 'Items to build' is now bold and says something like 'Build 4 project(s) for 1 platform(s) and configuration(s).

The description verbiage in step 3 depends on the number of projects, platforms, etc.
This is what I am after. In my custom template I am able to get the custom dialogs working for my custom parameters BUT the description just has the full assembly name of the dialog object. I would like to customize the text there.

A: You will need to open the Build process file and edit it's variables and arguments,


text:
Q: Static variable set, but not gettable - Class loading issue ( possibly?) This is very strange to me:
1) I have a class
public class Data {
    private static String name;

    public static String getName() {
        return name;
    }

    public static void setName (String n){
        Data.name = n;
    }
}

this class variable name is set correctly during my server ( J2EE app in WAS liberty) startup - I wanted to cache this data during the whole server lifecycle.
2) but when I hit an URL that eventually invokes a code that does a getter:
Data.getName(); // this returns null??

Can anyone think of a possible reason? Not be able to debug also, I am very frustrated.

To illustrate my problem more, let me show my project structure:
EAR
CommonJar
WAR1         WAR2
My Data.java is in CommonJar. This Data.java is initialized in WAR1 during the server startup triggered by a Listener registered in web.xml, and from here I saw it is set and I saw the non-null value using Data.getName().-- this is my step 1 in my original post.
Then I have a restful HelloWorld Service in WAR2. And when I call into this HelloWorld service, I see Data.getName() returns null. -- this is my step 2 in my original post. Don't even think anything like syntax type of easy error, because it is not that.
My theory is: it seems that Data.java is loaded by classloader in WAR1 in step 1 and then WAR 2 in my step 2, and Step 2 loaded an empty Data class.
To verify if this theory is correct, I moved Data.java initialization step into the WAR2, (and again I saw it is set and I saw the non-null value using Data.getName()), the difference is that when I call into this HelloWorld service, I saw Data.getName() returns the expected non-null value. This step is what I call my troubleshooting breakthrough because it seems to indicate my theory was correct. (but I can't fix the issue by moving the code in my real problem fix)
Then the question is how to fix and how to visually see which class is loaded by which class loader and when? Also based on WAS Liberty doc, the default class loader will be parentsfirst, which means Data.java should be loaded by the parent ( in this case, EAR), so I shouldn't have my problem the first place.
Anyone, please guide how to further to see the problem and fix it? Thanks.

A: Your getName() function is declared with no return type, yet attempts to return a string.

A: try out this one
public class Data {

    public static void main(String... args) {
        System.out.println("setting name 'Stack Overflow'");
        Data.setName("Stack Overflow");
        System.out.println("now getting the setted name");
        System.out.println(Data.getName());
    }

    private static String name;

    public static String getName() {
        return name;
    }

    public static void setName(String n) {
        Data.name = n;
    }
}

Output:

setting name 'Stack Overflow'
now getting the setted name
Stack Overflow

In your code, you defined no return types to your methods.


text:
Q: How can I harden input used with preg_match/replace regex? I am working with a PHP script that finds
var $_plgCode       = "#{comment(.*?) contentid=(.*?) option=(.*?) contenttitle=(.*?)}#i";

and then later uses this in:
preg_match_all($this->_plgCode, $_body, $matches);

and
$_body = preg_replace($this->_plgCode, $output, $_body);

The problem is that contenttitle can contain user input and hasn't been hardened at all - so lots of things will break it, like if a user enters }, for example.
What kind of escaping of user input needs to be done on the contenttitle to ensure it doesn't break the REGEX?

A: Use preg_quote


text:
Q: is this python error due to Syntax or program-specific error Newbie to python here, learning it as I go along because our new ERP uses it.
I'm making a custom warning to which I have put together the following output;
'Check the Opportunity stage is at "Prospect-Quoted!"' + ('\n\n If this quote value is different from previous quotes, remember to also update the Opportunity value.' if any([i.id for i in obj.sale_order_ids]))

For context, this is when raising a quote against a CRM opportunity, I want to remind the user to update the saved opportunity value if there are other quotes linked to the opportunity (obj) from which this is being called.
I'm confident based on the system's Dynamic Values Builder that the section any([i.id for i in obj.sale_order_ids]) is correct, and the if statement is structured the same as others elsewhere in the system, but when attempting to save the custom warning I get an error message saying

Cannot evaluate Warning. Error: unexpected EOF while parsing (, line 1)

Can someone more experienced tell me, is this a problem with my syntax or more likely to be a program-specific problem?

A: When doing this kind of syntax, with inlined if, you must always specify an else statement :
str1 = 'Check the Opportunity stage is at "Prospect-Quoted!"'
str2 = '\n\n If this quote value is different from previous quotes, remember to also update the Opportunity value.'
result = str1 + (str2 if any([i.id for i in obj.sale_order_ids]) else "")


text:
Q: Harmonic function function on annulus I want to find $\phi(x, y)$ that is harmonic in the washer $\{z \in \mathbb{C}: 2 \leq|z-1-i| \leq 3\}$ and satisfies the boundary conditions $\phi(x, y)=5$ for $|z-1-i|=2$ and $\phi(x, y)=6$ for $|z-1-i|=3$.
I  convert this into PDE problem, but i don't think it is right method. Can someone help .

A: The Laplacian in cylindrical coordinates is
$$
            \nabla^2f(r,\theta)=\frac{\partial^2f}{\partial r^2}+\frac{1}{r}\frac{\partial f}{\partial r}+\frac{1}{r^2}\frac{\partial^2f}{\partial\theta^2}.
$$
If $f$ is a function of $r$ only, then
$$
              \nabla^2 f(r)=\frac{d^2f}{d r^2}+\frac{1}{r}\frac{d f}{d r} = \frac{1}{r}\frac{d}{d r}\left(r\frac{d f}{d r}\right).
$$
So $f(r)$ is a solution of the Laplace equation if there are constants $C,D$ such that
$$
                r\frac{df}{dr}=C \\
                  f=C\ln(r)+D.
$$
If $f(r)$ satisfies
$$
     f(2)=5,\;\; f(3)=6,
$$
this determines $C$ and $D$, and gives a final solution
$$
                  \phi(x,y)=f(|(x,y)+(1,1)|)
$$

A: You have the boundary condition $\phi$ is constant on $\lvert z-(1+i)\rvert$ constant, so an obvious choice is $\phi(z)=\alpha\log\lvert z-(1+i)\rvert+\beta$, some real constant $\alpha$, since this is $\operatorname{Re}[\alpha\log(z-(1+i))+\beta]$ locally the real part of a holomorphic function.


text:
Q: Let $0Assignment:

Let $0<a<b$. Calculate $$\int_{(0,1)}\frac{t^b-t^a}{\ln(t)}dt$$

I'd appreciate a little help with this one. A hint says that rewriting $t^b-t^a$ as an integral should help, but I don't see how.

A: By the fundamental theorem of calculus, $F(b) - F(a) = \int_a^b F'(x)\,dx$.  Take $F(x) = t^x$.  Then consider changing the order of integration (Fubini's theorem).

A: Note that $t^b-t^a=\exp(b\log(t))-\exp(a\log(t))$ for fixed $t\in(0,1)$.
Hence: $$t^b-t^a=\int_a^b \log(t)\exp(x\log(t))dx$$
Thus:
$$\int_{(0,1)}\frac{t^b-t^a}{\log(t)}dt=\int_{(0,1)}\int_{(a,b)}\exp(x\log(t))dxdt$$
I think, this is computable using Tonelli's Theorem.

A: What they mean is:
$$\int_{x=a}^{b}{\ln{t}*t^{x}dx}=t^x\vert_a^b = t^b-t^a$$
Is that enough to get you started?


text:
Q: Enabling PEP on ejabberd server I'm creating a chat app using the Electron Framework and node-xmpp module for XMPP communication.
I have managed to do almost everything except making Personal Eventing Protocol to work. Specifically sending a new nickname to the roster.
When I send the PEP stanza
<iq from='test@localhost' type='set' id='pub1'>
  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    <publish node='http://jabber.org/protocol/nick'>
      <item>
        <nick xmlns='http://jabber.org/protocol/nick'>I am a test user</nick>
      </item>
    </publish>
  </pubsub>
</iq>

I get a response IQ stanza:
<iq from="test@localhost" type="result" to="test@localhost/testapp" id="pub1">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <publish node="http://jabber.org/protocol/nick">
      <item id="5D4E0BB8EB3C6"/>
    </publish>
  </pubsub>
</iq>

Now, according to XEP-172 example  6 I should get a Message with the nickname that is also sent to all my contacts. It should look like this:
<message from='test@localhost' to='otheruser@localhost' type='headline' id='foo'>
  <event xmlns='http://jabber.org/protocol/pubsub#event'>
    <items node='http://jabber.org/protocol/nick'>
      <item>
        <nick xmlns='http://jabber.org/protocol/nick'>I am a test user</nick>
      </item>
    </items>
  </event>
  <addresses xmlns='http://jabber.org/protocol/address'>
    <address type='replyto' jid='test@localhost/chatapp'/>
  </addresses>
</message>

The thing is I'm not getting any message to other contacts in the user's roster. Not even to myself.
Is there any step I'm missing to enable PEP on a ejabberd server? Any extra stanza or information I should include?
Thanks!

A: If you want to receive other users' nickname events you should include http://jabber.org/protocol/nick+notify string into your Entity Capabilities list.
See Filtered notifications for detailed description.


text:
Q: Override Function in Member Object Disclaimer: I'm a long time C programmer moving into C++, so it's very likely/possible there is a better way to do this.
I would like to create a class A with 1 to N members of class B.  In most cases, I'm fine calling class B's member functions.  However, in some cases I would like to override a member function in class B.  Is there an elegant way to do this without having to create a derived class from class B every time?
Here is an example:
using namespace std;
#include <iostream>

class B
{
public:
    void print();
};

void B::print()
{
    cout << "B::print" << endl;
}

class A
{
public:
    B b;
    B bprime;
};

int main()
{
    A a;
    a.b.print();
    a.bprime.print();
    return 0;
}

Is there a way to override the print() function in bprime or otherwise change it?  In C, I would have left class B as a struct and used function pointers, but I'd like to avoid that here.

A: You can use std::function to simulate polymorphism.
class B
{
    public:
    std::function<_FUNCTION_SIGNATURE_HERE_> print;
};

then you can always override print member in an instance of B
   a.bprime.print = SomeOTherFunctionWithSameSignature;

and from this moment on bprime will behave as if it was a different subclass in a hierarchy. Everything will work the same, except this particular function you changed.
Of course you will have to set initial behavior of print member in your constructor.


text:
Q: How to implement a 'handle remaining' observer using reactive extensions I have an IObservable<string> and several observers that handle strings based on some condition:
observable.Subscribe(s => { if (s.StartsWith("a")) {...} });
observable.Subscribe(s => { if (s.StartsWith("b")) {...} });
observable.Subscribe(s => { if (s.StartsWith("c")) {...} });
observable.Subscribe(s => { if (s.StartsWith("d")) {...} });
....

This is a simplified example (the condition is more complex and the observed events aren't strings) but you get the idea.
I'd like to have an IObserver<string> that catches all strings that are not handled by any other observer. Observers with different conditions (i.e.: StartsWith("e")) can be added at any time and the set of conditions does not overlap.
Is this scenario somehow supported? Or do I have to mark observed strings as handled and subscribe to unhandled strings once all other observers have tried (and how do I implement that)?

A: I've got two approaches.
The first provides a way to chain together the predicate/action pairs to "syphon" off values that match. It follows the Rx operator style.
I can write this:
observable
    .Syphon(s => s.StartsWith("a"), s => { })
    .Syphon(s => s.StartsWith("b"), s => { })
    .Syphon(s => s.StartsWith("c"), s => { })
    .Syphon(s => s.StartsWith("d"), s => { })
    .Subscribe(s => { /* otherwise */ });

If I have this extension method:
public static IObservable<T> Syphon<T>(
    this IObservable<T> source,
    Func<T, bool> predicate,
    Action<T> action)
{
    if (source == null) throw new ArgumentNullException("source");
    if (predicate == null) throw new ArgumentNullException("predicate");
    if (action == null) throw new ArgumentNullException("action");
    return Observable.Create<T>(o =>
        source.Subscribe(
            t =>
            {
                if (predicate(t))
                {
                    action(t);
                }
                else
                {
                    o.OnNext(t);
                }
            },
            ex =>
                o.OnError(ex),
            () =>
                o.OnCompleted()));
}

It doesn't allow you to add and remove predicate/action pairs on the fly, but it is a fairly simple operator that might be useful.
To have the full add/remove functionality I have come up with this approach:
Func<Func<string, bool>, Action<string>, IDisposable> add;

observable
    .Syphon(out add)
    .Subscribe(s => { /* otherwise */ });

var startsWithA = add(s => s.StartsWith("a"), s => { /* a */ });
var startsWithB = add(s => s.StartsWith("b"), s => { /* b */ });
startsWithA.Dispose();
var startsWithC = add(s => s.StartsWith("c"), s => { /* c */ });
var startsWithD = add(s => s.StartsWith("d"), s => { /* d */ });
startsWithC.Dispose();
startsWithB.Dispose();
startsWithD.Dispose();

The .Syphon(out add) extension method overload allows the method to effectively return two results - the normal return value is the IObservable<T> and the second comes out as a Func<Func<T, bool>, Action<T>, IDisposable>. This second return value allows new predicate/action pairs to be added to the syphon operator and then removed by calling Dispose on the returned subscription - very Rx-ish.
Here's the extension method:
public static IObservable<T> Syphon<T>(
    this IObservable<T> source,
    out Func<Func<T, bool>, Action<T>, IDisposable> subscriber)
{
    if (source == null) throw new ArgumentNullException("source");

    var pas = new List<Tuple<Func<T, bool>, Action<T>>>();

    subscriber = (p, a) =>
    {
        lock (pas)
        {
            var tuple = Tuple.Create(p, a);
            pas.Add(tuple);
            return Disposable.Create(() =>
            {
                lock (pas)
                {
                    pas.Remove(tuple);
                }
            });
        }
    };

    return Observable.Create<T>(o =>
        source.Subscribe(
            t =>
            {
                Action<T> a = null;
                lock (pas)
                {
                    var pa = pas.FirstOrDefault(x => x.Item1(t));
                    if (pa != null)
                    {
                        a = pa.Item2;
                    }
                }
                if (a != null)
                {
                    a(t);
                }
                else
                {
                    o.OnNext(t);
                }
            },
            ex =>
                o.OnError(ex),
            () =>
                o.OnCompleted()));
}

I tested the code with this:
var xs = Observable.Interval(TimeSpan.FromSeconds(0.2));

Func<Func<long, bool>, Action<long>, IDisposable> subscriber;
xs
    .Syphon(out subscriber)
    .Subscribe(x => Console.WriteLine(x));

var divBy3 = subscriber(
    x => x % 3 == 0,
    x => Console.WriteLine("divBy3"));

Thread.Sleep(2000);

var divBy2 = subscriber(
    x => x % 2 == 0,
    x => Console.WriteLine("divBy2"));

Thread.Sleep(2000);
divBy3.Dispose();
Thread.Sleep(2000);
divBy2.Dispose();
Thread.Sleep(10000);

And it produced:
divBy3
1
2
divBy3
4
5
divBy3
7
8
divBy3
divBy2
11
divBy3
13
divBy2
divBy3
divBy2
17
divBy3
19
divBy2
21
divBy2
23
divBy2
25
divBy2
27
divBy2
29
30
31
32
...

And that seemed right. Let me know if this solves it for you.

A: One option is to make your subscribers to be observable as well. So what these subscribers does is if that they don't handle the value then they emit it through their observable interface and then the last subscriber (that handle all not used values) will be a single ton object that subscribes to each of the observable interface of the other subscribers. Something like:
public class MyObserver : IObserver<string>, IObservable<string>
{
    Subject<string> s = new Subject<string>();
    public MyObserver(IObserver<string> obs)
    {
        s.Subscribe(obs);
    }
    public void OnCompleted()
    { }
    public void OnError(Exception error)
    { }
    public void OnNext(string value)
    {
        //If condition matches then else dont do on next
        s.OnNext(value);
    }
    public IDisposable Subscribe(IObserver<string> observer)
    {
        return s.Subscribe(observer);
    }
}
public class LastObserver : IObserver<string>
{
    public void OnCompleted()
    {   }

    public void OnError(Exception error)
    { }

    public void OnNext(string value)
    { //Do something with not catched value
    }
}
static LastObserver obs = new LastObserver();
static void Main()
{
    var timer = Observable.Interval(TimeSpan.FromSeconds(1)).Select(i => i.ToString());
    timer.Subscribe(new MyObserver(obs));
    timer.Subscribe(new MyObserver(obs));
    timer.Subscribe(new MyObserver(obs));

}

A: I don't know of any out of the box way to do this but I would do it as under
class ConditionAction
{
     public Predicate<string> Condition {get; set; }
     public Action<string> Action {get; set; }
}

var conditions = new ConditionAction[]{action1, action2, action3};

foreach (var condition in conditions)
       observable.Where(condition.Condition).Subscribe(condition.Action);
.....
observable.Where(s=>!conditions.Any(c=>c.Condition(s))).Subscribe(...);


text:
Q: Why can't I copy/paste img assets from one project into new directories in second project's drawable folder? I downloaded a project from Github, trying to rebuild it myself for learning purposes. I'm new to Android Studio, developing on a Mac. Having trouble with what I think would be simple tasks.
The source project from Github I downloaded has several different sub directories containing image resources under the res/drawable folder. I was hoping I could just copy and paste these assets into my own project. It doesn't seem to work the way I'd expect and I don't understand what is going on.
I've tried right clicking and copy/pasting the directory I'd like to duplicate from the Github project (opened in Android Studio) into the drawable folder in my new project (Also opened in AS). Nothing seems to happen when I do this. Right clicking and selecting "reveal in finder" reveals a still unfortunately empty drawable folder.
I also tried right clicking on the specific directory I'd like to copy from the Github project and selecting "reveal in finder", thinking I'd try copying and pasting it from there into my new project. Oddly enough when I do this, the same directory isn't even the one that's opened. Instead, it opens a drawable-hdpi folder containing several assets, but it's definitely not the one I was attempting to open.
I've tried right clicking and "synchronizing" the drawable folder in my new project after copy/pasting, still no luck.

A: You can not copy android folders or directories directly into android studio. But you can copy individual files into there respective folders in your project.
If you want to copy folders/ directories you can open the android app folder in your MAC browser and go to Application/app/src/main and paste whatever you have in the respective folders.
The main folder conrains java and res folders and an AndroidManifest.xml file.
You can paste xml files , drawables and pngs etc in res and java classes will go into java folder.


text:
Q: VB .Net when exporting to CSV issue when viewing in MS Excel I have encountered something really weird. When exporting to CSV my top line shows the quotation marks yet the lines below down.
I use UTF8 encoding and manually add the double quotation marks to the value so that it is encased with quotation marks.
the code being used is
Dim fs As New IO.FileStream(GenericValueEditorExportFilename.Value, IO.FileMode.Create)
        Dim writer As New IO.StreamWriter(fs, Encoding.UTF8)
        fs.Write(Encoding.UTF8.GetPreamble(), 0, Encoding.UTF8.GetPreamble().Length)
....
....
....

While reader.Read
                If reader("TargetLanguageID") = targetLanguageID Then
                    writer.WriteLine(Encode(reader("SourcePhrase")) & ", " & Encode(reader("TargetPhrase")))
                End If
....
....
....

Friend Shared Function Encode(ByVal value As String) As String
    Return ControlChars.Quote & value.Replace("""", """""") & ControlChars.Quote
End Function

the result when displayed in excel is shown as (https://ibb.co/ntMYdw)
when i open the file in Notepad++ the text is shown as below. But each line is displayed differently. Why is it that the 1st row displays them and the 2nd does not. Notepad++ result is displayed as (https://ibb.co/fMkWWG)

A: Excel is treating the first line as headers.
https://stackoverflow.com/a/24923167/2319909

A: So the issue was being caused by the BOM that was created to manually set the encoding for the file as a start writing to the file.
fs.Write(Encoding.UTF8.GetPreamble(), 0, Encoding.UTF8.GetPreamble().Length)

Removing this resolves by issue and the file remains in the desired UTF8 encoding as it is set on the stream writer. so there is no need to add the BOM to set the encoding.

A: Something like this should work for you.
Dim str As New StringBuilder

For Each dr As DataRow In Me.NorthwindDataSet.Customers

     For Each field As Object In dr.ItemArray

     str.Append(field.ToString & ",")

     Next

     str.Replace(",", vbNewLine, str.Length - 1, 1)

Next

Try

     My.Computer.FileSystem.WriteAllText("C:\temp\testcsv.csv", str.ToString, False)

Catch ex As Exception

     MessageBox.Show("Write Error")

End Try


text:
Q: What is \Q in Perl? Is it always necessary to use \E? I just read about \Q and \E and I am trying to fully undertand them. According to perlre:

\Q quote (disable) pattern metacharacters until \E
\E end either case modification or quoted section, think vi

So I did a couple of tests:
$ perl -e 'print "hello\n" if "he\\tllo" =~ /\Q\t/'
hello
$ perl -e 'print "hello\n" if "he\\tllo" =~ /\t/'
$

If I understand it properly, without \Q it does not evaluate as True because it considers \t as a tab.
Then I used \E and I see no difference:
$ perl -e 'print "hello\n" if "he\\tllo" =~ /\Q\t\E/'
hello

If I give a broader string and pattern containing both literal \t and a tab:
$ perl -e 'print "hello\n" if "he\\tl\tlo" =~ /\Q\t\E.*\t/'
hello

It seems to work, because it considers the first \t as fixed string, whereas the second \t is considered a tab.
So is this the way \Q and \E should be used? That is, do we enclose the "clean" strings in between \Q and \E? Is it correct to just use \Q if everything should be treated as literal?

A: \E marks the end, not just of \Q, but other escapes, such as \U. So you would use it when you need the \Q sequence to end. But I think you are overthinking things. \Q is the escape version of quotemeta().
"(foobar" =~ /\Q(fo+bar/    # false, "+" gets escaped
"(foobar" =~ /\Q(\Efo+bar/  # true

I would not say "should be used". If you do not use \E, then \Q continues through your whole pattern.
A more tangible way to see how \E works is to use it with \U:
$ perl -lwe' print "\Ufoobar" '
FOOBAR
$ perl -lwe' print "\Ufoo\Ebar" '
FOObar

A: Just like "abc $x def" is the same as "abc ".$x." def"
$ diff -u0 \
   <( perl -MO=Concise,-exec -E'$_ = "abc $x def";'     2>&1 ) \
   <( perl -MO=Concise,-exec -E'$_ = "abc ".$x." def";' 2>&1 ) \
      && echo "same"
same

"abc \Q$x\t\E def" is the same as "abc ".quotemeta($x."\t")." def"
$ diff -u0 \
   <( perl -MO=Concise,-exec -E'$_ = "abc \Q$x\t\E def";'               2>&1 ) \
   <( perl -MO=Concise,-exec -E'$_ = "abc ".quotemeta($x."\t")." def";' 2>&1 ) \
      && echo "same"
--- /dev/fd/63  2015-01-06 11:22:49.564061341 -0500
+++ /dev/fd/62  2015-01-06 11:22:49.564061341 -0500
@@ -7,3 +7,3 @@
-6  <2> concat[t3] sK/2
-7  <1> quotemeta[t4] sK/1
-8  <2> concat[t5] sK/2
+6  <2> concat[t4] sK/2
+7  <1> quotemeta[t5] sK/1
+8  <2> concat[t6] sK/2
@@ -11 +11 @@
-a  <2> concat[t6] sKS/2
+a  <2> concat[t7] sKS/2

(The difference is just an difference in the indexes in the "pad", the array where lexicals are stored.)
It can also be used in regexp literals.
my $exact_text = "...";
my $pat = quotemeta($exact_text);
if (/$pat/) { ... }

is long for
my $exact_text = "...";
if (/\Q$exact_text\E/) { ... }

\E can be omitted if it's at the end of the literal.
my $exact_text = "...";
if (/\Q$exact_text/) { ... }

A: The final \E is not needed if nothing dangerous follows it. I'm not sure this behaviour is documented, but I've seen it many times.
It's also interesting to see how variable interpolation plays with \Q:
perl -E '$x = "lo\$"; say "hello" =~ /$x/'
1

perl -E '$x = "lo\$"; say "hello" =~ /\Q$x/'

# ^
# | empty line here.

See also quotemeta.


text:
Q: How to iterate over a generic vector I've always found C++ templates inscrutable, and C++ error messages more so. I want to understand it, rather than always feeling confused. Here's the latest bizarre experience:
error: conversion from '<unresolved overloaded function type>' to non-scalar type 'std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}' requested

This doozy comes from the following code:
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
void printVector(const vector<T>& v) {
    for (typename vector<T>::iterator iter = v.begin; iter != v.end; iter++) {
        cout << *iter << endl;
    }
}

int main() {
    vector<int> v{1, 2, 3};
    printVector(v);
    return 0;
}

It has no problem iterating over the vector if I use a C++11 range-based loop. I want to learn how to do it using iterators.
Can someone explain what the error means and how to fix it?
It would also be wonderful if I could get a recommendation of a book that explains templates well.

A: See the error message carefully. It says you're trying to convert a function to iterator. You should call them by adding ().
Change
for (typename vector<T>::iterator iter = v.begin; iter != v.end; iter++) {

to
for (typename vector<T>::iterator iter = v.begin(); iter != v.end(); iter++) {
                                                ~~               ~~

For C++ books, The Definitive C++ Book Guide and List

A: You're missing the parentheses from begin and end and since you're passing the vector by const reference you'll need a const_iterator.
template <typename T>
void printVector(const vector<T>& v) {
    for (typename vector<T>::const_iterator iter = v.begin(); iter != v.end(); iter++) {
                             ^^^^^^^^^^^^^^               ^^                ^^
        cout << *iter << endl;
    }
}

Better yet use a ranged base for:
template <typename T>
void printVector(const vector<T>& v) {
    for(auto &&e : v) {
        cout << e << endl;
    }
}

A: std::vector<T>::begin and ::end are functions; you need to call them:
for (typename vector<T>::iterator iter = v.begin(); iter != v.end(); iter++) {
//                                              ^^               ^^
    cout << *iter << endl;
}

Additionally, you are trying to convert a const iterator to a non-const one. You need to use vector<T>::const_iterator, or, better yet, auto.


text:
Q: What is a free active directory simulator tool for testing remote single-sign-on auth requests? Need to test if an application has correctly implemented active directory remote authentication single-sign-on requests? If you don't know of a tool, what would be a checklist of items to confirm are in place?

A: How about a 180-day trial license for Windows Server 2008 R2?
Honestly, that's probably your best bet. I've never heard of an "Active Directory simulator". It's easy enough to just spin up a trial version of the OS, set up your users, and then test on a real, live version of the software.

A: The answers to this question should point you to a few alternatives (mainly LDAP-based): OpenDS, ApacheDS, OpenLDAP and AD LDS...


text:
Q: How does the Dirac equation show the existence of anti-particles? I want to understand the following

"The Dirac equation for a charged massive fermion predicts, correctly, the existence of an antiparticle of the same mass and spin, but opposite charge, and opposite magnetic moment relative to the direction of the spin. The Dirac equation for a neutrino ν allows the existence of an antineutrino ¯ν." .

can somebody write the mathematics of it?

A: The Dirac equation has negative energy solutions which are interpreted as the positively charged antiparticles of the electron. The limit of the Dirac equation for zero mass spin 1/2 particles is the (also relativistic) Weyl equation which was thought to describe the neutrinos before it was discovered that they have small mass. The mathematics of this can be found in any textbook of relativistic quantum theory. See, e.g., Landau & Lifshits' eponymous volume.


text:
Q: using GtkAlignment for horizontal alignment I am new to GTK+ world and trying to learn it from Foundations of GTK+ Development.
Mean while I am getting some problem in using GtkAlignment widget, as in the code below.
Even if I change the value of either one of the below I am not getting the Ok and calcel button getting aligned to right.
GtkWidget* halign = gtk_alignment_new(0, 0, 0, 0);
GtkWidget* halign = gtk_alignment_new(0, 1, 0, 0);

I think I'm missing something, but not getting exactly
Note: I am using GTK+3 on windows 7
int main(int argc, char* argv[]) {
    gtk_init(&argc, &argv);
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Gtk Alignment Sample");
gtk_container_set_border_width(GTK_CONTAINER(window), 5);
gtk_widget_set_size_request(window, 250, 400);
g_signal_connect(window, "delete_event", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget* ok_button = gtk_button_new_from_stock(GTK_STOCK_OK);
GtkWidget* cancel_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);

GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start(GTK_BOX(hbox), ok_button,     FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), cancel_button, FALSE, FALSE, 0);

GtkWidget* halign = gtk_alignment_new(0, 0, 0, 0);
gtk_container_add(GTK_CONTAINER(halign), hbox);

GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start(GTK_BOX(vbox), halign, FALSE, FALSE, 0);

GtkWidget* valign = gtk_alignment_new(0, 1, 0, 0);
gtk_container_add(GTK_CONTAINER(valign), vbox);

gtk_container_add(GTK_CONTAINER(window), valign);
gtk_widget_show_all(window);

gtk_main();
return 0;

}

A: Quote from the docs:

Note that the desired effect can in most cases be achieved by using
  the "halign", "valign" and "margin" properties on the child widget, so
  GtkAlignment should not be used in new code.

Try to just use
gtk_widget_set_alignment (button_ok, GTK_ALIGN_END);
gtk_widget_set_alignment (button_cancel, GTK_ALIGN_END);
//or
gtk_widget_set_alignment (hbox, GTK_ALIGN_END);

and remove all alignment widgets


text:
Q: Deploy PHP project with Yarn to Heroku Locally I simply run composer install and yarn install, but when pushing to Heroku only composer dependencies get installed, but not Yarn components. I can't seem to find a way for Heroku to trigger Yarn components installation.

A: I just needed to add the heroku/nodejs buildpack inside Heroku application's settings page, alongside the already present heroku/php. The next deploy then also installed the yarn components.


text:
Q: How can I install new charts on GKE with helm3 remotely? I get this error with helm3, why?
$ gcloud config list
[core]
account = xxxxx@xxxxx
disable_usage_reporting = True
project = project1-xxxxx

Your active configuration is: [xconfig]

$ kubectl get nodes --cluster gke_project1-xxxxx-central1-c_cluster-1
NAME                                       STATUS   ROLES    AGE    VERSION
gke-cluster-1-default-pool-xxxxx-xxxxx   Ready    <none>   159m   v1.19.9-gke.1400
gke-cluster-1-default-pool-xxxxx-xxxxx   Ready    <none>   159m   v1.19.9-gke.1400
gke-cluster-1-default-pool-xxxxx-xxxxx   Ready    <none>   159m   v1.19.9-gke.1400

$ helm3 install -f values.yaml confluent confluentinc/cp-helm-charts
ERROR: ld.so: object '/usr/local/lib/AppProtection/libAppProtection.so' from /etc/ld.so.preload cannot be preloaded (failed to map segment from shared object): ignored.
ERROR: ld.so: object '/usr/local/lib/AppProtection/libAppProtection.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object '/usr/local/lib/AppProtection/libAppProtection.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.
Error: Kubernetes cluster unreachable

A: Could this guide, from official repository, help you for installing confluentinc?
helm repo add confluentinc https://confluentinc.github.io/cp-helm-charts/   #(1)
helm repo update    #(2)
helm install confluentinc/cp-helm-charts --name my-confluent --version 0.6.0

Check the kubeconfig file with $ kubectl config view


text:
Q: Convert decimal representing time to hour, minutes, seconds I have a decimal. The range of this decimal is between 0 and 23.999999. This decimal represents a time. For example, if the decimal is 0.25, then the time it represents is 12:15 AM. If the decimal is 23.50, the time it represents is 11:30 PM.
I have three variables:
    - Hours
    - Minutes
    - Seconds
Using this decimal, how do I fill in the Hours, Minutes, and Seconds values?

A: The hours should be pretty easy.
There are 60 minutes in 1 hour, so get the decimal part, multiply it by 60, and take the integer.  Take the decimal again, multiply it again by 60, and you have your seconds.
For example, let's take the number 20.38490
We know it's hour 20, or 8 PM.
This leaves us with the number .38490
Multiplying with 60, we get 23.094 minutes.
Multiplying .094 with 60, we get 5 seconds.

A: Well, here's an answer in C#, but it's generally the same idea in most languages:
int hours = (int)hoursDecimal;
decimal minutesDecimal = ((hoursDecimal - hours) * 60);
int minutes = (int)minutesDecimal;
int seconds = (int)((minutesDecimal - minutes) * 60);

A: you can use the floor function to strip off the hours and leave the minuites and seconds as a fraction of an hour. Then you can use the floor function again to strip off the minuites as a fraction of an hour. you are then left with the seconds ( as fractions of an hour )
below a simple example to print hours and mins sunrise is in fractional hours since midnight
printf( "sunrise %ld:%ld, \n",
             (long)floor( sunrise ),
                 (long)(floor( sunrise * 60 ) - 60 * floor( sunrise )) );

A: Whatever language you use, you can do this using the math functions: MOD and FLOOR/TRUNC
Let "dec" be the decimal variable
trunc(mod(dec, 1)) => hours
trunc(mod(dec * 60, 60)) => minutes
trunc(mod(dec * 3600, 60)) => seconds

In C#, you can truncate a decimal to int using just explicit casting, e.g.
int seconds = (int) ((dec * 3600) % 60)


text:
Q: How to achieve vertical centering with optional extra element and adjacent matching column, in pure CSS, no tables? I've a problem laying out an e-commerce page with very strict layout requirements.  We want to show a product image alongside a product description, with some optional extra information about the product below the image.  The width is constrained by our overall page layout, while height can be variable.  The answer seems to be "you can't do this with pure CSS".
Here's a mock up:

The marked widths are 372+12+178=562 leaving 8px in borders.  The image and description areas have 2px borders, making a total of 8px horizontal pixels, and 562+8=570.
I've got the vertical centering of the image mostly sorted, what breaks the design is the optional 'extra info' panel.  The site is generated by PHP, which optionally includes the
 for that extra info if the data is available for the product.  I'd be happy to always include the 'extra info' element and style it to be invisible if it's empty, if it helps solve the design problem.
Requirements:

*

*Product image can be any aspect ratio.  Some are thin and tall, some wide and short, some square.

*Product image should fill its area horizontally and naturally size itself vertically by its aspect ratio.

*Product image should be vertically centered in its area (blue).  When extra info is not visible, image would be vertically centered alongside the Description area.  When extra info is visible, image should be vertically centered in the remaining space.

*Extra info can be any amount of text and aligned to bottom of product image area.  So, cannot have fixed height.

*Product Description can be any amount of text.

*The 'image and extra info' column should vertically match the size of the 'description' column and vice versa.

*Description and Extra Info boxes employ CSS gradient backgrounds and borders.  All these divs must actually size themselves accordingly, I cannot get away with 'faux columns' as described here http://www.alistapart.com/articles/fauxcolumns/.

*Do not want to use Javascript to align elements.  Yes, I'm sure we're all jQuery masters and it's a wonderful tool, but it shouldn't be required for this layout.

My design so far employs pure CSS and no tables, using the table-cell style to center the image, but there is some fudgery to do with min-height that breaks when different size images are used.  A jsfiddle: http://jsfiddle.net/GJVbX/
That fiddle is easily broken by e.g. tripling the Product Description text content, or adding "width: 370px; height: 400px;" to the  so it's not a nice height.
An example of my design that works well:

However, it's not hard to find an image size that breaks it:

Note how the tall product image makes the image div extend vertically and the Description column cannot keep up.
I've been on #css IRC channel on Freenode and was told that this is possible using pure CSS, using tables for this layout task is a sign I don't understand CSS layout and should hire a professional, and that to achieve the vertical centering I should use "display: table-cell".  However, extremely helpful as they were, the discussion was too complex to continue on IRC.  I understand that
 brings with it all sorts of horrible layout mechanics that is simply broken for accurate page layout, however, I can't think of a better solution, mostly because of my requirement to keep the columns the same height.
Would appreciate constructive criticism, alternative solutions, or even just confirmation of my plight :)
EDIT - here is the HTML and CSS content from the jsfiddle given above, for those who prefer this content contained within the stackoverflow question.  This is extracted from the live site, cleaned a little for indentation, with a dummy product image (produced by the thumbnailer script employed in the live site) and dummy text.
HTML:

Extra info goes here.

          Product Description goes here.

          Product Description goes here.

          Product Description goes here.

          Product Description goes here.

          Product Description goes here.

          Yet the gradient ends too soon because this div doesn't fill its space vertically!

CSS:
DIV.productInfo {
    max-width: 570px;
    font-family: Verdana,Geneva,'DejaVu Sans',sans-serif;
    font-size: 12px; /* Just for this fiddle */
}
.productInfo .productTopWrapper {
    overflow: hidden;
    margin-bottom: 12px;
    position: relative;
}
.productInfo .productImgWrapper {
    width: 372px;
    min-height: 353px;
    float: left;
    border: 2px solid #cbcbcb;
    text-align: center;
}

/* BEGIN css wrap from http://www.brunildo.org/test/img_center.html */
.wraptocenter {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    width: 372px;
    height: 309px;
}
.wraptocenter * {
    vertical-align: middle;
}
/*\*//*/
.wraptocenter {
    display: block;
}
.wraptocenter span {
    display: inline-block;
    height: 100%;
    width: 1px;
}
/**/
*:first-child+html {} * html .wraptocenter span {
    display: inline-block;
    height: 100%;
}

/* END css wrap */

.productInfo .extraInfoWrapper {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 376px;
}
.productInfo .extraInfoInner {
    padding: 5px;
    border: 2px solid #cbcbcb;
    text-align: center;
}

.productInfo .gradientBackground {
    background: #999; /* for non-css3 browsers */

    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#d0d1d3', endColorstr='#fefefe'); /* for IE */
    background: -webkit-gradient(linear, left top, left bottom, from(#d0d1d3), to(#fefefe)); /* for webkit browsers */
    background: -moz-linear-gradient(top, #d0d1d3,  #fefefe); /* for firefox 3.6+ */
    background: -ms-repeating-linear-gradient(top, #d0d1d3,  #fefefe);
    background: repeating-linear-gradient(top, #d0d1d3,  #fefefe);
}.productInfo .productDescription {
    width: 178px;
    min-height: 353px;
    margin-left: 388px;

    border: 2px solid #cbcbcb;
}
.productInfo .productDescriptionInner {
    padding: 5px;
    font-size: 1.2em;
    line-height: 1.2em;
}

A: You can do this with a tall height set with a negative margin. (your height minus the minimum height of your div, in this case 353px) The only problem is that the border bottom will disappear into the parent's overflow (which should stay hidden). Not sure how important the border is to you or even if that's what you were looking for, but perhaps it might point you in the right direction?
.productInfo .productDescription {
    width: 178px;
    min-height: 353px;
    margin-left: 388px;
    border: 2px solid #cbcbcb;
    height: 1000px;
    margin-bottom: -647px;
}

A: Unfortunately, which versions of IE you are required to support affects more than just CSS3 eye-candy. display: table-cell, for example, isn't avilable in IE7. And a myriad of other things present in other browsers are missing or buggy in IE7 and IE8. IE9 is a considerable improvement however.
To be honest, even if you were restricting yourself to latest version of all browsers, this layout would still be difficult in pure CSS, whatever people on IRC may claim. When new layout managers such as Flexible Box and Grid Layout are ubiquitously available, it will be easy, but we are a few years off from that, I'm afraid.
Anyway, here is my attempt at your required layout:
http://jsfiddle.net/amtiskaw/tNywn/
It requires IE8 and above, as it uses display: table-cell to vertically centre the product image. It also has a quirk where the content of the extra-info box will never overlap vertically with the content of the product-info box, although their borders will look correct.
The stretched borders and gradients are achieved by using additional elements which are sized to vertically fill the product container element using absolute positioning, then placed behind the content using negative z-indexes.
Personally, I'd me more inclined in this case to use tables or a bit of jQuery to get the sizing right, rather than this kind of CSS hackery. If you use a table, you can give it an attribute role="presentation" to indicate to screen readers and other semantic tools that it is being used for layout purposes, rather than to express tabular data. This pattern was approved by the W3C.

A: I remember having this problem some time ago and ended up resorting to JS to resolve it. Unforunately the constraints you have are making it very difficult to come up with a working example with pure CSS. The problem as I see it is that as soon as the image increases in size the containing div no longer has a specific width or height and with CSS alone you can't make the calculations needed to expand the description div to the correct height. Browsers won't do this automatically if the element that's size changes is not the direct parent, leaving children of the parent at the heights they were pre-height / width change.
Yes tables will solve the problem with a fixed row height but as you say, they come at a price that I try to stick clear of as much as possible.
I'm presuming you've considered using JS / Jquery to solve this problem already.
Jquery example
$(function()
{
    var height = $('.productImgWrapper').innerHeight();

    $('.productDescription').css('height', height);
});

Note that .innerHeight() includes padding but not the border or margin. To include the border use .outerHeight().
I know it's not ideal but I can't see any other way of solving your problem. Maybe someone with higher CSS powers than I can come up with a solution.


text:
Q: Android ActionBar Tabs and Fragments I am getting started with android and want to have an application that has several tabs.  I want to use the actionbar with the SherlockActionBar library to support devices running pre honeycomb versions of android.  I have seen so many examples of creating and using tabs that I have no idea now what is the best or preferred method of doing so.
I have read that the best way is to have a fragment for each tab and have one activity which controls the switching of fragments in an out as well as coordinating communication between fragments. If this is the proper way of handling tabs is it best to have each fragments layout defined in its own layout.xml.
It seems that when an button is clicked that is defined in a fragments layout the onclick is triggered in the parent activity.  If the best way to handle that to do the processing in the parent activity or to pass the event on to the correct fragment for processing.
In summary I want to know what the best practice is for creating an app with actionbar tabs, where the code should be and how the layouts should be separated.
Thank You,
Nathan

A: You are in the right direction from what I can read. Google has a lot of the best material on this subject. Also look at Googles apps for reference, the Play app features simple tab navigation and defines how we should and should not try to make tabs. One very important lesson is that we should only have 1 fragment in each tab and we shouldn't try to make back navigation inside tabs (though it is possible by hacking a little).


text:
Q: Undefined reference when using 2 files I have a problem with pointers. I want to use functions from one file, but there is a problem I can't solve.
Here is main file:
#include <iomanip>
#include <iostream>
#include "ilgas_skaicius.h"
#include "stekas.h"

using namespace std;

int main(){
  stackType pile;
  int a = Create(&pile); // problem is over here. Undefined reference.
  return 0;
}

And here's header file:
#ifndef STEKAS_H_INCLUDED
#define STEKAS_H_INCLUDED

typedef struct LinkElem    stackValue;
typedef struct LinkElem*   stackPointer;
typedef struct StackStruct stackType;

typedef int myType;

struct StackStruct
{
   stackPointer end1;
};

int Create(stackType* stack1);
int Delete (stackType* stack1);
int isFull (stackType* stack1);
int isEmpty (stackType* stack1);
int Push (myType value, stackType* stack1);
int Pop(stackType* stack1, myType* value);

#endif

What should I do?


text:
Q: space character / streamwriter problem C# I tried to make a fixed width file, but I found that when I use the space character I have a strange signs in my txt file. If I change the "50" number to something like "15" or "1000", it works fine.
This is my code:
string fileName = Path.GetTempPath() + "temp.txt";
FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter writer = new StreamWriter(stream);
writer.Write("1".PadRight(50, ' '));
writer.Write("0".PadRight(756, ' '));
writer.Close();

What is wrong?

A: Disregard what you read here previously.  I took the output of your program, which does shows up strange in Microsoft Notepad, and opened it in a few other editors.  It appears fine in all of them.  Convinced it was some encoding error, I then cracked open XVI32 to look at the binary.
I removed a single space from the end of the file and I re-save the file and it shows up fine.    I put it back in and the problem returned.  I change the first hex character from 32 to anything less than 30 and it works fine.
So this seems like a very bizarre error with Microsoft Notepad.


text:
Q: jar file not finding main class After compiling a java program with javac
$ javac -classpath javax.mail.jar:javax.activation.jar:. PriceEmailer.java

I am including the resultant class and the libraries I used into a jar, however, the jar file will not execute.
Running the java file on the command line works:
$ java -classpath javax.activation.jar:javax.mail.jar:. PriceEmailer
Sending...
Email sent!

Now I want to make an executable .jar file. I placed the following in manifest.txt:
Manifest-Version: 1.0
Main-Class: PriceEmailer
Class-Path: javax.activation.jar:javax.mail.jar:.

Creating the .jar file:
$ jar vcfm PriceEmailer.jar manifest.txt class/*
added manifest
adding: class/javax.activation.jar(in = 56290) (out= 50561)(deflated 10%)
adding: class/javax.mail.jar(in = 653275) (out= 617552)(deflated 5%)
adding: class/PriceEmailer.class(in = 4106) (out= 2205)(deflated 46%)

Running the .jar file:
$ java -jar PriceEmailer.jar
Error: Could not find or load main class PriceEmailer

Why can't the jar file execute?
Note: The main function is in the file PriceEmailer.java which defines the PriceEmailer class.
public static void main(String[] args) throws Exception {

A: The Class-path entries should be separated by spaces, not colons. See the specification.


text:
Q: Custom DataGridView duplicated columns I've created a custom Winforms control by subclassing from the DataGridView.
The custom datagrid view defines it's own columns and mappings.
However whenever I drag it off the toolbox and onto the design surface of a form, the form recreates a column control (DataGridViewTextBoxColumn) for each column in the custom control, such that I end up with double the number of columns I should have.
The whole idea is that the control is already "self aware" so I don't need the form to do anything. Clearly I've overlooked something simple but I'm more Web than Windows and nothing immediately stands out as the cause for this.

Custom Datagrid:
 partial class StrategyGrid
{
        private System.ComponentModel.IContainer components = null;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
            this.zquantityDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.zbuyPricePerShareDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xbuyParcelTotalDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xtargetPricePerShareDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xtargetParcelTotalDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xTargetNetProfitAmt = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xTargetNetProfitPct = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xMarketPriceNetProfitAmt = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xMarketPriceNetProfitPct = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.xColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            this.SuspendLayout();
            //
            // zquantityDataGridViewTextBoxColumn
            //
            this.zquantityDataGridViewTextBoxColumn.DataPropertyName = "Quantity";
            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.zquantityDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle13;
            this.zquantityDataGridViewTextBoxColumn.HeaderText = "Qty";
            this.zquantityDataGridViewTextBoxColumn.MinimumWidth = 85;
            this.zquantityDataGridViewTextBoxColumn.Name = "zquantityDataGridViewTextBoxColumn";
            this.zquantityDataGridViewTextBoxColumn.Width = 85;
            //
            // zbuyPricePerShareDataGridViewTextBoxColumn
            //
            this.zbuyPricePerShareDataGridViewTextBoxColumn.DataPropertyName = "BuyPricePerShare";
            dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle14.Format = "N2";
            dataGridViewCellStyle14.NullValue = null;
            this.zbuyPricePerShareDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle14;
            this.zbuyPricePerShareDataGridViewTextBoxColumn.HeaderText = "Buy Price";
            this.zbuyPricePerShareDataGridViewTextBoxColumn.MinimumWidth = 85;
            this.zbuyPricePerShareDataGridViewTextBoxColumn.Name = "zbuyPricePerShareDataGridViewTextBoxColumn";
            this.zbuyPricePerShareDataGridViewTextBoxColumn.ToolTipText = "Buy price per share";
            this.zbuyPricePerShareDataGridViewTextBoxColumn.Width = 85;
            //
            // zbuyParcelSubtotalDataGridViewTextBoxColumn
            //
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.DataPropertyName = "BuyParcelSubtotal";
            dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle15.Format = "C2";
            dataGridViewCellStyle15.NullValue = null;
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle15;
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.HeaderText = "Buy Sub";
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.MinimumWidth = 85;
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.Name = "zbuyParcelSubtotalDataGridViewTextBoxColumn";
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.Visible = false;
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn.Width = 85;
            //
            // zbuyBrokerageFeeAmountDataGridViewTextBoxColumn
            //
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.DataPropertyName = "BuyBrokerageFeeAmount";
            dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle16.Format = "C0";
            dataGridViewCellStyle16.NullValue = null;
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle16;
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.HeaderText = "Rates";
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.MinimumWidth = 75;
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.Name = "zbuyBrokerageFeeAmountDataGridViewTextBoxColumn";
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.ToolTipText = "Buy Brokerage Rates";
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.Visible = false;
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn.Width = 75;
            //
            // xbuyParcelTotalDataGridViewTextBoxColumn
            //
            this.xbuyParcelTotalDataGridViewTextBoxColumn.DataPropertyName = "BuyParcelTotal";
            dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle17.Format = "N0";
            dataGridViewCellStyle17.NullValue = null;
            this.xbuyParcelTotalDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle17;
            this.xbuyParcelTotalDataGridViewTextBoxColumn.HeaderText = "Buy Price Total";
            this.xbuyParcelTotalDataGridViewTextBoxColumn.MinimumWidth = 85;
            this.xbuyParcelTotalDataGridViewTextBoxColumn.Name = "xbuyParcelTotalDataGridViewTextBoxColumn";
            this.xbuyParcelTotalDataGridViewTextBoxColumn.ToolTipText = "Buy Total Parcel Cost";
            this.xbuyParcelTotalDataGridViewTextBoxColumn.Width = 85;
            //
            // xbreakevenPricePerShareDataGridViewTextBoxColumn
            //
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn.DataPropertyName = "BreakevenPricePerShare";
            dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle18.Format = "N2";
            dataGridViewCellStyle18.NullValue = null;
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle18;
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn.HeaderText = "B/E Price";
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn.MinimumWidth = 100;
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn.Name = "xbreakevenPricePerShareDataGridViewTextBoxColumn";
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn.ToolTipText = "Breakeven price per share";
            //
            // xtargetPricePerShareDataGridViewTextBoxColumn
            //
            this.xtargetPricePerShareDataGridViewTextBoxColumn.DataPropertyName = "TargetPricePerShare";
            dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle19.Format = "N2";
            dataGridViewCellStyle19.NullValue = null;
            this.xtargetPricePerShareDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle19;
            this.xtargetPricePerShareDataGridViewTextBoxColumn.HeaderText = "Target Price";
            this.xtargetPricePerShareDataGridViewTextBoxColumn.MinimumWidth = 100;
            this.xtargetPricePerShareDataGridViewTextBoxColumn.Name = "xtargetPricePerShareDataGridViewTextBoxColumn";
            this.xtargetPricePerShareDataGridViewTextBoxColumn.ToolTipText = "Target price per share";
            //
            // xtargetParcelTotalDataGridViewTextBoxColumn
            //
            this.xtargetParcelTotalDataGridViewTextBoxColumn.DataPropertyName = "TargetParcelTotal";
            dataGridViewCellStyle20.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle20.Format = "N0";
            dataGridViewCellStyle20.NullValue = null;
            this.xtargetParcelTotalDataGridViewTextBoxColumn.DefaultCellStyle = dataGridViewCellStyle20;
            this.xtargetParcelTotalDataGridViewTextBoxColumn.HeaderText = "Target Price NV";
            this.xtargetParcelTotalDataGridViewTextBoxColumn.MinimumWidth = 100;
            this.xtargetParcelTotalDataGridViewTextBoxColumn.Name = "xtargetParcelTotalDataGridViewTextBoxColumn";
            this.xtargetParcelTotalDataGridViewTextBoxColumn.ToolTipText = "Target Price Net Value";
            //
            // xTargetNetProfitAmt
            //
            this.xTargetNetProfitAmt.DataPropertyName = "TargetNetProfitAmt";
            dataGridViewCellStyle21.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle21.Format = "N2";
            dataGridViewCellStyle21.NullValue = "0";
            this.xTargetNetProfitAmt.DefaultCellStyle = dataGridViewCellStyle21;
            this.xTargetNetProfitAmt.HeaderText = "Target NP Amt";
            this.xTargetNetProfitAmt.MinimumWidth = 100;
            this.xTargetNetProfitAmt.Name = "xTargetNetProfitAmt";
            //
            // xTargetNetProfitPct
            //
            this.xTargetNetProfitPct.DataPropertyName = "TargetNetProfitPct";
            dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.xTargetNetProfitPct.DefaultCellStyle = dataGridViewCellStyle22;
            this.xTargetNetProfitPct.HeaderText = "Target NP Pct";
            this.xTargetNetProfitPct.MinimumWidth = 100;
            this.xTargetNetProfitPct.Name = "xTargetNetProfitPct";
            //
            // xMarketPriceNetProfitAmt
            //
            this.xMarketPriceNetProfitAmt.DataPropertyName = "MarketPriceNetProfitAmt";
            dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle23.Format = "N2";
            dataGridViewCellStyle23.NullValue = "0";
            this.xMarketPriceNetProfitAmt.DefaultCellStyle = dataGridViewCellStyle23;
            this.xMarketPriceNetProfitAmt.HeaderText = "Market Price NP Amt";
            this.xMarketPriceNetProfitAmt.MinimumWidth = 100;
            this.xMarketPriceNetProfitAmt.Name = "xMarketPriceNetProfitAmt";
            //
            // xMarketPriceNetProfitPct
            //
            this.xMarketPriceNetProfitPct.DataPropertyName = "MarketPriceNetProfitPct";
            dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            dataGridViewCellStyle24.Format = "N2";
            dataGridViewCellStyle24.NullValue = null;
            this.xMarketPriceNetProfitPct.DefaultCellStyle = dataGridViewCellStyle24;
            this.xMarketPriceNetProfitPct.HeaderText = "Market Price NP Pct";
            this.xMarketPriceNetProfitPct.MinimumWidth = 100;
            this.xMarketPriceNetProfitPct.Name = "xMarketPriceNetProfitPct";
            this.xMarketPriceNetProfitPct.ReadOnly = true;
            //
            // xColumn2
            //
            this.xColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
            this.xColumn2.HeaderText = "";
            this.xColumn2.Name = "xColumn2";
            this.xColumn2.ReadOnly = true;
            //
            // bindingSource1
            //
            this.bindingSource1.DataSource = typeof(FlatShareTradePlanList);
            //
            // StrategyGrid
            //
            this.AutoGenerateColumns = false;
            this.BackgroundColor = System.Drawing.Color.Black;
            this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.zquantityDataGridViewTextBoxColumn,
            this.zbuyPricePerShareDataGridViewTextBoxColumn,
            this.zbuyParcelSubtotalDataGridViewTextBoxColumn,
            this.zbuyBrokerageFeeAmountDataGridViewTextBoxColumn,
            this.xbuyParcelTotalDataGridViewTextBoxColumn,
            this.xbreakevenPricePerShareDataGridViewTextBoxColumn,
            this.xtargetPricePerShareDataGridViewTextBoxColumn,
            this.xtargetParcelTotalDataGridViewTextBoxColumn,
            this.xTargetNetProfitAmt,
            this.xTargetNetProfitPct,
            this.xMarketPriceNetProfitAmt,
            this.xMarketPriceNetProfitPct,
            this.xColumn2});
            this.Cursor = System.Windows.Forms.Cursors.Arrow;
            this.MultiSelect = false;
            this.Name = "StrategyGridView";
            this.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Sunken;
            this.RowHeadersVisible = false;
            this.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            this.Size = new System.Drawing.Size(1193, 401);
            this.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.entryStrategyGridView_CellFormatting);
            ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.DataGridViewTextBoxColumn zquantityDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn zbuyPricePerShareDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn zbuyParcelSubtotalDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn zbuyBrokerageFeeAmountDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn xbuyParcelTotalDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn xbreakevenPricePerShareDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn xtargetPricePerShareDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn xtargetParcelTotalDataGridViewTextBoxColumn;
        private System.Windows.Forms.DataGridViewTextBoxColumn xTargetNetProfitAmt;
        private System.Windows.Forms.DataGridViewTextBoxColumn xTargetNetProfitPct;
        private System.Windows.Forms.DataGridViewTextBoxColumn xMarketPriceNetProfitAmt;
        private System.Windows.Forms.DataGridViewTextBoxColumn xMarketPriceNetProfitPct;
        private System.Windows.Forms.DataGridViewTextBoxColumn xColumn2;
        private System.Windows.Forms.BindingSource bindingSource1;

    }

When dragging onto a form the form generates the following insides it's InitializeComponent:
  private StrategyGrid strategyGrid1;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn12;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn13;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn14;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn15;
    private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn28;

Not sure where it's reading this "requirement" of having these columns from... but it's wrong. They are already present within the custom control. I thought maybe something to do AccessModifiers but can't seem to work it out.

A: It seems like you have not assigned Column's DataPropertyName in those columns. if you have created columns manually and assigning DataSrouce to the data grid the unmatched column will be generated automatically. Get more information and example about DataPropertyName on MSDN

A: go to gridview properties or F4 --> Uncheck Auto Generated Coloumns ="False"

A: If you have code like that ;
            for (int i = 0; i < columnNames.Length; i++)
            {
                GridName.Columns.Add(columnNames[i], columnNames[i]);
            }

add each column just one time. I used a flag
        if (AddColumnFlag)
        {
            for (int i = 0; i < columnNames.Length; i++)
            {
                GridName.Columns.Add(columnNames[i], columnNames[i]);
            }
        }

and when I call the function anywhere apart from constructor, set flag to false.
It's solved my problem.


text:
Q: Error while executing query for custom object Work Order I am executing the query for my custom object created in SFDC. but i am getting the following error:
{'[{"message":"\nSELECT FS_Account_Name__c from FS_Work_Order__c\ERROR at Row:1:Column:34\nsObject type 'FS_Work_Order__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.","errorCode":"INVALID_TYPE"}]'} Thoough have written the correct table name as given while i created the Custom object. PLease help.

A: First thing to try: does it work properly when run as the system administrator profile? If so then it's certainly a permissions issue. Things to checl

*

*The object is deployed (Setup > Create > Objects > Edit > Deployment Status)

*The profile has permission to query the object.

If not, does that same query work from inside the developer console? If so I can't think of what it might be, except connecting to production instead of a sandbox or vice versa.


text:
Q: Different object with the same Identifier Any ideas as to why I'd be getting this error:
nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Product#6]

From this code:
def save = {
    def productInstance = new Product(params)

    if(!productInstance.hasErrors() && productInstance.save()) {
        flash.message = "Product ${productInstance.id} created"
        redirect(action:show,id:productInstance.id)
    }
    else {
        render(view:'create',model:[productInstance:productInstance])
    }
}

A: It turned out the problem was a bug with the Searchable plugin, which doesn't allow you to index more than one domain. Disabling Searchable in all but one domain class resolved the issue.
This issue is detailed in an issue on Jira here: http://jira.codehaus.org/browse/GRAILSPLUGINS-601

A: You might have been passing id as part of the params, and a product with that id probably already exists in database.


text:
Q: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) - cannot start server Trying to feed a MySql database to AWS for a webapp I currently have running.  I haven't done this in a long time, but when I ssh'd into my AWS instance to feed the DB to my MySql server, I chose to run "sudo yum update" and it had 200+ updates.
I've tried starting/restarting my MySql server and get "FAILED" every time.
I've searched and do not have a /etc/mysql/my.cnf path, just /etc/my.cnf, and it contains:
[mysqld]
lower_case_table_names=1

So I'm unsure where I'd plug in 127.0.0.1.
I've been searching for a solution for a couple hours now and have not found anything.  Any assistance would be greatly appreciated.


text:
Q: add custom widget to DataGrid in GWT I am trying to add a custom widget in a DataGrid cell in GWT.
The widget has 2 anchors and I want to be able to choose the action to take depending on the anchor clicked.
is there any example on how to do this.
My widget renders but it is unable to handle the clicks events.
Thanks

A: With cell Widgets, you have to use cells. It's a different way of thinking, building the UI and handling events, though.


text:
Q: How to request data on already open chromedriver tab? At this point i auto-logint to a website
driver.get("[example link] example.com/124f32fqw")
r = request.get(driver_current_url)
test = r.text
print(test)

but it only print the the example link without logint
[Q]
How can i request something from a (selenium) Chromedriver that already open

A: your_url = driver.current_url

I answered similar question recently here How to extract the URL of a particular page using selenium/python?
For requests:
response = requests.get(url)
response.url


text:
Q: Unity+ Caching: how to keep an object instance that should be a singletone I need my UnityContainer to contain an instance of CacheManager that should be created once and re-used for all future instances of containers.
I am creating new UnityContainer instance each time when I need it ('CreateChildContainer' is not used).
I've created static member that contains my cache manager and registered it's instance.
Looking on this after half-year, I don't like static members...
Will it work if I will create a single instance of UnityContainer and register there the instance of CacheManager with 'ContainerControlledLifetimeManager' option?
Do you see any better way?
Thanks.

A: Keep an instance of the container around and use ContainerControlledLifetimeManager. Creating lots of containers is going to perform poorly.


text:
Q: How I can fix the error in: "Fit the PCA transformer on the training data and transform the data line" and "model = svm.SVC(kernel='linear')" I have create this Support Vector machine model but I get errors in "Fit the PCA transformer on the training data and transform the data line"  and "model = svm.SVC(kernel='linear')"
The first error is:
NameError: name 'x_train' is not defined

The second error is:
NameError: name 'svm' is not defined

import pandas as pd
import numpy as np
from sklearn.svm import SVC
from sklearn.model_selection import train_test_split
import seaborn as sns
import seaborn as sns # for data visualization

train_df = pd.read_csv('diabetes_data_upload.csv')
train_df.head()

# checking total of rows and columns
train_df.shape

# Transforming the Gender into 0 and 1
train_df["Gender"] = train_df["Gender"].map({"Male": 0, "Female": 1}).astype(int)
#Rounding the Age
train_df["Age"] = train_df.Age.round()

# Separating the data to predict the missing ages
X_train = train_df[train_df.Age.notnull()][['Age','Gender','weakness','Obesity', 'class']]
X_test = train_df[train_df.Age.isnull()][['Age','Gender','weakness','Obesity', 'class']]
y = train_df.Age.dropna()

# Just confirming if there is no more ages missing
train_df.Age.isnull().sum()

# Taking only the features that is important for now
X = train_df[['Gender', 'Age', 'weakness']]

# Taking the labels
Y = train_df['class']

# Spliting into 80% for training set and 20% for testing set so we can see our accuracy
X_train, x_test, Y_train, y_test = train_test_split(X, Y, test_size=0.2, random_state=0)

# Declaring the SVC with no tunning
print(X_train.shape)
print(Y_train.shape)

from sklearn.decomposition import PCA

# Create a PCA transformer with 3 components
pca = PCA(n_components=3)

# Fit the PCA transformer on the training data and transform the data
x_train_pca = pca.fit_transform(x_train)

# Transform the test data using the PCA transformer fitted on the training data
x_test_pca = pca.transform(x_test)

# Fit the classifier on the transformed training data
classifier.fit(x_train_pca, y_train)

# Predict the labels for the transformed test data
predictions = classifier.predict(x_test_pca)

# Calculate the accuracy of the model
accuracy = classifier.score(x_test_pca, y_test)
print("Accuracy:", accuracy)

#make it binary classification problem
X = X[np.logical_or(Y==0,Y==1)]
Y = Y[np.logical_or(Y==0,Y==1)]
model = svm.SVC(kernel='linear')
clf = model.fit(X, Y)
# The equation of the separating plane is given by all x so that np.dot(svc.coef_[0], x) + b = 0.
# Solve for w3 (z)
z = lambda x,y: (-clf.intercept_[0]-clf.coef_[0][0]*x -clf.coef_[0][1]*y) / clf.coef_[0][2]

tmp = np.linspace(-5,5,30)
x,y = np.meshgrid(tmp,tmp)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot3D(X[Y==0,0], X[Y==0,1], X[Y==0,2],'ob')
ax.plot3D(X[Y==1,0], X[Y==1,1], X[Y==1,2],'sr')
ax.plot_surface(x, y, z(x,y))
ax.view_init(30, 60)
plt.show()

A: The two errors you mention can be solved by the following -
1. NameError: name 'x_train' is not defined
This is because you are using x_train instead of the X_train variable you have defined right above. Remember, variables names are case sensitive.
x_train_pca = pca.fit_transform(x_train)  # your code

x_train_pca = pca.fit_transform(X_train)  # change it to this

2. NameError: name 'svm' is not defined
This is because you are already importing the SVC class using from svm import SVC. But while trying to instantiating the class the model you are using svm.SVC.
model = svm.SVC(kernel='linear') # your code

model = SVC(kernel='linear')     # change it to this


text:
Q: Simple Powershell Pester Test not working for $false I wrote a very simple function called "Check-RegValueExists" which works as follows when executing directly from the command prompt
Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "DevicePath"

Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "Devicexxxx"

Check-RegValueExists "HKCU:\Software\Classes\message-facebook-com" "URL Protocol"

which outputs the following
True
False
False

which are all correct outcomes.
My pester test is
Describe 'Check-RegValueExists Tests'{

It "has valid key with valid value" {
        'Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "DevicePath"' | Should Be $true
        }

It "has invalid key" {
        'Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "Devicexxxx"' | Should Be $false
        }

It "has empty value" {
        'Check-RegValueExists "HKCU:\Software\Classes\message-facebook-com" "URL Protocol"' | Should Be $false
        }

}

However only the first test passes and other two fail with following
[-] has invalid key 17ms
   Expected: {False}
   But was:  {Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "Devicexxxx"}
   8:         'Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "Devicexxxx"' | Should Be $false
   at <ScriptBlock>, <No file>: line 8
 [-] has empty value 28ms
   Expected: {False}
   But was:  {Check-RegValueExists "HKCU:\Software\Classes\message-facebook-com" "URL Protocol"}
   12:         'Check-RegValueExists "HKCU:\Software\Classes\message-facebook-com" "URL Protocol"' | Should Be $false
   at <ScriptBlock>, <No file>: line 12

I even copied and pasted first test and modified only the string to confirm but still failing. Is there a syntax error or something else?

A: Your issue is because you have wrapped your commands in single quotes, which has turned them in to strings. As a result you are testing whether each string is $true or $false and any value is considered $true.
You need to do this:
Describe 'Check-RegValueExists Tests'{

    It "has valid key with valid value" {
        Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "DevicePath" | Should Be $true
    }

    It "has invalid key" {
        Check-RegValueExists "HKLM:\Software\Microsoft\Windows\CurrentVersion" "Devicexxxx" | Should Be $false
    }

    It "has empty value" {
        Check-RegValueExists "HKCU:\Software\Classes\message-facebook-com" "URL Protocol" | Should Be $false
    }
}


text:
Q: Meta syntax, or syntax for documenting syntax While going through and properly documenting old code, I was wondering, what standards are there for documenting syntax?

*

*regular expressions: there's no single standard, and it's a little confusing to read.

*the one used in python documentation (here's an example): it looks nice, but I haven't been able to find the specification anywhere.

Are there any others, and which one is best?

A: BNF is one option. Syntax diagrams is another.


text:
Q: Counting number in one column with VBA I have a simple excel sheet with number starting from 1 - 50 in column "I"
To count many cell with value in column "I", I use this formula
=COUNT("I:I")

How can I use the similar method in VBA?
Currently Istruggle to finish the code below:
number = WorksheetFunction.Count(Range("I:I"))

I need advise to modified the code to become more independent by current cell selected (for example I will place the cell in column "H" and then run the VBA. the code automatically select range of column next to the cell and count cell that have value)

A: use OFFSET:
number = application.WorksheetFunction.Count(selection.offset(,1).entirecolumn)


text:
Q: Is there any way to stop Java from automatically creating new lines in the console output? I started learning Java a month back, and I have been using Eclipse as the workspace. Although I love the layout of it, I've been having trouble with what the console outputs. Specifically, the console will automatically create new lines in the output, despite no call for the creation of a new line being in the code.
For example, something like this:
     public class myClass
{
    public static void main(String args[])
    {
        int [] array = {10, 20, 30, 40, 50};
        for(int x : array)
        {
            System.out.println(x + ", ");
        }
    }
}

Will print the following:

10,
20,
30,
40,
50,

Is there any way to stop this from happening? I don't want future projects to have such odd spacing in between the lines.

A: It's NOT Eclipse. It is the Java method System.out.println you invoked:
public void println(String s)

Terminates the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').

public void print(String s)

Prints a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) method.

Use print() istead if you want to print all numbers in one line.
A much shorter way to do is:
String output = String.join(",", array);  // Java8

A: There is an easy way to stop creating new lines
Remove ln in your println
ln represents new line if ignore it there no comes new line.
public class myClass
{
    public static void main(String args[])
    {
        int [] array = {10, 20, 30, 40, 50};
        for(int x : array)
        {
            System.out.print(x + ", "); // println changed to print
        }
    }
}

Output:
10, 20, 30, 40, 50