How to reset a Magento password using Mysql Server

If you are unable to log in to your magento application? Follow the below steps to reset your magento store password from Mysql server.

Step1: Select your database from the Mysqlserver.

Step2: Find admin_user table from the selected database.

Step3: In that table, edit the user which you want to reset their admin password.

Step4: For security reason, Magento will store the password in MD5 Hash encrypted format and also uses a salt calculate the hash . The password was stored in the password field value.

Step5: Generate the password in the following format md5(salt + password):salt

[php]
i.e,
$salt = "blog";
$password = "123456";
echo md5($salt.$password).":".$salt;
[/php]

Step6: Now password was generated successfully, update the table with the password to the selected user.

Password was changed successfully, Now you can log in to your magento application.

Permanent link to this article: https://blog.openshell.in/2013/09/how-to-reset-a-magento-password-using-mysql-server/

How to Reset a WordPress Password from Mysql Server

Its essential thing to knowing, how to reset the wordpress password from Mysql server without following traditional method. Because your site may hacked, you may forgot your admin password and its email id to reset the password, you are no longer able to login into wordpress using login credentials. This method will very useful to reset your password.

Follow the below steps to reset your wordpress password from Mysql server:

Step1: Select your database from the Mysql Server.

Step 2: Select the *_users table from your selected database.

Step 3: In that table, edit the user which you want to reset the password.

Step 4: Due to security reasons, WordPress stores the passwords as MD5 Hash rather than Plain text. The password was stored in the user_pass field value.

Step 5: Generate your password with MD5 hash method and update the field value of the respective user in that table.

Now, You have successfully changed your wordpress password.

Permanent link to this article: https://blog.openshell.in/2013/09/how-to-reset-a-wordpress-password-from-mysql-server/

Find number of working days between two dates in Mysql

This which helps to find number of working days between two dates in Mysql. There is no specific or inbuilt function in mysql, For that we need to use the SQL query as below.

[sql]
SELECT 5 * ((DATEDIFF(@end_date, @start_date) ) DIV 7) + MID(‘0123455501234445012333450122234501101234000123450’, 7 * WEEKDAY(@start_date) + WEEKDAY(@end_date) + 1, 1)
[/sql]

For the Reference, i have given the URL: http://stackoverflow.com/questions/1828948/mysql-function-to-find-the-number-of-working-days-between-two-dates, Kindly review this link for more information about the Days calculation.

Permanent link to this article: https://blog.openshell.in/2013/08/find-number-of-working-days-between-two-dates-in-mysql/

Java Essential Tips: Automatic Resource Management

Java7 introduced many features that simplifies coding which are overhead in older Java versions. In this blog we will see the feature called Automatic Resource Management.
This is really a good feature in Java7 which close the resources like IO streams automatically. Everything you need to do is implement java.lang.AutoCloseable.

try-with-resources Statement

try-with-resources statement simply has the instantiation of any AutoClosable type in try statement with or without catch/finally block and it will be closed regardless of whether the try statement completes normally or abruptly. For example check the following code:
public String readMyFile(String path) throws IOException{
try(BufferReader reader=new BufferedReader(new FileReader(path)){
return reader.readLine()
}
}

The java.io.BufferedReader in Java 7 or later, implements the interface java.lang.AutoCloseable so that it will be automatically closed once the execution is done.

Note: A try-with-resources statement can have catch and finally blocks just like an ordinary try statement. In a try-with-resources statement, any catch or finally block is run after the resources declared have been closed.

Permanent link to this article: https://blog.openshell.in/2013/08/java-essential-tips-automatic-resource-management/

MySQL Error – SQL_BIG_SELECTS

While executing JOIN SQL query in live server, i got the following error.

[code]
The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay:
[/code]

To resolve this error, I have used the following SQL query before executing the JOIN SQL query.

[sql]
SET OPTION SQL_BIG_SELECTS=1;
[/sql]

Permanent link to this article: https://blog.openshell.in/2013/08/mysql-error-sql_big_selects/

Turn off resize textarea

It is very easy to turn off the users ability to resize the textarea. To turn off this feature, use the following css code. This is used to remove the users ability to resize the textarea.

[css]
textarea{resize: none}
[/css]

The two properties that can be used are max-width and max-height. This will give the user the ability to resize
the textarea but limit them to a certain max size. Use the following css command to fix the textarea resizing limit.

[css]
textarea{max-width: 100px; max-height: 100px;}
[/css]

Permanent link to this article: https://blog.openshell.in/2013/07/turn-off-resize-textarea/

How to Compare Two Versions of the Same Word Document in Office 2010

1) Open the word document in Office 2010, Click the Review tab and choose Compare -> Compare.

The Compare Documents dialog box shows up.

document_compare

2) Select the original document from the Original Document drop-down list.

If you can’t find the original document, click the wee folder icon to browse for it.

3) Select the edited document from the Revised Document drop-down list.

Like with the original document, you can locate the revised one by clicking the folder icon to browse.

4) Click OK.

Word compares the two documents and notes all changes. Then it displays a list of changes, the compared document with changes marked, plus the original and revised documents.

5) If your screen doesn’t display all the information it should, click the Compare button again and, from its menu, choose Show Source Documents -> Show Both.

Look it over! Peruse the changes made to your pristine prose by the barbarian interlopers; use the Reviewing pane to witness each change individually.

6) Click a change in the Reviewing pane if you want to see which part of your document was folded, spindled, or mutilated.

Each reviewer is given his or her own color on your screen. For example, the writer’s revision marks may appear in red, but had a second person reviewed the text, those comments would appear in a second color, and so on for other reviewers.

Permanent link to this article: https://blog.openshell.in/2013/06/how-to-compare-two-versions-of-the-same-word-document-in-office-2010/

How to remove dead node out of the Cassandra cluster?

This tutorial will helps you to remove unused / dead node from the cassandra cluster ring.

Run the following command in console to list the cluster node ring formation.

[code] nodetool -h <cluster-ip1> ring [/code]

Results of the command it list details as like below:

[code]
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
129134720650856572100467877009544391173
Cassandra rack1 Up Normal 2.13 GB 36.19% 20560443149910729499380876119296925598
Cassandra rack1 Up Normal 60.37 MB 63.81% 129134720650856572100467877009544391173
Cassandra rack1 Up Normal 1.37 GB 40.30% 234992374923402342349239423423423432123
[/code]

To remove unused / dead node from cluster ring follow the below instruction:

Run nodetool removetoken from one of the up nodes

[code] nodetool removetoken 20560443149910729499380876119296925598 [/code]

Run nodetool cleanup on each node

[code] nodetool cleanup [/code]

If you run the command agian, you can see the given token node has been removed from custer ring.

[code] nodetool -h <cluster-ip1> ring [/code]

Results of the command it list details as like below:

[code]
Note: Ownership information does not include topology, please specify a keyspace.
Address DC Rack Status State Load Owns Token
129134720650856572100467877009544391173
Cassandra rack1 Up Normal 60.37 MB 63.81% 129134720650856572100467877009544391173
Cassandra rack1 Up Normal 1.37 GB 40.30% 234992374923402342349239423423423432123
[/code]

Permanent link to this article: https://blog.openshell.in/2013/05/how-to-remove-dead-node-out-of-the-cassandra-cluster/

Mysql GROUP_CONCAT

MySQL has useful extention to the GROUP BY operation – function GROUP_CONCAT:

GROUP_CONCAT(expr) – This function returns a string result with the concatenated non-NULL values from a group.

Returns NULL when there are no non-NULL values.

Where it can be useful?

For example to get array without looping inside the code, In single SQL query we can get it.

[sql]
CREATE TABLE services (
id INT UNSIGNED NOT NULL,
client_id INT UNSIGNED NOT NULL,
KEY (id));

INSERT INTO services
VALUES (1,1),(1,2),(3,5),(3,6),(3,7);

SELECT id,client_id FROM services WHERE id = 3;
+—-+———–+
| id | client_id |
+—-+———–+
| 3 | 5 |
| 3 | 6 |
| 3 | 7 |
+—-+———–+

SELECT id,GROUP_CONCAT(client_id) FROM services WHERE id = 3 GROUP BY id;
+—-+————————-+
| id | GROUP_CONCAT(client_id) |
+—-+————————-+
| 3 | 5,6,7 |
+—-+————————-+

SELECT id,GROUP_CONCAT(DISTINCT client_id ORDER BY client_id DESC SEPARATOR ‘ ‘) FROM services GROUP BY id;

+—-+————————————————————————+
| id | GROUP_CONCAT(DISTINCT client_id ORDER BY client_id DESC SEPARATOR ‘ ‘) |
+—-+————————————————————————+
| 1 | 2 1 |
| 3 | 7 6 5 |
+—-+————————————————————————+
[/sql]

The above MySQL statement will return unique client_id’s, as a list of strings separated by the specified separator ‘ ‘(space) in descending order for each group of ‘id’ from the services table. The order can be changed in ascending, using ‘ASC’ option instead of ‘DESC’ at the end of the select statement.

Permanent link to this article: https://blog.openshell.in/2013/05/mysql-group_concat/

Connect MS SQL Server with Rails

To connect MS SQL Server with Ruby on Rails follow the below steps:

SQL Server (2005 or higher recommended)

Install the adapters and driver

[code]
gem install tiny_tds
gem install activerecord-sqlserver-adapter
[/code]

Ensure the activerecord adapter and db driver gems are defined in your Gemfile

[code]
gem ‘tiny_tds’
gem ‘activerecord-sqlserver-adapter’
[/code]

Permanent link to this article: https://blog.openshell.in/2013/04/connect-ms-sql-server-with-rails/