Wednesday, September 28, 2016
get the value of selected option in a select box using jQuery
0 comments Posted by Duc Nguyen at 6:58 PM
$(document).ready(function(){
$("select.country").change(function(){
var selectedCountry = $(".country option:selected").val();
alert("You have selected the country - " + selectedCountry);
});
});
Labels: ASP.net, Javascript, jquery
Friday, September 9, 2016
Until just this month one of the best Kinect 2 integration tools was hidden, like Rappuccini’s daughter, inside a walled garden. Microsoft released a Unity3D plugin for the Kinect 2 in 2014. Unfortunately, Unity 4 only supported plugins (bridges to non-Unity technology) if you owned a Unity Pro license which typically cost over a thousand dollars per year.
On March 3rd, Unity released Unity 5 which includes plugin support in their free Personal edition – making it suddenly very easy to start building otherwise complex experiences like point cloud simulations that would otherwise require a decent knowledge of C++. In this post, I’ll show you how to get started with the plugin and start running a Kinect 2 application in about 15 minutes.
(As an aside, I always have trouble keeping this straight: Unity has plugins, openFrameworks as add-ins, while Cinder has bricks. Visual Studio has extensions and add-ins as well as NuGet packages after a confusing few years of rebranding efforts. There may be a difference between them but I can’t tell.)
1. First you are going to need a Kinect 2 and the Unity 5 software. If you already have a Kinect 2 attached to your XBox One, then this part is easy. You’ll just need to buy a Kinect Adapter Kitfrom the Microsoft store. This will allow you to plug your XBox One Kinect into your PC. The Kinect for Windows 2 SDK is available from the K4W2 website, though everything you need should automatically install when you first plug your Kinect into your computer. You don’t even need Visual Studio for this. Finally, you can download Unity 5 from the Unity website.
Friday, September 2, 2016
internal
class
Program
{
private
static
void
Main()
{
List<
double
> data =
new
List<
double
> {1, 2, 3, 4, 5, 6};
double
mean = data.Mean();
double
variance = data.Variance();
double
sd = data.StandardDeviation();
Console.WriteLine(
"Mean: {0}, Variance: {1}, SD: {2}"
, mean, variance, sd);
Console.WriteLine(
"Press any key to continue..."
);
Console.ReadKey();
}
}
public
static
class
MyListExtensions
{
public
static
double
Mean(
this
List<
double
> values)
{
return
values.Count == 0 ? 0 : values.Mean(0, values.Count);
}
public
static
double
Mean(
this
List<
double
> values,
int
start,
int
end)
{
double
s = 0;
for
(
int
i = start; i < end; i++)
{
s += values[i];
}
return
s / (end - start);
}
public
static
double
Variance(
this
List<
double
> values)
{
return
values.Variance(values.Mean(), 0, values.Count);
}
public
static
double
Variance(
this
List<
double
> values,
double
mean)
{
return
values.Variance(mean, 0, values.Count);
}
public
static
double
Variance(
this
List<
double
> values,
double
mean,
int
start,
int
end)
{
double
variance = 0;
for
(
int
i = start; i < end; i++)
{
variance += Math.Pow((values[i] - mean), 2);
}
int
n = end - start;
if
(start > 0) n -= 1;
return
variance / (n);
}
public
static
double
StandardDeviation(
this
List<
double
> values)
{
return
values.Count == 0 ? 0 : values.StandardDeviation(0, values.Count);
}
public
static
double
StandardDeviation(
this
List<
double
> values,
int
start,
int
end)
{
double
mean = values.Mean(start, end);
double
variance = values.Variance(mean, start, end);
return
Math.Sqrt(variance);
}
}
Subscribe to:
Posts (Atom)