Thursday, April 19, 2012

How To Create a Rotating Wheel Control?

I am trying to implement the Rotatory wheel in android, just like the image displayed below.I came across the tutorial from this link. But i want to implement just as shown in the below image.The wheel consists of individual images.Does anybody have any idea regarding this implementation?? Any help would be appreciated.



enter image description here



Thanks in advance.



Akash





Can anyone give me a complete introduction using implementation of MVC 3 with NHibernate for connection with mySQL DB

MVCI am new to MVC and ofcourse to MVC 3. I need a tutorial which explains by implementation of MVC 3 and integrate it with mySQL database using NHibernate. It would be really thankful if employee record is fetched from DB to view but I want this with MySQL.
Thanks in Advance.





Passing & in query string

I want to pass '&' operator in query string. I tried to use urlencode and urldecode
but its not working. I am doing this:



$abc="A & B";
$abc2=urlencode($abc);


Then I am passing the value like this



<a href="hello.php?say=<?php echo $abc2 ?>"><?php echo $abc;?></a>


and getting value on next page as



$abc=$_GET['say'];
$abcd=urldecode($abc');
echo $abcd;


but the output is not A & B



What am I doing wrong?





Generating script when using EclipseLink

I am using EclipseLink as JPA implementation and I am adding these properties in the persistence.xml but I can't see any scripts generated? Where are they supposed to be saved or have I misunderstood this property.



<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="both" />


Is it possible to define a script as well that would be run after the tables are created? The same way as a seed script in Rails?





perl redirection linux

sub cdevice{
$p=$_[0];
$s=$_[1];
$q=$_[2];
try {
$device_create_cmd ="create type:NSR Device;media type:adv_file;name:$p;device access information:$p";
system("echo $device_create_cmd > command.txt ");
} catch Error with {
print "Error " ;
exit();
};
}
cdevice("/device1","raddh054","/device1");


this pl file is working fine on Windows but not on Linux because echo in Linux is not accepting spaces between the text !how do i resolve it





Howto Test Databinding with Rhino Mocks and NUnit

I try to test my SW-Project VS2008, .NET 3.5 with "Rhino Mocks" and "NUnit". It uses the MVP Pattern and Databinding, so nothing unusual. But I get a problem (System.ArgumentException) when I try to test the databinding of my controls which occures on System.Windows.Forms.BindToObject.CheckBinding() and is: Cannot bind to the property or column IsOpened on the DataSource. But this only occures in the test. When I run the project everything is fine ... so this might be a problem of my Test definition e.g. Mock definition?



My project looks like the following: (I describe it here with my words and some code. To paste all code here this post will explode, but you can download it here: http://www.speedshare.org/download.php?id=1FD0FF0D11 Password: test)



I've a Presenter:



public class Presenter
{
IView view;
IModel model;

public Presenter(IView view, IModel model)
{
this.view = view;
this.model = model;

view.Shown += new EventHandler(view_Shown);
}

void view_Shown(object sender, EventArgs e)
{
view.OptionsForm.SpecialOptionsUserControl.CheckBox.DataBindings.Add("Checked", model, "IsOpened", false, DataSourceUpdateMode.OnPropertyChanged);

var dialogResult = view.OptionsForm.ShowDialog();
}
}`


which binds the model to the view when it's shown and opens an OptionsDialog. On the OptionsDialog is a UserControl with a Checkbox.
Now the following test should give a little bit of clearance about my problem:



[TestFixture]
public class PresenterTests
{
[Test]
public void ShouldBindCorrectly()
{
var stubView = MockRepository.GenerateStub<IView>();
var stubModel = MockRepository.GenerateStub<IModel>();

var presenterUnderTest = new Presenter(stubView, stubModel);

stubView.Stub(x => x.OptionsForm).Return(new OptionsForm());

stubView.Raise(x => x.Shown += null, this, EventArgs.Empty);
stubModel.AssertWasCalled(x => x.PropertyChanged += Arg<PropertyChangedEventHandler>.Is.Anything);
}
}


Ok, when I execute this test I get an error in line:
var dialogResult = view.OptionsForm.ShowDialog(); described above. Btw. I'm using Rhino Mocks 3.6 and NUnit 2.5.10.



Thanks for your help... (Please let me know if something is missing or could not be understood in my failure description.) Thanks.



Marco





Counting the number of first place scores with mysql

Ok, so I have the following database:



CREATE TABLE IF NOT EXISTS `highscores` (
`lid` int(11) NOT NULL,
`username` varchar(15) NOT NULL,
`score` int(16) NOT NULL,
PRIMARY KEY (`lid`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


lid being the level id.



lets say I have the following values in the table:



lid, username,score

1,sam,15
1,joe,12
1,sue,6
1,josh,9
2,sam,8
2,joe,16
2,sue,4
3,sam,65
4,josh,87
4,sue,43
5,sam,12
5,sue,28
5,joe,29
and so on.


How would I create a query(or if required a set of queries) to get the following



sam has 3 high scores
joe has 2 high scores
josh has 1 high score


Thanks in advance.