What is the fastest way to communicate with Java application?
Consider a setting of a large database and an application which needs to
interact with the database. If you were building it from scratch, what
communication technology would you use, if the objective is to maximize
throughput? Important requirement is, however, that the application using
the database is not written in Java. There is however a relaxed
requirement: it needs not to run on anything other then Linux, and if only
a particular JVM provides this feature, but not the others, I'm ok with
that too.
In other words, I would imagine there must be some kind of foreign
function interface and a way to represent Java objects (at least the most
basic types) in memory and pass them to the Java database w/o ever needing
to print them, open sockets, write on pipes, because all of that would
imply tons of memory de/allocation, de/serialization and so on. But since
I'm not really a Java person, I don't know what I'm looking for.
Thursday, 3 October 2013
Wednesday, 2 October 2013
Coniditions for a Random Variable which is differentiable to be simple
Coniditions for a Random Variable which is differentiable to be simple
Assume that $\Omega=[0,1]$ with Lebesgue measure. Under what conditions is
a random variable $X$ which is differentiable also simple?
Thanks!
Assume that $\Omega=[0,1]$ with Lebesgue measure. Under what conditions is
a random variable $X$ which is differentiable also simple?
Thanks!
jQuery $.each() update div using webservice
jQuery $.each() update div using webservice
I have the following webservice working:
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public List<ServerRoomDisplay> GetData(List<string> urls)
{
List<ServerRoomDisplay> returnList = new List<ServerRoomDisplay>();
foreach (var uri in urls)
{
XDocument xdoc = XDocument.Load(uri);
IEnumerable<XElement> serv = xdoc.Elements();
string ur = "";
string room = "";
string temp = "";
string hum = "";
string dew = "";
foreach (var ser in serv)
{
room = ser.Attribute("host").Value;
ur = "http://" + ser.Attribute("address");
temp =
ser.Descendants("devices").Descendants("device").Descendants("field").Where(x
=> (string)x.Attribute("key").Value ==
"Temp").FirstOrDefault().Attribute("value").Value.ToString();
hum =
ser.Descendants("devices").Descendants("device").Descendants("field").Where(x
=> (string)x.Attribute("key").Value ==
"Humidity").FirstOrDefault().Attribute("value").Value.ToString();
dew =
ser.Descendants("devices").Descendants("device").Descendants("field").Where(x
=> (string)x.Attribute("key").Value ==
"Dewpt").FirstOrDefault().Attribute("value").Value.ToString();
returnList.Add(new ServerRoomDisplay
{
RoomName = room,
Url = ur,
Temperature = temp,
Humidity = hum,
DewPoint = dew,
});
}
}
return returnList;
}
I then pass the parameters via an ajax call. Please note that this method
runs RECURSIVELY as to update the data within the div... like a stock
ticker on eTrade or something.
(function poll() {
var pageUrl = '<%=ResolveUrl("~/Reporting/GetXMLData.asmx")%>'
var urls = ["http://aaa/data.xml", "http://bbb/data.xml",
"http://ccc/data.xml"];
var jsonText = JSON.stringify({ urls: urls });
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: pageUrl + "/GetData",
data: jsonText,
success: function (msg) {
var res = msg.d;
$.each(res, function (i, item) {
$('#<%=lblOutput.ClientID%>').html(res[i].RoomName);
});
},
dataType: "json",
complete: poll,
timeout: 3000
});
})();
which then produces this response:
[{"__type":"ServerRoomDisplay",
"Url":"http://address=\"aaa\"",
"RoomName":"aaa MDF Room 500",
"Temperature":"74.99",
"Humidity":"38",
"DewPoint":"47.65",
"AlarmOne":null,
"AlarmTwo":null,
"AlarmThree":null,
"AlarmFour":null
},
{"__type":"ServerRoomDisplay",
"Url":"http://address=\"bbb\"",
"RoomName":"bbb Room 298",
"Temperature":"77.73",
"Humidity":"39",
"DewPoint":"50.79",
"AlarmOne":null,
"AlarmTwo":null,
"AlarmThree":null,
"AlarmFour":null
},
{"__type":"ServerRoomDisplay",
"Url":"http://address=\"ccc\"",
"RoomName":"ccc Room 601",
"Temperature":"75.32",
"Humidity":"49",
"DewPoint":"54.83",
"AlarmOne":null,
"AlarmTwo":null,
"AlarmThree":null,
"AlarmFour":null
}];
As you can see, it is 3 full objects returned in the json response. I then
have output div to place the data
<div>
<asp:Label ID="lblOutput" runat="server" />
</div>
from the jquery above, i'm testing by trying to list only the "RoomName"
into the div. When I do so, it only ever prints out the LAST item, which
is "ccc Room 601" and that's the only thing in the div.
Can someone please help me to be able to list all of the objects and then
only update the data that changes? basically it should re-write the
lblOutput again and change only the temperature, humidity and dewpoint
info. But it should print out all 3 of the objects. In other words, I
should get the following (for RoomName only right now)
aaa MDF Room 500
bbb Room 298
ccc Room 601
I hope I've explained this well enough. Thank you in advance.
I have the following webservice working:
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public List<ServerRoomDisplay> GetData(List<string> urls)
{
List<ServerRoomDisplay> returnList = new List<ServerRoomDisplay>();
foreach (var uri in urls)
{
XDocument xdoc = XDocument.Load(uri);
IEnumerable<XElement> serv = xdoc.Elements();
string ur = "";
string room = "";
string temp = "";
string hum = "";
string dew = "";
foreach (var ser in serv)
{
room = ser.Attribute("host").Value;
ur = "http://" + ser.Attribute("address");
temp =
ser.Descendants("devices").Descendants("device").Descendants("field").Where(x
=> (string)x.Attribute("key").Value ==
"Temp").FirstOrDefault().Attribute("value").Value.ToString();
hum =
ser.Descendants("devices").Descendants("device").Descendants("field").Where(x
=> (string)x.Attribute("key").Value ==
"Humidity").FirstOrDefault().Attribute("value").Value.ToString();
dew =
ser.Descendants("devices").Descendants("device").Descendants("field").Where(x
=> (string)x.Attribute("key").Value ==
"Dewpt").FirstOrDefault().Attribute("value").Value.ToString();
returnList.Add(new ServerRoomDisplay
{
RoomName = room,
Url = ur,
Temperature = temp,
Humidity = hum,
DewPoint = dew,
});
}
}
return returnList;
}
I then pass the parameters via an ajax call. Please note that this method
runs RECURSIVELY as to update the data within the div... like a stock
ticker on eTrade or something.
(function poll() {
var pageUrl = '<%=ResolveUrl("~/Reporting/GetXMLData.asmx")%>'
var urls = ["http://aaa/data.xml", "http://bbb/data.xml",
"http://ccc/data.xml"];
var jsonText = JSON.stringify({ urls: urls });
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: pageUrl + "/GetData",
data: jsonText,
success: function (msg) {
var res = msg.d;
$.each(res, function (i, item) {
$('#<%=lblOutput.ClientID%>').html(res[i].RoomName);
});
},
dataType: "json",
complete: poll,
timeout: 3000
});
})();
which then produces this response:
[{"__type":"ServerRoomDisplay",
"Url":"http://address=\"aaa\"",
"RoomName":"aaa MDF Room 500",
"Temperature":"74.99",
"Humidity":"38",
"DewPoint":"47.65",
"AlarmOne":null,
"AlarmTwo":null,
"AlarmThree":null,
"AlarmFour":null
},
{"__type":"ServerRoomDisplay",
"Url":"http://address=\"bbb\"",
"RoomName":"bbb Room 298",
"Temperature":"77.73",
"Humidity":"39",
"DewPoint":"50.79",
"AlarmOne":null,
"AlarmTwo":null,
"AlarmThree":null,
"AlarmFour":null
},
{"__type":"ServerRoomDisplay",
"Url":"http://address=\"ccc\"",
"RoomName":"ccc Room 601",
"Temperature":"75.32",
"Humidity":"49",
"DewPoint":"54.83",
"AlarmOne":null,
"AlarmTwo":null,
"AlarmThree":null,
"AlarmFour":null
}];
As you can see, it is 3 full objects returned in the json response. I then
have output div to place the data
<div>
<asp:Label ID="lblOutput" runat="server" />
</div>
from the jquery above, i'm testing by trying to list only the "RoomName"
into the div. When I do so, it only ever prints out the LAST item, which
is "ccc Room 601" and that's the only thing in the div.
Can someone please help me to be able to list all of the objects and then
only update the data that changes? basically it should re-write the
lblOutput again and change only the temperature, humidity and dewpoint
info. But it should print out all 3 of the objects. In other words, I
should get the following (for RoomName only right now)
aaa MDF Room 500
bbb Room 298
ccc Room 601
I hope I've explained this well enough. Thank you in advance.
Regex - word that contains a defined number letters between a series of letters
Regex - word that contains a defined number letters between a series of
letters
For example, I have these letters: a b c d e f g h l m n i i a b, how do I
find the words with a regex that can be formed with 5 of these letters?
letters
For example, I have these letters: a b c d e f g h l m n i i a b, how do I
find the words with a regex that can be formed with 5 of these letters?
How to stop supporting iOS7
How to stop supporting iOS7
I have just installed xCode 5, and I have an application the should be
targetted only to iOS 6.0 and iOS 6.1 devices.
How can I stop supporting iOS 7.0 ??
I have just installed xCode 5, and I have an application the should be
targetted only to iOS 6.0 and iOS 6.1 devices.
How can I stop supporting iOS 7.0 ??
Tuesday, 1 October 2013
how to create an array with default value in scala?
how to create an array with default value in scala?
I'm working on eclipse under ubuntu 12.04 with scala 2.10 and Akka 2.2.1.
val algorithm = if(args(0) > 1)()=> new A else ()=> new B // A and B
are derived from Node
class work(algorithm: ()=> Node, num: Int){
val a = new Array[Node](num)(algorithm) // here I wanna create an
array with num slots
// and objects of A or B in it
}
I read this post Default value for generic data structure, it does not
work. Eclipse reports
"type mismatch; found: ()=>Node required: Int".
I have no idea how to fix it. Thanks!
I'm working on eclipse under ubuntu 12.04 with scala 2.10 and Akka 2.2.1.
val algorithm = if(args(0) > 1)()=> new A else ()=> new B // A and B
are derived from Node
class work(algorithm: ()=> Node, num: Int){
val a = new Array[Node](num)(algorithm) // here I wanna create an
array with num slots
// and objects of A or B in it
}
I read this post Default value for generic data structure, it does not
work. Eclipse reports
"type mismatch; found: ()=>Node required: Int".
I have no idea how to fix it. Thanks!
Can't call event from button
Can't call event from button
I have three different events:
form_load
button_click
pnlTiles_Paint
My button click event I have:
private void btnUpdate_Click(object sender, EventArgs e)
{
pnlTiles.Paint += pnlTiles_Paint;
}
My form_load event I have:
private void frmMain_Load(object sender, EventArgs e)
{
pnlTiles.Paint += pnlTiles_Paint;
}
Now my problem is that the event gets called when I use it in form_load
but when I use it in the button event; it just skips over the event, I
tried to step into the event when debugging the button click. But I made
no progress on trying to figure out why the event doesn't get called from
the button.
I have three different events:
form_load
button_click
pnlTiles_Paint
My button click event I have:
private void btnUpdate_Click(object sender, EventArgs e)
{
pnlTiles.Paint += pnlTiles_Paint;
}
My form_load event I have:
private void frmMain_Load(object sender, EventArgs e)
{
pnlTiles.Paint += pnlTiles_Paint;
}
Now my problem is that the event gets called when I use it in form_load
but when I use it in the button event; it just skips over the event, I
tried to step into the event when debugging the button click. But I made
no progress on trying to figure out why the event doesn't get called from
the button.
cannot see RS232 serial data on Raspberry Pi [migrated]
cannot see RS232 serial data on Raspberry Pi [migrated]
I have a Model B Raspberry Pi and an Serial Pi RS232 Interface. I am
running Raspbian Wheezy on my RPi.
I configured the RPi using a Serial Guide, with particular attention to
the section titled "Reconfigure the RPi console port to to be used as a
standard serial port".
I used a null modem to connect a Windows PC to the RPi. The PC ran
TeraTerm and the RPi ran minicom. I configured both as follows:
Baud Rate = 115200, Data Bits = 8, Parity = NONE, Stop Bits = 1, Flow
Control = NONE
This worked perfectly in both directions.
I need to log the data, I assumed something like this would work:
cat /dev/ttyAMA0 > /var/log/ttyAMA0.log
But it doesn't log anything. I tried just this, and nothing is output to
the screen:
cat /dev/ttyAMA0
Does anyone have any ideas or suggestions?
I have a Model B Raspberry Pi and an Serial Pi RS232 Interface. I am
running Raspbian Wheezy on my RPi.
I configured the RPi using a Serial Guide, with particular attention to
the section titled "Reconfigure the RPi console port to to be used as a
standard serial port".
I used a null modem to connect a Windows PC to the RPi. The PC ran
TeraTerm and the RPi ran minicom. I configured both as follows:
Baud Rate = 115200, Data Bits = 8, Parity = NONE, Stop Bits = 1, Flow
Control = NONE
This worked perfectly in both directions.
I need to log the data, I assumed something like this would work:
cat /dev/ttyAMA0 > /var/log/ttyAMA0.log
But it doesn't log anything. I tried just this, and nothing is output to
the screen:
cat /dev/ttyAMA0
Does anyone have any ideas or suggestions?
install_driver(mysql) failed: Unable to get DBI state function. DBI not loaded
install_driver(mysql) failed: Unable to get DBI state function. DBI not
loaded
I installed OTRS from a rpm and the web installer /orts/installer.pl stops
with:
Error during AJAX communication. Status: error, Error: Internal Server Error
Apache error_log
install_driver(mysql) failed: Unable to get DBI state function. DBI not
loaded.
/opt/otrs/bin/otrs.CheckModules.pl
DBD::mysql.......................FAILED! Not all prerequisites for this
module correctly installed. YAML::XS.........................Not
installed! (required - use "perl -MCPAN -e shell;" - )
But sudo zypper install perl-DBD-mysql-4.021-27.2.x86_64.rpm has Nothing
to do. and mysql configuration is set as the manual requested.
System is SLES 11 SP2 (x86_64) and special thing: No internet connection!
I guess the question is: Why doesn't perl find DBI:mysql while it's
installed?
loaded
I installed OTRS from a rpm and the web installer /orts/installer.pl stops
with:
Error during AJAX communication. Status: error, Error: Internal Server Error
Apache error_log
install_driver(mysql) failed: Unable to get DBI state function. DBI not
loaded.
/opt/otrs/bin/otrs.CheckModules.pl
DBD::mysql.......................FAILED! Not all prerequisites for this
module correctly installed. YAML::XS.........................Not
installed! (required - use "perl -MCPAN -e shell;" - )
But sudo zypper install perl-DBD-mysql-4.021-27.2.x86_64.rpm has Nothing
to do. and mysql configuration is set as the manual requested.
System is SLES 11 SP2 (x86_64) and special thing: No internet connection!
I guess the question is: Why doesn't perl find DBI:mysql while it's
installed?
Subscribe to:
Comments (Atom)