Biniam Asnake

Run the following commands separately to change/reset your ‘root’ user password in MySql database.

There is a database called mysqlwhich is the default database. It is where Users such as root are stored. More info can be found
In this script, it is assumed that your new password is MyNewPassword. Hence, replace that with whatever you want your password to be.

UPDATE mysql.user
SET Password=PASSWORD(‘MyNewPassword’)
WHERE User=’root’;
FLUSH PRIVILEGES;

Originally published at http://binyit.blogspot.com.

--

--

First, Set up your connectionString and use the following code snippet in a method.

using (SqlConnection con = new SqlConnection(connectionString)){

con.Open();

SqlCommand cmd = new SqlCommand("SELECT userid, username, email, city FROM USERS where username=@username and password=@password", con);
cmd.Paramters.AddWithValue("@username", username)…

--

--

When upgrading grails to version 2.3.0, I got the following error.

Failed to resolve dependencies ... 
org.grails.plugins:tomcat:2.3.0 ...
hibernate:2.3.0 ...

This is because as of Grails 2.3.0, the tomcat and hibernate plugins (as well as the scaffolding and webflow plugins) have been split out as completely independent plugins and are…

--

--

Code Example

<script type="text/javascript">
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
document.write("<b>" + day + "/" + month + "/" + year + "</b>")
</script>

The result will be 15/1/2014

--

--

Here is a complete class that shows how another activity is called when a button in the first activity is pressed.

public class FirstActivity extends Activity implements View.OnClickListener {

Button goToSecondActivityButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.first_activity);

((TextView) findViewById(R.id.textRecommendationMessage)).setText("This is the first activity");

goToSecondActivityButton= (Button) findViewById(R.id.button_go_to_second_activity);
goToSecondActivityButton.setOnClickListener(this);
}

@Override
public void onClick(View view) {

goToSecondActivity();
}

private void goToSecondActivity() {

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
finish();
}
}

--

--

If you have a string variable containing a date value such as 2014–06–03T11:03:44.779+03, then:

  1. Convert it to Date using “parse” method of SimpleDateFormat
  2. Format the Date using the format you want such as “yyyy-MM-dd” or “yyyy/MM/dd” or any other.

Code Example

import java.text.SimpleDateFormat 
import java.text.DateFormat
String mydate = “2014–06–03T11:03:44.779+03”
DateFormat formatter = new SimpleDateFormat(“yyyy-MM-dd”)
Date parsedDate = formatter.parse(mydate)
Date formattedDate = formatter.format(parsedDate)
/* Simplified code in one line
Date parsedAndFormattedDate = formatter.format(formatter.parse(mydate))
*/

Originally published at http://binyit.blogspot.com.

--

--