which binlog format runs mysql replication efficiently
which binlog format runs mysql replication efficiently.Also many times
slave gets stopped because of errors like 1062,1054,1677,1032,1452.Any
help in this regarding can be useful.
Friday, 13 September 2013
Thursday, 12 September 2013
c# - how to make this code as different manner?
c# - how to make this code as different manner?
Below code is my interview question but I don't know how to make perfect
Code:
public class Shape
{
public void Rectangle(int length, int height)
{
Console.Write(length * height);
}
public void Circle(int radius)
{
Console.Write(3.14 * (radius * radius));
}
}
Any ideas? Thanks in advance
Below code is my interview question but I don't know how to make perfect
Code:
public class Shape
{
public void Rectangle(int length, int height)
{
Console.Write(length * height);
}
public void Circle(int radius)
{
Console.Write(3.14 * (radius * radius));
}
}
Any ideas? Thanks in advance
Using Regex to validate a variable length string
Using Regex to validate a variable length string
I'm trying to validate a form field in Java using Regex, which can have 5
different format possibilities. I'm struggling to get this one working.
The string to be checked will be between 4-6 alphanumeric characters.
If it's 4 characters, it must be all numbers.
^\\d{4}$
If it's 5 characters, it can be all numbers, first position letter with 4
following numbers, or first 3 positions letters followed with 2 numbers.
^\\d{5}$
^[a-zA-Z]\\d{4}$
^[a-zA-Z]{3}\\d{2}$
And if it's 6 characters, it will be first position letter, 4 numbers, and
last another letter.
^[a-zA-Z]\\d{4}[a-zA-Z]$
I just can't seem to piece it all together though.
I'm trying to validate a form field in Java using Regex, which can have 5
different format possibilities. I'm struggling to get this one working.
The string to be checked will be between 4-6 alphanumeric characters.
If it's 4 characters, it must be all numbers.
^\\d{4}$
If it's 5 characters, it can be all numbers, first position letter with 4
following numbers, or first 3 positions letters followed with 2 numbers.
^\\d{5}$
^[a-zA-Z]\\d{4}$
^[a-zA-Z]{3}\\d{2}$
And if it's 6 characters, it will be first position letter, 4 numbers, and
last another letter.
^[a-zA-Z]\\d{4}[a-zA-Z]$
I just can't seem to piece it all together though.
How to create Instance by java.lang.reflect.Type
How to create Instance by java.lang.reflect.Type
I want to set property of class by using reflect,
and my class have a List<Article> property.
i just get the generics type of the List<Artile> by below code
Method[] methods = target.getClass().getMethods();
String key = k.toString(), methodName = "set" + key;
Method method = getMethod(methods, methodName);
if (Iterable.class.isAssignableFrom(method.getParameterTypes()[0])) {
// at there, i get the generics type of list
// how can i create a instance of this type?
Type type = getGenericsType(method);
}
public static Method getMethod(Method[] methods, String methodName) {
for (Method method : methods) {
if (method.getName().equalsIgnoreCase(methodName))
return method;
}
return null;
}
private static Type getGenericsType(Method method) {
Type[] types = method.getGenericParameterTypes();
for (int i = 0; i < types.length; i++) {
ParameterizedType pt = (ParameterizedType) types[i];
if (pt.getActualTypeArguments().length > 0)
return pt.getActualTypeArguments()[0];
}
return null;
}
EDIT:
i just solved it with a stupid solution,
its instantiation generics type by using Class.forName();
the class name come from type.toString()
Type type = getGenericsType(method);
Class<?> genericsType = null;
try {
genericsType = Class.forName(getClassName(type));
// now, i have a instance of generics type
Object o = genericsType.newInstance();
} catch (Exception e) {
}
static String NAME_PREFIX = "class ";
private static String getClassName(Type type) {
String fullName = type.toString();
if (fullName.startsWith(NAME_PREFIX))
return fullName.substring(NAME_PREFIX.length());
return fullName;
}
I want to set property of class by using reflect,
and my class have a List<Article> property.
i just get the generics type of the List<Artile> by below code
Method[] methods = target.getClass().getMethods();
String key = k.toString(), methodName = "set" + key;
Method method = getMethod(methods, methodName);
if (Iterable.class.isAssignableFrom(method.getParameterTypes()[0])) {
// at there, i get the generics type of list
// how can i create a instance of this type?
Type type = getGenericsType(method);
}
public static Method getMethod(Method[] methods, String methodName) {
for (Method method : methods) {
if (method.getName().equalsIgnoreCase(methodName))
return method;
}
return null;
}
private static Type getGenericsType(Method method) {
Type[] types = method.getGenericParameterTypes();
for (int i = 0; i < types.length; i++) {
ParameterizedType pt = (ParameterizedType) types[i];
if (pt.getActualTypeArguments().length > 0)
return pt.getActualTypeArguments()[0];
}
return null;
}
EDIT:
i just solved it with a stupid solution,
its instantiation generics type by using Class.forName();
the class name come from type.toString()
Type type = getGenericsType(method);
Class<?> genericsType = null;
try {
genericsType = Class.forName(getClassName(type));
// now, i have a instance of generics type
Object o = genericsType.newInstance();
} catch (Exception e) {
}
static String NAME_PREFIX = "class ";
private static String getClassName(Type type) {
String fullName = type.toString();
if (fullName.startsWith(NAME_PREFIX))
return fullName.substring(NAME_PREFIX.length());
return fullName;
}
Based on multiple criterias on parent's siblings
Based on multiple criterias on parent's siblings
I would like to know if I can combine at the same time an XPath looking
for the previous sibling of a certain class with a certain text and at the
same time a sibling at the same level with a certain text.
For example I would like to find the following cells:
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160832)">Book</a></td>
by looking up a sibling of class sdawatt_hrdcell containing the text Spin
preceded by a td of class sdawatt_banner with the text Monday - 16
September 2013.
Or the following td:
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160864)">Book</a></td>
if we look for the date of the 'Friday - 13 September 2013'.
Is this something doable in Xpath ?
<table cellspacing="0" cellpadding="0" border="0"
style="border-collapse:collapse;" class="sdawatt_outer">
<tbody><tr>
<td class="sdawatt_hdrcell">Time</td>
<td class="sdawatt_hdrcell">Class</td>
<td class="sdawatt_hdrcell">Level</td>
<td class="sdawatt_hdrcell">Spaces</td>
<td class="sdawatt_hdrcell">Location</td>
<td class="sdawatt_hdrcell">Instructors</td>
<td class="sdawatt_hdrcell">Tags</td>
<td class="sdawatt_hdrcell">Info</td>
<td class="sdawatt_hdrcell">Book</td>
</tr><tr>
<td colspan="9" class="sdawatt_banner">Friday - 13 September
2013</td>
</tr><tr class="sdawatt_classrow">
<td class="sdawatt_time">07:45-08:15</td>
<td class="sdawatt_classname">Boxing</td>
<td class="sdawatt_level"> </td>
<td class="sdawatt_spaces">14 Left</td>
<td class="sdawatt_location">Main Studio</td>
<td class="sdawatt_resources"> Darren</td>
<td class=" sdawatt_infotags"></td>
<td class="sdawatt_info"><img
src="https://v4.fitnessandlifestylecentre.com/webaccess/TimetableView/information.gif"
class="tiptip" /></td>
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160848)">Book</a></td>
</tr><tr class="sdawatt_classrow">
<td class="sdawatt_time">12:00-12:45</td>
<td class="sdawatt_classname">Spin</td>
<td class="sdawatt_level"> </td>
<td class="sdawatt_spaces">8 Left</td>
<td class="sdawatt_location">Main Studio</td>
<td class="sdawatt_resources"> Matt</td>
<td class=" sdawatt_infotags"></td>
<td class="sdawatt_info"><img
src="https://v4.fitnessandlifestylecentre.com/webaccess/TimetableView/information.gif"
class="tiptip" /></td>
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160864)">Book</a></td>
</tr><tr>
<td colspan="9" class="sdawatt_banner">Monday - 16 September
2013</td>
</tr><tr class="sdawatt_classrow">
<td class="sdawatt_time">13:00-13:45</td>
<td class="sdawatt_classname">Spin</td>
<td class="sdawatt_level"> </td>
<td class="sdawatt_spaces">12 Left</td>
<td class="sdawatt_location">Main Studio</td>
<td class="sdawatt_resources"> Marzena</td>
<td class=" sdawatt_infotags"></td>
<td class="sdawatt_info">
<img
src="https://v4.fitnessandlifestylecentre.com/webaccess/TimetableView/information.gif"
class="tiptip" /></td>
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160832)">Book</a></td>
</tr>
</tbody></table>
I would like to know if I can combine at the same time an XPath looking
for the previous sibling of a certain class with a certain text and at the
same time a sibling at the same level with a certain text.
For example I would like to find the following cells:
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160832)">Book</a></td>
by looking up a sibling of class sdawatt_hrdcell containing the text Spin
preceded by a td of class sdawatt_banner with the text Monday - 16
September 2013.
Or the following td:
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160864)">Book</a></td>
if we look for the date of the 'Friday - 13 September 2013'.
Is this something doable in Xpath ?
<table cellspacing="0" cellpadding="0" border="0"
style="border-collapse:collapse;" class="sdawatt_outer">
<tbody><tr>
<td class="sdawatt_hdrcell">Time</td>
<td class="sdawatt_hdrcell">Class</td>
<td class="sdawatt_hdrcell">Level</td>
<td class="sdawatt_hdrcell">Spaces</td>
<td class="sdawatt_hdrcell">Location</td>
<td class="sdawatt_hdrcell">Instructors</td>
<td class="sdawatt_hdrcell">Tags</td>
<td class="sdawatt_hdrcell">Info</td>
<td class="sdawatt_hdrcell">Book</td>
</tr><tr>
<td colspan="9" class="sdawatt_banner">Friday - 13 September
2013</td>
</tr><tr class="sdawatt_classrow">
<td class="sdawatt_time">07:45-08:15</td>
<td class="sdawatt_classname">Boxing</td>
<td class="sdawatt_level"> </td>
<td class="sdawatt_spaces">14 Left</td>
<td class="sdawatt_location">Main Studio</td>
<td class="sdawatt_resources"> Darren</td>
<td class=" sdawatt_infotags"></td>
<td class="sdawatt_info"><img
src="https://v4.fitnessandlifestylecentre.com/webaccess/TimetableView/information.gif"
class="tiptip" /></td>
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160848)">Book</a></td>
</tr><tr class="sdawatt_classrow">
<td class="sdawatt_time">12:00-12:45</td>
<td class="sdawatt_classname">Spin</td>
<td class="sdawatt_level"> </td>
<td class="sdawatt_spaces">8 Left</td>
<td class="sdawatt_location">Main Studio</td>
<td class="sdawatt_resources"> Matt</td>
<td class=" sdawatt_infotags"></td>
<td class="sdawatt_info"><img
src="https://v4.fitnessandlifestylecentre.com/webaccess/TimetableView/information.gif"
class="tiptip" /></td>
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160864)">Book</a></td>
</tr><tr>
<td colspan="9" class="sdawatt_banner">Monday - 16 September
2013</td>
</tr><tr class="sdawatt_classrow">
<td class="sdawatt_time">13:00-13:45</td>
<td class="sdawatt_classname">Spin</td>
<td class="sdawatt_level"> </td>
<td class="sdawatt_spaces">12 Left</td>
<td class="sdawatt_location">Main Studio</td>
<td class="sdawatt_resources"> Marzena</td>
<td class=" sdawatt_infotags"></td>
<td class="sdawatt_info">
<img
src="https://v4.fitnessandlifestylecentre.com/webaccess/TimetableView/information.gif"
class="tiptip" /></td>
<td class="sdawatt_booknow"><a href="#"
onclick="wa_class_book(160832)">Book</a></td>
</tr>
</tbody></table>
Wednesday, 11 September 2013
how to call a variable outside of function
how to call a variable outside of function
jquery
$(selector).on('click',function(){
var $myvar = 'hi';
});
alert($myvar); // this won't alert hi as this is out of click function
How can I call that $myvar outside the function?
jquery
$(selector).on('click',function(){
var $myvar = 'hi';
});
alert($myvar); // this won't alert hi as this is out of click function
How can I call that $myvar outside the function?
Invoke Java program in Linux using "./"
Invoke Java program in Linux using "./"
Is it possible to invoke a Java program in a Linux command line using a
command like "./hello"?
Is it possible to invoke a Java program in a Linux command line using a
command like "./hello"?
Subscribe to:
Posts (Atom)