Reset your MYSQL Password

Hi friends,

After long time, today i thought of use my MYSQL db, But the thing is i’ve forget my password 😦  Then i asked to my friend mani, “pls help me mani, i ve to reset my MYSQL password urgently. He gave the simple solution”. 🙂

Here the i’m posting the simple steps to reset the mysql root password.

Open your terminal and type the following commands.

First we’ve to stop the mysql service,

  $ sudo service mysqld stop
 $ sudo mysqld_safe --skip-grant-tables

( It runs the mysql in safe mode and the “skip-grant-tables ” skips the table which ‘ve the MYQSL  user passwords )

The above command ‘ll start mysql server, now open a another tab in ur terminal and type this command.

$  mysql --user=root mysql  ( It 'll login as root without password)

Now type the below query in myqsl prompt.

Note: change “new-password” to your new password.  🙂

> update user set Password=PASSWORD('new-password') WHERE User='root';

That’s all     ve fun 🙂


Power of PYTHON and RUBY languages

Hi friends,

Since last week i had worked with Send SMS via rails application. After long search, i found a site called “” which provides API and sends SMS. This site  is very much helpful in sending automated SMS.

They also provide  codes for different languages like “Python, Ruby, PHP, Perl, Java, C, C#, VB.NET”

When i compared the same code for different languages, I was surprised (shocked 😛 )to see that PYTHON and RUBY has the minimal and very efficient code. 🙂


require 'net/http'
require 'uri'
Net::HTTP.get_print URI.parse('<a href=""></a>')


from urllib
import urlopen
print urlopen('').read()

Here are the codes for other languages.


echo file_get_contents("".urlencode('YOUR MESSAGE')."&senderid=YOUR_SENDERID&recipient=MOBILE_NUMBERS");


use strict;

use LWP::UserAgent;

my $ua = new LWP::UserAgent;
my $url='';
my $request = new HTTP::Request('GET', $url);
my $response = $ua->request($request);
my $content = $response->content();
print $content;



public class JavaGetUrl {
public static void main(String[] args) throws Exception {
URL myurl = new URL("");
BufferedReader in = new BufferedReader(
new InputStreamReader(

String inputLine;

while ((inputLine = in.readLine()) != null)



#include <curl/curl.h>

void main() {

long http_code = 0;
CURL *curl;
CURLcode res;

//Initializing the CURL module
curl = curl_easy_init();

if(curl) {

curl_easy_setopt(curl, CURLOPT_URL, "");
res = curl_easy_perform(curl);

if(CURLE_OK == res) {
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);

if(http_code == 200) {
puts("Received 200 status code");
} else {
puts("Did not received 200 status code");
} else {
puts("Could not initialize curl");


using System.IO;
using System.Net;
string connectionString = "";
System.IO.Stream SourceStream = null;
System.Net.HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(connectionString);
myRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse webResponse = (HttpWebResponse)myRequest.GetResponse();
SourceStream = webResponse.GetResponseStream();
StreamReader reader = new StreamReader(webResponse.GetResponseStream());
string str = reader.ReadLine();
catch (Exception ex)
Imports System.IO
Imports System.Net
Dim connectionString As String = ""
Dim SourceStream As System.IO.Stream
Dim myRequest As System.Net.HttpWebRequest = WebRequest.Create(connectionString)
myRequest.Credentials = CredentialCache.DefaultCredentials
Dim webResponse As WebResponse = myRequest.GetResponse
SourceStream = webResponse.GetResponseStream()
Dim reader As StreamReader = New StreamReader(webResponse.GetResponseStream())
Dim str As String = reader.ReadLine()

Catch ex As Exception
End Try


How to Send a mail using Gmail account with Rails3, ActionMailer and SMTP

Hi friends,

Action Mailer:

Action Mailer is a framework for building e-mail services. You can use Action Mailer to receive and process incoming email and send simple plain text or complex multipart emails based on flexible templates.

Lets see how to setup the actionmailer with Gmail SMTP.

First we have to create a rails application using

   $ rails new action_mailer

Next we’ll generate a scaffold for a User model with name and email attributes to act as a simple user-registration page.

$ rails genetate scaffold user name:string email:string

Now we have to migrate with DB.

$ rake db:migrate

The generated scaffolding code includes a page for creating users. We want to create a new user and then send them a confirmation email when the form on this page is submitted.

Now, just run the rails server command,

$ rails s

Then, open the “http://localhost:3000

Adding New User

The first thing we’ll do is create a new initializer file called setup_mail.rb and put some configuration options in it. ActionMailer will use sendmail if it’s set up on your machine but we can instead specify SMTP settings in the initializer.

  $ cd /config/initializers/

  $ gedit setup_mail.rb

ActionMailer::Base.smtp_settings = {  
      :address              => "",  
      :port                 => 587,  
      :domain               => "",  
     :user_name            => "thasuresh", #Your user name
      :password             => "actionmailer", # Your password
      :authentication       => "plain",  
      :enable_starttls_auto => true  

You’ll probably want to use a different approach in a production application but this is a good enough approach while our application is in development. Obviously you’ll want to change the domain, user_name and password options to suit your own Gmail account.

Now that we’ve completed the configuration we can generate a new mailer with the following code:

  $ rails generate mailer user_mailer

$ cd /app/mailer

  $ gedit user_mailer.rb

class UserMailer < ActionMailer::Base
default :from => ""

def registration_confirmation(user)
mail(:to =>, :subject => "Registered")

Now we have to create a file called registration_confirmation.text.erb under app/views/user_mailer.

  $ gedit app/views/user_mailer/registration_confirmation.text.erb

Thank you for registering!

/app/controllers/users_controller.rb  (Note the 6th line)

def create
@user =[:user])

respond_to do |format|
UserMailer.registration_confirmation(@user).deliver  #include this line in your users_controller.rb file
format.html { redirect_to(@user, :notice => 'User was successfully created.') }
format.xml  { render :xml => @user, :status => :created, :location => @user }
format.html { render :action => "new" }
format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }

mail sent by "ActionMailer"

If you want add user name at the mail, add the following line into registration_confirmation.text.erb


<%= %>,

Thank you for registering!

Added User name

Now if you want add any attachments in the mail add this line into /app/mailer/user_mailer.rb

def registration_confirmation(user)
@user = user
attachments["rails.png"] ="#{Rails.root}/public/images/rails.png")
mail(:to => "#{} <#{}>", :subject => "Registered")

Here my need is send a numeric password, when a user subscribe with his mail id. The password will send by actionmailer. So i added the a single ruby command into

Hi <%= %>,

This is the one time password, You can login into our site using the password given below

Password: <%=rand(999999)%>

Thank You For Registering!

Final output 🙂

That’s all !!!

Here sample “actionmailer” application and which deployed in heroku

GitHub Account link:

Constants in Ruby

Hi friends,

In ruby, “Constants” holds a constant value for the life of the ruby program. Constants are variables whose names are “Capitalized” or “Upper case”.


Matz = “yukihiro matsumoto”

puts Matz # => yukihiro matsumoto

if a constant is defined within a “class” or “module”, we can access the constant from within that class or module. if it is defined outside either a class or module, the constant is available globally.

Unlike other languages, a Ruby constant is mutable, that is, we can change its value

Finding Character code Ruby 1.8.7 and 1.9.2

Hi friends,

In Ruby 1.8.7, we can use “?” operator to find the “character code from a character.?a evaluates to the integer 97. Now we can see some examples via “irb”

Ex: (ruby 1.8.7)

> ?a # it shows character code of "a"
=> 97

But in Ruby 1.9.2, we can’t use the “?” operator to find character code from a character.In 1.9.7 , syntax “?a”  is now the same as "a".  There is now an “ord” method of strings to convert a character into its integer code. So we can use the”.ord” method.

Ex:  (ruby 1.9.2)

> ?a    # it won't show the char code, just show as "a"
 => "a"
> "a".ord  # This method ly show char code of "a" in 1.9.7
=> 97


🙂 🙂 🙂

Learning CSS

Hi friends,

Today i didn’t study Rails. i learned something in CSS 🙂 My friend Sathia taught CSS from very basic. Finally i wrote some code for my “nanbenda” project.

width: 960px;
margin: 0 auto;
overflow: hidden;
background: white;

overflow: hidden;
width: 450px;
margin: 5px auto;

margin: 0 3px;
float: left;
list-style-type: none;

width: 960px;
margin: 0 auto;
overflow: hidden;
background: #66CCFF;
text-indent: 39px;

#header a{
background: #CC3399;
text-decoration: none;
padding: 3px 20px;
color: white;
#header a:hover{
background: black;

#red {
color: red;
.container #add_link{
font-size: 14px;
display: block;
width: 200px;
line-height: 18px;
margin-bottom: 10px;
color: white;

This is my first experience with css code

🙂 🙂 🙂

simple css

Tomo i have to learn “cucumber” 😉