Saturday, 27 September 2014

Shortest Job First ( SJF) Algorithm in java with graph plot and dynamic process burst time.

Shortest Job First ( SJF) Algorithm in java with graph plot and dynamic process burst time.

This program is an  example of how computer arranges the processes while executing different process. This is one of the oldest and the easiest processing technique.
                               What it does is that it basically checks for the shortest job in the queue and executes it first so that the larger task are pushed at last.
                                I have demonstrated it using a graph where y axis shows waiting time and x axis shows process id's.


 
P_ID is Process ID
P_TIME is Process time required.
W_TIME is the wating time calculated by the machine based on the SJF Algorithm.

Note: The program takes dynamic P_TIME, So you will always get a different graph.

The class name defined here is sjf make sure if you use different class names change the sjf to your class name.

 CODE:

 import javax.swing.*;

import java.awt.*;
import java.awt.geom.Rectangle2D;

class sjf extends JPanel {
  
 static    int process1[] = new int[3];
 static    int ptime1[] = new int[3];
 static    int wtime1[] = new int[3];
 static    int n,total1;
 static float avg1;

    public static void main(String args[])
    {
        int process[] = new int[3];
        int ptime[] = new int[3];
        int wtime[] = new int[3];
        int temp, total=0;
        float avg=0;
      
        long l=System.currentTimeMillis()%10;
      
        n=3;
        process[0]=1;
        process[1]=2;
        process[2]=3;
      
          if(l>=5)
          {
              
                   ptime[2]=(int)(l-3);
                   ptime[1]=(int)(l-4);
                   ptime[0]=(int)(l-5);
              
          }
        
          if(l<5)
          {
               ptime[2]=(int)(l);
               ptime[1]=(int)(l+2);
               ptime[0]=(int)(l+5);
             
            
          }
      
      
  
        for(int i=0;i<n-1;i++)
        {
            for(int j=i+1;j<n;j++)             {                 if(ptime[i]>ptime[j])
                {
                    temp = ptime[i];
                    ptime[i] = ptime[j];
                    ptime[j] = temp;
                    temp = process[i];
                    process[i] = process[j];
                    process[j] = temp;
                }
            }
        }

        wtime[0] = 0;
        for(int i=1;i<n;i++)
        {
            wtime[i] = wtime[i-1]+ptime[i-1];
            total = total + wtime[i];
        }
        total1=total;
        avg = (float)total/n;
        avg1=avg;
        for(int i=0;i<n;i++)
        {
            process1[i]=process[i];
            ptime1[i]=ptime[i];
            wtime1[i]=wtime[i];
          
        }
      
      
      
         JFrame f1 = new JFrame();
         f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         f1.getContentPane().add(new sjf()); //remember sjf() is the name of the class you seen above 
//so change it same as your class name. 
         f1.setSize(400,400);
         f1.setLocation(200,200);
         f1.setVisible(true);     
    }

    /**
     *
     */
    final int PAD = 20;
 
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        int w = getWidth();
        int h = getHeight();
      
        int v=30;
        g2.drawString("P_ID    P_TIME    W_TIME",200,30);
      
      
        for(int i=0;i<n;i++)
        {
            v=v+20;
            String s= Integer.toString(process1[i]);
          
            g2.drawString("   "+s+"                "+ptime1[i]+"                    "+wtime1[i],200,v);  
          
        }
        v=v+20;
        g2.drawString("Total Waiting Time: "+total1,200,v);
        v=v+20;
        g2.drawString("Average Waiting Time: "+avg1,200,v);
      
      
        g2.drawLine(PAD, PAD, PAD, h-PAD);
        g2.drawLine(PAD, h-PAD, w-PAD, h-PAD);
     
        g2.setPaint(Color.red);
     

        g2.drawString("0",15 ,h-10);
        g2.drawString("1",35 ,h-10);
        g2.drawString("2",65 ,h-10);
        g2.drawString("3",95 ,h-10);
      
        g2.drawString("P",65 ,h);
        g2.drawString("I",95 ,h);
        g2.drawString("D",125 ,h);
     
        g2.drawString("1",10 ,h-40);
        g2.drawString("2",10 ,h-70);
        g2.drawString("3",10 ,h-100);
        g2.drawString("4",10 ,h-130);
        g2.drawString("5",10 ,h-160);
        g2.drawString("6",10 ,h-190);
        g2.drawString("7",10 ,h-220);
        g2.drawString("8",10 ,h-250);
        g2.drawString("9",10 ,h-280);
        g2.drawString("10",5 ,h-310);
 
        g2.drawString("E",2 ,h-30);
        g2.drawString("M",2 ,h-50);
        g2.drawString("I",2 ,h-70);
        g2.drawString("T",2 ,h-90);
      
        g2.drawString("G",2 ,h-130);
        g2.drawString("N",2 ,h-150);
        g2.drawString("I",2 ,h-170);
        g2.drawString("T",2 ,h-190);
        g2.drawString("A",2,h-210);
        g2.drawString("w",2 ,h-230);
   
        for(int i=0;i<n;i++)
        {
            int x=process1[i]*30;
            int wait=wtime1[i]*30;
            g2.draw(new Rectangle2D.Double(x,h-PAD-wait,20,wait));
        }     } }//END

If you get any problem in running the code please let me know or if you dont understand anything you can leave a comment or mail me. 

Dont forget to say thanks :P
Take care, Have a great day ahead :)
By Sirus 



 

Thursday, 28 August 2014

How to root Ambrane tablets and Ambrane tablet drivers.

How to root Ambrane tablets and Ambrane tablet drivers. 


Friends lets get on a task which was a bit difficult previously but its now possible.

Step 1: We need to get drivers for our Ambrane tablet. I had AC-7 tablet but this process will work                  for all unknown tablets including Ambrane. But do at your own risk.
Step 2: 

 It won’t work for every model, it should help quite a few of us with rooting our China phones. Please report back in the comment section whether the PDAnet drivers worked for you, and what model phone you use so we can aggregate a list here. Especially for the more popular phones such as UMi X1, JiaYu G3, Amoi N821, JiaYu G2, Lenovo A789 etc…
This tutorial can be used in conjunction with my previous post regarding the generic root procedure for Android Ice Cream Sandwich 4.0 and Android Jelly Bean 4.1. As I wrote before, that method should root most phones, but it is required to be able to access the phone via debugging mode in Windows which is where these drivers come in.
Again, please report back with your success or lack of. Much appreciated.
NOTE: Before continuing, disconnect your Android smartphone from your PC. Do not connect until PDAnet prompts you to do so.
1) Download the appropriate PDAnet installer:
2) Open the .zip download and extract the installer. Run the extracted file. If you have User Account Control turned on, you will see a warning. Select ‘Yes’ to continue.
3) Accept the terms of the install and click next until you see ‘Phone Selection’. Assuming it’s a China phone or anything other than what’s named select ‘Others’.
4) Another warning may pop up letting you know Windows can’t verify the publisher of the driver. Select ‘Install anyway’
5) Before connecting your Android phone via USB, turn on ‘USB debugging’ in settings. After turning this mode on, connect the Android smartphone to your PC and click ‘okay’. If prompted, select ‘Install the software automatically’.
6) After the install is finished, you will see a window with several options. For our purposes, DESELECT all options and click ‘finish’.
7) At this point, the ADB driver install should be complete – hopefully successfully. You should see your phone in ‘Device Manager’ now without any warnings assuming everything went well.
8) Report here in comments or via email to bLACKsTARs if the PDAnet ADB driver install worked or didn’t for you and what model phone.
9)
Came across this excellent video and software for rooting almost any Android 4.0 Ice Cream Sandwich or Android 4.1 Jelly Bean smartphone.
First you will need to install the PDAnet ADB drivers to root your MTK6575 and MTK6577 phone. PDAnet ADB Drivers
The JiaYu G2S has been successfully rooted with this method, so we do know that it will work with at least some MTK China phones.
Please report back to bLACKsTARs and comment in this post with your success and any links to ADB drivers you may have.
Root Software Download Link (opens in new tab)

10) If u feeling bored watching this video. Once u downloaded the software and unzipped it open the folder and u will get a file name RunMe.bat ... double click and run it. If ur device appears then its ok or else disconnect and reconnect your device. Then follow the instructions.
Feel free to say thanks :)  

Tuesday, 4 February 2014

To change password of mysql using php file for xampp and others whose phpmyAdmin is not working i.e showing Access Denined


To change password of mysql using php file.

Note:
        

 1. Install Apachi tomcat web server or download xampp which is easiest to configure.


2. Download the files below and paste it in the folder. For xampp it  "C:\xampp\htdocs".

3. In XAMPP control pannel make sure Apachi and mysql are started.

Solving this error:
Install xampp and then open its control panel
2. Start service Apache and MySQL
3.Go to Web browser and type localhost.

Now you can see that xampp page is loaded.
If you want to run php or html or jsp or any web page you need to copy those pages into htdocs folder i.e
Or you can create a folder under htdocs and then paste your file in it.


Now at your web browser type “localhost/your_file_name.extension” and hit enter.

This is how you can run a page on a server.
Or if you have a folder inside htdocs follow this

Sqlconnet is a folder inside htdocs and i have connect.php inside sqlconnect folder.

HOW TO CHANGE MYSQL DATABASE PASSWORD

Once you are done with all configuration and pasted connect.php and pswdchng.php inside your htdocs folder i.e

Now follow this....
Open web browser and type this....
Or simple “localhost/connect.php”
Now follow the images below


Password by default is root or nothing i.e blank.
Click on connect and wait.

New page shows successfully connected to database.
So now you can change your password.
NOTE: Keep your new password blank if you want to access phpmyAdmin and click changepassword button.


Now goto phpmyAdmin link and check...


You are done J


Any query feel free to contact me at sirusdas@gmail.com




Saturday, 2 November 2013

HOW effective ARE YOU......

HOW effective ARE YOU......

Here there is nothing like percentage to check you effectiveness but it will help you 100% to be effective and best of what you have.

This is truly a psychological and a perfect way to find how efficient you are in your daily life.

Many of us just live our life as usual but somehow we always try to make it better and effective than the previous day.
                           We are usually busy with thousands of thoughts in our brain, but you must have never thought about how actually our brain works.

One best part of our brain is that we can train it as we want, its the best part of our brain, but there is also a disadvantage of this, 
                                            If  training of brain is done in wrong way then it will lead to sorrow, unhappiness, defeat at work and many more.
                                            So a perfect training is important to be successful and happy.

TIPS TO TRAIN YOUR BRAIN 

  1. Learn everything good around you, keep smiling in all difficult situation and never forget that, it will take time to be what you want to be just like it took years for you to grow.


  2. Control you brain to a particular task for a particular time it will increase your accuracy and speed.
  3. Think about your next step before you take it, plan for perfection.
  4. Plan your day in such a way that you don't miss any thing.
  5. Everyday should include good food, sufficient sleep, healthy exercise. Exercise should be done for both brain and body. 
  6. Brain exercise will include puzzle games, study, research etc. 
  7. In body exercise try to target on different parts of body everyday. At least walk few kilometers if you don't love exercise.
  8. Sleep sufficiently as it repairs both brain and body and make you stronger.
  9. Try to make habits of the above mention steps and don't stop here, mind is a 'endless power' utilize it and make more steps and always remember "What you sow is What you reap". So don't stop make yourself effective.


Sunday, 27 October 2013

Why? Root an Android Device


 Now a days rooting an Android device is quite an easy job. But very few of us actually know what rooting is all about. 
                               Today we are going to  see how actually rooting takes place and what we actually need to root an Android device.

 Process Details:
                           
The process of rooting varies widely by device, but usually includes exploiting a security bug(s) in the firmware (i.e. in Android) of the device, and then copying the su binary to a location in the current process's PATH (e.g. /system/xbin/su) and granting it executable permissions with the chmod command. A supervisor application like SuperUser or SuperSU can regulate and log elevated permission requests from other applications. Many guides, tutorials, and automatic processes exist for popular Android devices facilitating a fast and easy rooting process.
For example, shortly after the HTC Dream was released, it was quickly discovered that anything typed using the keyboard was being interpreted as a command in a privileged (root) shell. Although Google quickly released a patch to fix this, a signed image of the old firmware leaked, which gave users the ability to downgrade and use the original exploit to gain root access. Once an exploit is discovered, a custom recovery image that skips the digital signature check of a firmware update package can be flashed. In turn, using the custom recovery, a modified firmware update can be installed that typically includes the utilities (for example the Superuser app) needed to run apps as root.
The Google-branded Android phones, the Nexus One, Nexus S, Galaxy Nexus and Nexus 4, as well as their tablet counterparts, the Nexus 7 and Nexus 10, can be boot-loader unlocked by simply connecting the device to a computer while in boot-loader mode and running the Fastboot program with the command "fastboot oem unlock". After accepting a warning, the boot-loader is unlocked, so a new system image can be written directly to flash without the need for an exploit.
Recently, Motorola, LG Electronics and HTC added security features to their devices at the hardware level in an attempt to prevent users from rooting retail Android devices.For instance, the Motorola Droid X has a security boot-loader that puts the phone in "recovery mode" if a user loads unsigned firmware onto the device, and the Samsung Galaxy S II displays a yellow triangle indicator if the device firmware has been modified.

How to root: 
                     Though you got lots of link for a successful rooting techniques on WEB but a wrong rooting steps can brick your phone.

                              BRICK
                                             A stage where your phone will neither boot up nor start because of lack of proper configuration in OS with its hardware components.

                                              So ill suggest you to go for software like 1 click recovery etc. but you will need to pay a price for it but if you want to do it for free you can also download a free rooting to 
i.e

SRSRoot One Click Root for Android .

its completely free software till now.

NOTE: Rooting is a process of bypassing Android actual security which may   lead to bricking your phone and warranty is also exploited while your phone is rooted. So DO AT YOUR OWN RISK.

 

 ADVANTAGE OF ROOTING:
                                                                                    
                                                                               Rooting  has many advantage over unrooted phones.

1> Complete control over your applications i.e uninstall any application that you want but for this you will require tool like Titanium Backup which i recommend for root user only, its a all in 1 tool.

2> Boot up new custom roms and increase your device performance.

3> Run OS like UBUNTU on your android device and this is a fact since i have already done it.

4> Increase your RAM ie use SDCARD as a RAM.

5> Increase internal memory which can allow you to install more apps and games. Using softwares like linktosd, appstosd etc which need ROOT.

6> Boost up CPU by using overclocking it.

7> Save data usage using apps like derodwall.

8> Secure your internet connection using virtual apn apps like deroidapn.

9> Move any application to sdcard to save internal memory.
and many more .......
for any query join android development community like Android Forums
Thank you :) keep visiting us and do like us.

   



 
                      

Thursday, 3 October 2013

Amazing youtube videos

Today's theme is more towards random Amazement

1) The deadly nano bugs

Air Force Bugbots Nano Drone video gives a peak inside what nano-drone 
technology the Federal Government is currently implementing within the 
united states 
The deadly, insect-sized drones of the future - Unobtrusive, Invasive, 
and Lethal are here as depicted in this old video

2) Amazing water trick

water turn into ice in 5sec

3) No more flat tires? Sounds good to me


4) Amazing detailed view of atom

Scientists at the University of California Los Angeles have found a 
way to create stunningly detailed 3D reconstructing of platinum 
nanoparticles at an atomic scale. These are being used to study 
tiny structural irregularities called dislocations.
many more to come stay tuned

What Happens When You Put iPhone 5C, 5S in a Blender :D :D :D -admin )(0Tsho+





crazy insane totally nutzzzzzzzzz..........! video

no words to express :D

this video is on a crazy blending scientist who blend stuffs :D :D

wanna seee more crazy watch dis video............!

CLICK THIS  LINK  https://www.youtube.com/watch?v=GAuhUTzNwiY

i cant watch it /.\



WARNING:- PEOPLE WITH  NO HEART ONLY CAN WATCH IT .........!

Wednesday, 2 October 2013

production of Gasoline using biotechnology.......!


Novel Technology to Produce Gasoline by a Metabolically-Engineered Microorganism






Sep. 29, 2013 — Scientists succeeded in producing 580 mg of gasoline per litre of cultured broth by converting in vivo generated fatty acid.


For many decades, we have been relying on fossil resources to produce liquid fuels such as gasoline, diesel, and many industrial and consumer chemicals for daily use. However, increasing strains on natural resources as well as environmental issues including global warming have triggered a strong interest in developing sustainable ways to obtain fuels and chemicals.
Gasoline, the petroleum-derived product that is most widely used as a fuel for transportation, is a mixture of hydrocarbons, additives, and blending agents. The hydrocarbons, called alkanes, consist only of carbon and hydrogen atoms. Gasoline has a combination of straight-chain and branched-chain alkanes (hydrocarbons) consisted of 4-12 carbon atoms linked by direct carbon-carbon bonds.
Previously, through metabolic engineering of Escherichia coli (E. coli), there have been a few research results on the production of long-chain alkanes, which consist of 13-17 carbon atoms, suitable for replacing diesel. However, there has been no report on the microbial production of short-chain alkanes, a possible substitute for gasoline.
In the paper (entitled "Microbial Production of Short-chain Alkanes") published online in Nature on September 29, a Korean research team led by Distinguished Professor Sang Yup Lee of the Department of Chemical and Biomolecular Engineering at the Korea Advanced Institute of Science and Technology (KAIST) reported, for the first time, the development of a novel strategy for microbial gasoline production through metabolic engineering of E. coli.
The research team engineered the fatty acid metabolism to provide the fatty acid derivatives that are shorter than normal intracellular fatty acid metabolites, and introduced a novel synthetic pathway for the biosynthesis of short-chain alkanes. This allowed the development of platform E. coli strain capable of producing gasoline for the first time. Furthermore, this platform strain, if desired, can be modified to produce other products such as short-chain fatty esters and short-chain fatty alcohols.
In this paper, the Korean researchers described detailed strategies for 1) screening of enzymes associated with the production of fatty acids, 2) engineering of enzymes and fatty acid biosynthetic pathways to concentrate carbon flux towards the short-chain fatty acid production, and 3) converting short-chain fatty acids to their corresponding alkanes (gasoline) by introducing a novel synthetic pathway and optimization of culture conditions. Furthermore, the research team showed the possibility of producing fatty esters and alcohols by introducing responsible enzymes into the same platform strain.
Professor Sang Yup Lee said, "It is only the beginning of the work towards sustainable production of gasoline. The titre is rather low due to the low metabolic flux towards the formation of short-chain fatty acids and their derivatives. We are currently working on increasing the titre, yield and productivity of bio-gasoline. Nonetheless, we are pleased to report, for the first time, the production of gasoline through the metabolic engineering of E. coli, which we hope will serve as a basis for the metabolic engineering of microorganisms to produce fuels and chemicals from renewable resources."