Saturday, October 6, 2012

Windows 8 keyboard shortcuts

The next version of Windows has new keyboard shortcuts for the benefit of keyboard users which are most users. It still seems that Windows 8 is only worth having for touch screen system.

This file contains the shortcuts listed
ShortcutDescription
Win key+COpen the Charms
Win key+FOpen the Search charm to search files
Win key+HOpen the Share charm
Win key+IOpen the Settings charm
Win key+JSwitch the main app and snapped app
Win key+KOpen the Devices charm


Reference

http://windowsteamblog.com/windows/b/windowsexperience/p/win8_keyboard_shortcuts.aspx

Sunday, July 8, 2012

Semaphores in Java Example

Semaphores in java handles permits to execute the next lines of instructions. They are often use to restrict the number of threads to access a resource.

Before getting a resource the thread must acquire a permit form a semaphore and release the resource after using the shared resource which can be memory, storage or data.

Constructors

Semaphore ( i n t   permits )
Creates a Semaphore  with  the given  number of  permits and no fair fairness setting .
Semaphore ( i n t   permits ,   boolean   fair )
Creates a Semaphore  with  the given  number of  permits and the given  fairness setting .

Now for a sample semaphore program that counts until 20 using two threads that uses semaphores for data consistency.
Counter.java
import java.util.concurrent.Semaphore;
import javax.swing.JTextArea;

public class Counter extends Thread{
 private static int count=0;
 private String ID;
 private JTextArea TBox;
 private Semaphore sem;
 
 public ServiceQueue(String name,JTextArea jArea, Semaphore s){
  ID=name;
  TBox=jArea;
  sem=s;
 }
 
 private void nonCrit(int i){
  System.out.println(ID+" is not in critical: "+i);
 }
 
 
 private synchronized void doCrit(){
   count++;
   TBox.append(ID+" gave count: "+count+"\n");
 }
 
 public void run(){
  for(int ctr=0;ctr<10;ctr++){
  nonCrit(ctr);
   try{
   sem.acquire();
    } catch (InterruptedException e){ }
   doCrit();
   sem.release();
  }
 }
 
}
Executioner.java
import javax.swing.*;
import java.util.concurrent.Semaphore;
import java.awt.*;
public class Executioner extends JFrame{

 public Executioner(){
  super("Hello World");
  JTextArea TA=new JTextArea(20,15);
  Semaphore sem = new Semaphore(3, true);
  
  setLayout(new FlowLayout());
  add(TA);
  
  Counter Q1=new ServiceQueue("1st Class",TA,sem);
                Counter Q2=new ServiceQueue("3rd Class",TA,sem);
  
  
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setVisible(true);
  
  C1.start();
  C2.start();
  pack();
 }

 public static void main(String args[]){
  new Executioner();
 }
}

Monday, June 18, 2012

Adding User Accounts in mysql

Sample create user command for Mysql


CREATE USER 'myUser'@'localhost' IDENTIFIED BY 'hello';
GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'myUser'@'localhost';

The first command is the CREATE USER where
  • myUser is the user name
  • localhost is where the database is
  • hello is the password
The next command is the Grant command containing the Mysql statements to be allowed, the the database/s to be granted and the user to assigned for the permission.
  • The assigned user is myUser
  • The user can use the commands SELECT,INSERT,UPDATE,DELETE on all databases in localhost
  • ON *.* means that the user can use all the granted commands
  • ON *DBname.* can be used to allow the user to use the commands on the database names DBname
After the CREATE USER command has been executed, the user can now use the new user name and password as arguments in running mysql. In this example, the user can type mysql -u myUser -p then type hello. However not all commands can be used by myUser unlike the root user.

Reference

Oracle (2012). Adding User accounts. http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Friday, May 25, 2012

Checking If software development process is Working

The process must Improve the ff.

Appropriate model
Can improve:
development speed
quality
tracking & control
client relations
Can minimize:
overhead
risk exposure




Inappropriate
-Can improve:
slow
unnecessary
redundant
frustrating

Monday, May 21, 2012

HTTP STATUS CODES

Error CodeMeaning
302Redirect
400bad_request
401unauthorized
403forbidden
404not_found
405method_not_allowed
500internal_server_error
507insufficient_storage

Sunday, May 6, 2012

Agile Software Development

As gleaned from (Beck, K. et al., 2001), Agile development is a approach of developing software that aims to develop software that can adapt. it does not recommend a certain life-cycle model.

It has the ff. characteristics

  • Design and analysis has less emphasis
  • Early implementation of software
  • Prioritize working software over detailed documentation
  • Aim to respond to requirement changing
  • Aims to collaborate with the client
  • Aims to Deliver working software frequently, ideally every 2 to 3 weeks


  • Values Individual and interactions
  • Flexible for changes
  • Not much emphasis on analysis and design
  • Implements project early
  • Working on software is prioritized over documentation
  • Shorter life cycle than waterfall
  • Promotes collaboration with clients
  • Has multiple variations

Reference Beck, K. et al. 2001. Manifesto for Agile Software Development

Monday, March 26, 2012

Shortest Job First Simulation in C#


Where did I go wrong. How do I make this right


public ShortestJobFirst(int pollTime)
        {
            if (pollTime < 1)
            {
                throw new ArgumentOutOfRangeException(Resources.PollTimeGreaterThanZero);
            }

            _pollTime = pollTime;
        }

       
        public void Execute(Runner runner)
        {
            List readyQueue = new List(runner.ProcessLoad);
            while (readyQueue.Count > 0)
            {
                try
                {
                    // select the process that is eligible to run with the smallest remaining burst time
                    Process p = readyQueue.Where(x => x.ArrivalTime <= runner.Time).OrderBy(x => x.BurstTime - x.Data.UtilizedCpuTime).First();
                    runner.UtilizeCpu(p, _pollTime);
                    if (Process.IsComplete(p))
                    {
                        runner.LogProcessMetrics(p);
                        readyQueue.Remove(p);
                    }
                }
                catch (InvalidOperationException)
                {
                    runner.SkipIdleCpuTime();
                }
            }
        }

        public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "Shortest Job First (Job Time = {0})", _pollTime);
        }
}

Saturday, March 24, 2012

Servlet Lifecycle

StagePurposeWhen it happensCan be Overridden
init() Initialize servlet before client request After the servlet instance is created Possibly, when you have an initialization code
service() determine the HTTP method (Get/post) When the client's request comes in No, unlikely
doget() dopost Initialize servlet before client request Invoked by service() whether the method is post or get Always. this where the programmer's work is suppose to be in

Friday, March 2, 2012

Network Layer Glossary


Host-- A node in the computer network that provides information services and applications to other nodes
End System- Nodes Connected to the internet
Subnet-- Division of a network
Transmission Lines-- Carries alternating current to the of frequency containing information.
Switching Elements--
Congestion-- Quality of service deteriorates due to the overflow of data. Typical effects include queueing delay, packet loss or the blocking of new connections.
Flow Control-- Management of Data transmission rate between two nodes to prevent a fast sender from outrunning a slow receiver.
Connection Management-- Manages Connections
Virtual Circuit--Allows higher level protocols to avoid dealing with the division of data into segments, packets, or frames. Delivered by Packet modes. A path from source to destination in Connection Oriented Service.
Datagram-- Packets in a connection less service that are injected into a subnet individually and independently.

Thursday, February 9, 2012

Channel Allocation

Channel Allocation Schemes deal with the following:

  • The allocation of channels to cells within a cellular network
  • Allocation of bandwidth to base stations access points & terminal equipment (nodes)
  • Users within a channel can use the available channels to communicate with people within them
  • Trying to be efficient in system spectral terms 

Kinds of allocation Scheme

  • Fixed Channel Allocation,
  • Dynamic Channel Allocation and
  • Hybrid Channel Allocation which is a combination of the first two methods.

System spectral efficiency

  • Goal of an allocation scheme
  • Measured in (bit/s)/Hz per unit area
  • Measured in  (bit/s)/Hz per cell
  • Measured in (bit/s)/Hz per site
  • Measure of the quantity of users or services that can be simultaneously supported by a limited radio frequency bandwidth in a defined geographic area.

Reference:
http://wireless.per.nl/reference/chaptr04/cellplan/dca.htm by John S. Davis, II,

Wednesday, February 8, 2012

Software Development Cycle

The Software Development Cycle is the process of making software products. There are several models followed to make software. the models used vary on the project and the people working on it.

Code and Fix

  • Simple way of making software
  • No design
  • No Documentation
  • No consultation of requirements
  • Best for short programs
  • Implement Software until client is satisfied

Waterfall

  • A disciplined way testing
  • Every step has documentation and
  • Each step must be approved with quality assurance
  • Like Code and fix client sees product after implementation (coding)
  • Needs patience for both developers and customers
  • Documentation give explanations to teammates
  • Documenting gives a plan
  • Costly in dealing with changes in requirements or plan


Agile


  • Values Individual and interactions
  • Flexible for changes
  • Not much emphasis on analysis and design
  • Implements project early
  • Working on software is prioritized over documentation
  • Shorter life cycle than waterfall
  • Promotes collaboration with clients
  • Has multiple variations

Reference

Object-Oriented &; Classical Software Engineering, 7th Ed. by Stephen Schach, 2007
McGraw-Hill International Edition

Saturday, January 21, 2012

Some geolocation objects in html5

Here is a model representing position and coordinates in Geolocation API that can be used in HTML 5

Position

Coords: the coordinates in the position class
Timestamp: The time when the location was traced

The Coordinates class varies on browser support

Reference:
Head First HTML5 Programming by Eric Freeman & Elisabeth Robson.

Monday, January 16, 2012

Web Design Navigation Notes

Cederholm(2008) informs several tips in making more flexible navigation using CSS.

  • Imaged based navigation make it impossible for people with poor eyesight to adjust text-size
  • An Unordered or definition list list can be used as a markup for text based navigation to organize navigation items
  • Those kinds of navigation items can be accessed by a wide range of browsers mobile or desktop
  • The text based navigation can be easily modified with out adding or removing images
  • Placing background images creatively can add detail to the navigation design without compromising flexibility
  • Scalability can attained by using ems for font-size, margins, paddings and etc...

For more information on web design:
http://www.webdesign.org/
Headfirst web design
Tips for novices

Reference:

Cederholm, D. (2007). Bulletproof web design, improving flexibility and protecting against worst-case scenarios with xhtml and css. (2nd ed.). Berkeley: New Riders Pub.

Thursday, January 5, 2012

4 Principles of OOP

Encapsulation
Objects keep track of its state internally. Objects have characteristics that should not interact with other objects
Inheritance
Objects can get characteristics from other objects and interfaces.
An objects characteristics can be passed down to other objects similar to the class
Polymorphisim
Object can have many forms to take for different situations
Abstraction
Putting classes in a general to most specific hierarchy. Some characteristics are hidden and do not need to be changed but it can still they can still be modified.
Group objects base on what they can do

Wednesday, January 4, 2012

OOP Encapsulation

Encapsulation in Object Oriented Programming is about keeping data in classes private. The object or data are figuratively placed in a capsule where what is observed by other objects is the capsule not the object or data. inside. This also means that the characteristics of the objects are hidden from direct access. This can mean that the code in the class wont be that affected much with changes in the code made by other people

Purpose:
Protect Object Characteristics from unwanted changes.


Reference:

Head First C#