Thursday, 3 October 2013

KVM Ethernet bridge flaky connection and delay

KVM Ethernet bridge flaky connection and delay

libvirt 0.9.10 qemu-kvm CentOS 6, STP enabled bridge. One guest has very
unreliable connection. OS is Win Vista, connection shows ip4 Internet
connected but often 100% packet loss pinging gateway. I run tcpdump on
host when pinging gateway from guest and I dont see the icmp requests
until seconds after the ping timeout. Guest uses br0
bridge name bridge id STP enabled interfaces
br0 8000.90b11c106fec yes em1
vnet0
vnet1
virbr0 8000.525400b7455a yes virbr0-nic

Wednesday, 2 October 2013

Euler character of etale finite cover

Euler character of etale finite cover

Let $\pi: \tilde{X} \to X$ be an etale finite cover, then why the Euler
character has relation:
$$\chi(\tilde{X},\mathcal{O}_{\tilde{X}})=\deg(\pi)\chi({X},\mathcal{O}_{{X}}).$$
I try to use Riemann-Roch, but do not know how to relate Chern characters
and Todd class of them.
Besides, I found a similar question on topological setting.

Intersect not giving expected results

Intersect not giving expected results

In the below code if I iterated over L3 I would expect to have 2 results
available. However it only has one result and that result is the objTest
with a Id = 9. I thought it should be a result set with two objtest s' Id
= 9 and Id = 10.
class Program
{
public class objTest
{
public int Value { get; set; }
public bool On { get; set; }
public int Id { get; set; }
}
class PramComp : EqualityComparer<objTest>
{
public override bool Equals(objTest x, objTest y)
{
return x.Value == y.Value;
}
public override int GetHashCode(objTest obj)
{
return obj.Value.GetHashCode();
}
}
static void Main(string[] args)
{
List<objTest> L1 = new List<objTest>();
L1.Add(new objTest { Value = 1, On = true ,Id =1});
L1.Add(new objTest { Value = 2, On = false ,Id =2});
L1.Add(new objTest { Value = 3, On = false, Id = 3 });
L1.Add(new objTest { Value = 4, On = false ,Id =4});
L1.Add(new objTest { Value = 5, On = false ,Id =5});
List<objTest> L2 = new List<objTest>();
L2.Add(new objTest { Value = 6, On = false ,Id =6});
L2.Add(new objTest { Value = 7, On = false ,Id=7});
L2.Add(new objTest { Value = 8, On = false,Id =8 });
L2.Add(new objTest { Value = 1, On = true,Id =9 });
L2.Add(new objTest { Value = 1, On = true, Id =10 });
var L3 = L2.Intersect(L1, new PramComp());
}
}
So I have made a mistake with my code if I want to return the two results
Id=9 and Id=10. Could someone tell me where my mistake is?

Why System.currentTimeMillis() generate incorrect long value?

Why System.currentTimeMillis() generate incorrect long value?

It was discussed too many times, I know, but I can't get why the
milliseconds generated by mine:
System.currentTimeMillis();
Or by:
Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis()
Are not equal to what I see on http://www.epochconverter.com/?
What I need is to merely generate a String of concrete format, but I've
found out the milliseconds aren't right.
Just in case here is how I do it:
private static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static String getCurrentTimestamp() {
long time = System.currentTimeMillis();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);
String lastModifiedTime = sdf.format(time);
Logger.logVerbose(TAG, "Generated timestamp is " + lastModifiedTime);
return lastModifiedTime;
}
What I finally get is just a local time, but I need the only time which is
pure UTC without conjunction with my timezone.
I've even checked it with SQLite (using the SELECT
strftime('%s',timestring);) and got the correct milliseconds. Why then I
got it incorrectly generated by those two statements I posted above?
Thanks a lot in advance.

WCF WebFaultException ExceptionDetail

WCF WebFaultException ExceptionDetail

I'm creating a WCF service that returns data in JSON Format. I'm trying to
figure out how to best handle exceptions and I'm trying to use the
WebFaultException class to return an exception detail message in the
response, which can later be outputted to the user.
A simple Test of this method I am trying is as follows
The WCF Service method
<WebInvoke(Method:="POST",
ResponseFormat:=WebMessageFormat.Json)>
<OperationContract()>
Public Function Test() As Object
Throw New WebFaultException(Of String)("Message Details",
Net.HttpStatusCode.NotFound)
End Function
From what I found searching for answers to this questions, you should give
the service a behaviorconfiguartion which sets
includeExceptionDetailInFaults to true.
My Web.Config
<service name="WebserviceExceptionTest.Service"
behaviorConfiguration="behavior">
<endpoint address=""
behaviorConfiguration="WebserviceExceptionTest.ServiceAspNetAjaxBehavior"
binding="webHttpBinding"
contract="WebserviceExceptionTest.Service" />
</service>
<serviceBehaviors>
<behavior name="behavior">
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
Unfortunately, this appears to not do the trick for me and the response
still does not include the exception detail, the JSON string looks like
this:
{"ExceptionDetail":null,"ExceptionType":null,"Message":"Not
Found","StackTrace":null}
Does anyone have any idea of what it is I am doing wrong, or am I just
entirely on the wrong path? Thanks!

Tuesday, 1 October 2013

Naive Bayes and Logistic Regression Error Rate

Naive Bayes and Logistic Regression Error Rate

I have been trying to figure out the correlation between the error rate
and the number of features in both of these models. I watched some videos,
and the creator of the video said that a simple model can be better than a
complicated model. So I figured that the more features I had the greater
the error rate would be. This did not prove to be true in my work, and
when I had less features the error rate went up. I'm not sure if I'm doing
this incorrectly, or if the guy in the video made a mistake. Can someone
care to explain? I also am curious how features relate to Logistic
Regression's error rate as well.

jQuery round number to 2 decimal places

jQuery round number to 2 decimal places

I have a little problem that I can't seem to get my head round...
I have figure that I need to find what the VAT element of it would be, I
have the following jQuery which works but it doesn't fix it to 2 decimal
places.
var ThreeMonthPriceFinal = "99.29";
var ThreeMonthPriceVAT = ThreeMonthPriceFinal * 0.2.toFixed(2);
alert(ThreeMonthPriceVAT);
It works out the VAT correctly but adds lots of recurring digits that i
don't need... I can't round it up as with VAT you not really supposed to.
http://jsfiddle.net/Xg4Qs/
The Jfiddle shows £19.858000000000004 I need this to show 19.86, i've
tried the following but it rounds it up to the whole amount not just 1p.
var ThreeMonthPriceVAT = Math.round(ThreeMonthPriceFinal * 0.2).toFixed(2);
Can anyone help me?