Thursday, 3 October 2013

How to capitalize first letter of each world in the string

How to capitalize first letter of each world in the string

How to capitalize first letter of each world in the string in Ruby on Rails:
"goyette-xyz-is wide road".titleize returns "Goyette Xyz Is Wide Road".
I want the output like:
"goyette-xyz is wide road".SOME-FUNCTION should return "Goyette-xyz-is
Wide Road".
titleize removes the underscore and hyphens but i want to keep it in the
string.

Wednesday, 2 October 2013

resizable layout swing when disappears JPanel

resizable layout swing when disappears JPanel

pI have many jPanel (panelF) that are added in other jPanel(panelB).
jPanelF contain jPanelC. img src=http://i.stack.imgur.com/U1vts.png
alt=enter image description here/p pI have set the layout to add them as
follows:/p precode PanelB.setLayout(new BoxLayout(this.PanelB,
BoxLayout.PAGE_AXIS)); PanelF panelF1 = new PanelF(); PanelB.add(panelF1);
PanelF panelF2 = new PanelF(); PanelB.add(panelF2); /code/pre pI set
visible false in jPanelC1. But JPanelF2 preserves distance and not want to
make that blank space/p pimg src=http://i.stack.imgur.com/NTSR3.png
alt=enter image description here What I want is that when disappearing
JPanelC1. Distance is maintained between the jPanelF and not be a white
space. I tried validate() and change the layout but I fail. What would be
the way? Thank you very much. Sorry for my English/p pknow if there are
something like $(#panelC1).fadeOut(slow)? would be ideal./p

Inheritance in java, casting subclass to superclass

Inheritance in java, casting subclass to superclass

I am writing a software in java and this inheritance problem always crops
up. Funny enough, I don't get problems when i run the program in my IDE
(Eclipse Kepler) but once i export it to an executable jar, problem
starts. I think am the only one experiencing this problem because all
searches on google show the direct opposite. My problem is I have an
interface named VoteType. This interface is implemented by serveral
concrete classes. I save the concrete implementation to a file using
XMLEncoder and retrieve it using XMLDecoder. But when i try to cast it to
the interface it implements (VoteType), i get a ClassCastException. What
could possibly be causing this? Please help.

Euclid's Algorithm Theory

Euclid's Algorithm Theory

I understand the following code always produces the GCF of two integers. I
can see that variable b passes its value to a, and variable r passes its
value to variable b. This is according to Euclid's algorithm. However, I
don't understand why this works. Namely, how does the remainder share a
common factor with a and b?
// x and y are integers; x >= y > 0
a = x;
b = y;
r = a % b;
while (r > 0}
{
a = b;
b = r;
r = a % b;
}
// b is the greatest common factor of x and y

C# : overridden Equals method not getting called

C# : overridden Equals method not getting called

I have a class named 'x' which overrrides Equals() as follows:
public override bool Equals(object obj)
{
if(obj is x)
{
return ((obj as x).key == this.key);
}
return false;
}
When the following extension method tries to use the above override for
comparison, Equals() doesnt get used:
public static bool Contains(this HashSet<x> set, char key)
{
x SearchKey = new x(key);
return set.Contains(SearchKey);
}
I get the expected behavior only when I modify the first line in the
extensio method as follows:
x SearchKey = new x(key);
Can you please explain this behavior?
I had expected that, Equals() would get called against instance of x
itself since it is a subset of Object. What am I missing?

Tuesday, 1 October 2013

How can I take substring in Oracle

How can I take substring in Oracle

I have a row string in oracle table.
Some text ¹ 3694452 from 31.08.2013, stilltext 02.09.2013 18:16:27
How can I take "02.09.2013 18:16:27" (from the end of row and after
stilltext) for convert to date.
Thansk for time. Aleksandr

Input field to only accept a specific number

Input field to only accept a specific number

I have created a form and now I want to add an input field inside it which
would only accept a specific number i.e. the digit '4'. This is more like
a spam check where the user is asked that 'What is the answer of 1+3?' and
then he/she would've to enter the digit '4', in the input field, in order
for the form to get processed. This could also work in a manner that if
any other number is entered inside the input field and the form is
submitted, a pop up window is fired explaining the error.
I have created a jsfiddle which only accepts the digit 4 but sadly it is
allow accepting 'full stops'.
HTML:
<input id="humancheck" type="text" maxlength="1" name="humancheck"
required />
Javascript:
jQuery('#humancheck').keyup(function () {
this.value = this.value.replace(/[^4-4\.]/g,'');
});

What its the best way to transform AC do DC without a transformer=?iso-8859-1?Q?=3F_=96_electronics.stackexchange.com?=

What its the best way to transform AC do DC without a transformer? –
electronics.stackexchange.com

I have a battery drill, but the battery is useless, so I want to power
direct from the outlet. I need convert 220VAC to 7.2VDC @ 4A. I can't use
a transformer because the high output current, it ...

If $\lim_{n\to \infty} a_n = A$, $\lim_{n\to \infty} b_n = B$ and $A

If $\lim_{n\to \infty} a_n = A$, $\lim_{n\to \infty} b_n = B$ and $A

If $\lim _{n\to \infty} a_n = A$, $\lim _{n\to \infty} b_n = B$ and $A<B$,
prove $\lim _{n\to \infty}\max\{a_n,b_n\} = B$
Side question: Does the $A<B$ imply $a_n < b_n$?
Since we know $a_n$ converges to $A$, doesn't the problem kind of suggest
$\max{a_n,b_n} = b_n$ (as we also know $A\not = B$, so if the max were
$a_n$ the limit would have to be A, but then the problem is futile)?
[Not homework, just practice for learnings sake :-)]