What is a QA tester?

The many types of QA testers

What is a qa tester? What is a QA tester? First off QA stands for quality assurance and if you are a QA tester you are testing the quality of any product to make sure it meets a certain standard of quality. There are several different types of QA testers in the world. Call centers, for example, will have a QA tester to periodically listen to customer service calls and see if the calls meet the company’s definition of quality. Another example would be in a manufacturing line. A QA tester would take random samples of a product being produced and determine if the quality is good. In a world where information is shared so rapidly people can go online, find the product they have purchased, and rate what they think of it. The point of a QA tester would be to find problems before the user does. You will not find every problem, but if you can mitigate major problems then when people review your product you will not have as much negative pr (public relations). Consumers will write something bad about a product far more then they will write a good review.

Software QA testers

While there are several types of QA testers in the world, the most common today is in the world of software engineering. If you talk about a quality assurance tester for testing software there are two main paths of testers.

  1. Quality Assurance Engineer – The qualifications for a QA engineer are the same for a software engineer. He or she has to know how to write code and test code. In a nutshell a QA engineer programs tests to validate software, works on frameworks to help a software developer test his or her code, and makes sure that the pipeline from creation to production of software has automated validation of the quality. This type of engineer can also be more focused on testing how the software behaves under stress or load conditions, or programmatically find vulnerabilities in the security of the software being developed.
  2. Quality Assurance Analyst – This job position does not necessarily require advanced knowledge of programming, but rather an in depth knowledge of how the product behaves and functions from a user’s perspective. An analyst is primarily focused on exploratory testing and seeing how a user would navigate his or her way through the product.

Make Your Own Website Scraper

Description of a website scraper

I recently did a project where I needed to scrape a subset of webpages from the internet. Back in the 1990s all websites were pretty much straight up html, which makes crawling them and getting their data pretty easy. All you needed was to grab the html files and run them through a tokenizer, parsing out all the juicy bits. Today things are a bit more complicated as most websites have some form of javascript execution (usually jQuery or AngularJS). In order to crawl these type of sites the web scraper needs to be able to execute javascript. There are several ways this can be done each with their benefits and drawbacks. I chose to go with Selenium Webdriver

Of the various implementations of the webdriver – chrome, firefox, internet explorer, htmlunit, and etc . . . the fastest is chrome by far. The basic idea of a web scraper is to load a page as the user would see it. Grab the text from the page that you need, massage it, and store it off somewhere for data mining later. In the process of parsing the pages you grab all the anchor tags and push them into a list of websites “To Be Crawled” and once you scrape the particular website move them to a list of “Crawled Websites.” That’s a web scraper in a nutshell, however, the implementation of one can get a bit more complex especially depending on what your goals are.

One of the major problems I ran into quickly was how angular routes store references to pages. They use a baseurl.com/#/rest_of_link. The reason this is bad is because you need to strip the “#” hash sign from other url’s like foo.com/page#div, which references an id of an html element to scroll to on the loading of that link. The following is the regex I used in order to do strip out the #! and #_end_of_url. It uses the regex look ahead to accomplish the goal.

List<WebElement> list = driver.findElements(By.xpath("//*[@href]"));
for (def e : list) {
    def href =  e.getAttribute("href");
    if (href.contains('#')) {

        href = href.replaceAll("(?!#!)#.*","")

        UrlModel newModel = new UrlModel(href);
        //SUBMIT TO DB
    }
}

Then once you have a list of url’s to crawl you can just initialize a new chromedriver instance with the url in question and grab all the webelements in the body. Once you have all the web elements you can grab the text values. The rest is up to you how you want to store the data and mine it later. I did not need this to go particularly fast but you can map reduce the scraping by running multiple instances of the chromedriver on several different machines. Selenium grid has a good way of doing this.

Web Designer Job Description

Web Designer Job Description

Years ago if you were a web designer that meant that you knew how to arrange a page in HTML, change colors, and work on a little bit of javascript. With such modern advances with html5, jQuery, and AngularJS, the frontend of web development needs people who are better skilled at user interface logic and can architect massive projects. Although a company may have a specific stack or set of libraries for their front end logic, there are some skills that a good web designer needs to have and companies should look for individuals with these qualities. The web designer job description is slightly different than a typical software engineer because the web designer generally has to live within the constraints of a web browser. This does not make solving problems easier. In fact because each browser behaves differently this job can be seemingly more complex.

GOOD Web Designer Description

  • UNDERSTANDS NUANCES BETWEEN BROWSERS: This is where experience really counts. Each browser has its own javascript and css interpreters and this causes code to have to be written conditionally for each browser. With html5 and most new versions of browsers this has become more unified, but Internet Explorer for example is notorious for not even being backwards compatible with itself version to version.
  • UTILIZES HTML5: HTML5 has eliminated a lot of legacy design patterns. Nobody orders a webpage by tables and rows anymore, instead it is done with divs and appropriate css in order to better accommodate the vast differences in users
  • APPROPRIATELY ABSTRACTS CSS: There are many tools out there that help with css abstraction such as compass-style or sass. While these tools are useful, being able to just know various css properties and how to abstract classes is vital. Abstraction in css will make a web site easier to maintain and update to a newer look in the future.
  • CAN CODE PROFICIENTLY IN JAVASCRIPT: Several years ago javascript was viewed as awful and people were encouraged to turn off javascript in their browsers. Today most webpages use javascript in some form or another. One of the biggest benefits of using javascript is a user will download the page to their browser and all the computations happen on the individuals computer rather than the server. The only requests then go to the server to retrieve data or documents.
  • UNDERSTANDS ASYNCHRONOUS PROGRAMMING: This is probably one of the most important parts of a good web designer. Knowing javascript is good, but the requests are asynchronous. Normal programming paradigms fall apart here. A prime example is making http requests in javascript. A good web developer knows what a promise is and how to use callback functions to process multiple http requests that are dependent on happing in order.
  • KNOWS REST CONTRACTS: Projects that have large data or large number of users often abstract logic into front end and backend code. The front end logic will request data or documents from the server, and the server will query for them and return them in the form of json, xml, or other various serialized forms. Being able to know how to send requests and process response bodies is vital for a web designer. This also means knowing how to handle form submissions and normalizing data from a user that is acceptable to a server.
  • ABSTRACTS FRONT END CODE: Abstraction is a reoccurring theme in most software. User interface code is no exception. Angular has a good example of having a standard MVC (Model View Controller) style of abstraction. Each class or object has a purpose and it makes maintaining code much easier.
  • CAN SEARCH GOOGLE: Knowing what to search for is valuable. Sometimes websites have very weird errors that are not very explicit. Looking at a javascript stack trace may show where a line broke in some library, but not what line in your code broke it. Knowing what to search for to solve problems only comes with experience. The more projects a web designer has worked on the more exposure to the various problems that will occur will be more familiar.

BAD Web Designer Description

  • WEB DESIGNER IS NOT A UX DESIGNER: While having a web designer that can make a page look good, it is not his or her job to necessarily design all the functionality, layout of the page, or pick a color scheme. Web designers that freelance generally will do this, but when you start getting involved in a production software team having a UX designer to help facilitate colors and what layouts will attract users is different than the actual implementation of the user interface.
  • FALLS BEHIND WITH TECHNOLOGY: As this is true of any computer career, having a web designer that does not know how to make a webpage viewable by screens of different sizes, including mobile devices, can drastically impact the amount of visibility a website will receive. Google now calculates a website’s ranking in their search engine by being easily viewable through mobile devices.
  • LACKS SCALABILITY: Any person can write an html page and make several static html pages. When you start working on large projects making plain html pages does not scale well or fast. For example – if you make a recipe site, entering all the data as html is tedious and doesn’t promote involvement from other people.

Conclusion

As with most things in life you pay for what you get. If you want to offshore website development or find some high school free lancers, you can get a project started. If you need something that has a lot more involvement, such as producing graphs or using a html5 canvas, finding someone with more experience and a better sense of software abstraction and development will help make your project more successful, scalable, and generally better for the users that will interface with it.

Software Engineer Job Description

Software Engineer Job Description

There was an article I read in the news lately about the top 7 careers in Utah. Number three in the list was a software developer or software engineer. The terms have slightly different meaning, but can be interchanged quite frequently. Quite often I have either been asked what to include in a my company’s software engineer job description when we are looking to hire new engineers, or I have been looking for jobs and had to sift through tons of different qualification requirements. It seems every company has a different idea of what is a software engineer in their job description. Although it is perfectly ok to have specific requirements, we should broaden the scope a little bit. If an engineer is good at problem solving, debugging, and looking through other’s then the engineer should be considered for a position even if he or she is not familiar with the technologies that make up the specific company’s stack.



GOOD software engineer description

  • CAN CODE: Obviously you need someone who can code. The best way is to have a person either code or sudo code during an interview. Have the potential candidate go to a white board and solve some problem of your choice. Some common examples are to have the engineer code a binary search or code a method to detect a palindrome.
  • UNDERSTAND DATA STRUCTURES: Knowing different data structures like trees, lists, sets, and maps is essential. Every type of data structure has a specific purpose. These are just more tools inside an engineers tool belt.
  • KNOW DESIGN PATTERNS: The world of software has lots complexities in it. A software engineer should know several different design patterns. These patterns are like tools in an engineers tool belt. Each tool should do one job and do it really well. Some examples of design patterns are understanding singletons, command patterns, rest, or dependency injection. These are independent of any language.
  • DEBUG CODE: This is an absolute must in any software engineer. Using tools such as debug mode in an IDE or how to use programs like gdb are essential. Code will always have bugs, and being able find, troubleshoot, and fix bugs is essential. You could always present some code to the engineer with a bug and ask him or her to figure out what is wrong and give a possible solution.
  • SOLVE PROBLEMS: Any features that a company or customers need often include complex problem solving. For example how to persist data based on what is need more, writing or reading? What is the best solution to the problem?
  • UNDERSTAND COMPLEXITY: Knowing every algorithm and its big O complexity is overrated. More important is being able to derive big O complexity. Have the engineer determine what the big O complexity of some provided method.
  • DESIGN STRUCTURES: If your stack uses OOP (Object Oriented Programming), functional (i.e. javascript or c), or embedded paradigms then the engineer should have some familiarity with them. A kernel developer, for example, needs to understand good functional programming designs more than object oriented designs.
  • WHAT DON’T I KNOW: Most software engineers do not know the answers to every question. Being able to know what to search for on google is important. Example: If you are in angular land you need to know how to speak the angular language. Searching should use things like directives or scope.
  • STAYS MODERN: Software is a fast moving field. If an engineer does not stay current he or she falls behind fast. A prime example is knowing only perl or php. Most software stacks have moved towards some rest server like java or node and a frontend in angular. While there are so many technologies out there knowing specifics can be hard, but an engineer should be familiar enough with what various technologies to know if they will be a solution to specific problems that arise.
  • KNOWS MATH: Knowing how to implement a mathematical function – such as a simple Riemann sum – is what separates a junior or entry level position from a senior or architect level position. You could always provide a mathematical equation and have the engineer give sudo code of how to translate the idea into code.

BAD software engineer description

  • SPECIFIC LANGUAGE: I have had interviews that ask very specific questions to a programming language. They reference obscure aspects of a language that nobody will need on a regular basis. Being able to google an answer is more important than knowing specifics.
  • SPECIFIC APPLICATIONS: While this should be determined on a case by case basis, having requirements like knowing specific applications should generally be avoided. Example: requiring a software developer to know protractor for end to end testing. This still uses selenium under the hood and has all the same selenium problems that any other end to end testing framework will have.
  • LIMITING TO DEGREES: Having a degree is always beneficial. Especially from colleges or universities that have abet accreditations. I have mixed feelings on this subject. Some self taught engineers are so thirsty to know in depth how to program, but some learn just enough to get by and have gaps in their knowledge.
  • TAKE HOME CODE TESTS: These are terrible because the user can easily have someone else code the solution. If you need to give them a take home test to assess the engineer’s ability to program, then you should add bugs to the code and have the engineer debug the code in real time during an interview.
  • NOT ALLOWING SEARCHING: There have been interviews I have had where I have been required to take some test without being able to use google. Being able to know what to search for in order to solve a problem is 100% essential to a good engineer.




Benefits

The number of jobs that require software to be made is only going to increase. The number of people with mobile computing platforms (iphones or android phones) is very prevalent. A company needs to not only have a competitive salary, but have other benefits or perks to attract top talent. Some companies provide 20 days paid vacation in the first year along with catered meals and great health benefits. Having good benefits will give the company a bigger pool of candidates to select.

Conclusion

Hopefully this helps define a good software engineer job description. These are things a company should look for and not look for in potential software engineering candidates.

Custom PS2 Keyboard GPIO for Spartan 6 Microblaze

Description

This is an old post I never finished. I just thought I would at least share the code for the project. I made a keyboard interface with PS2 that plugged into the Spartan 6 Microblaze. You will need to make sure you have the right voltage and resistors in the right place. There is also a wire for the clock and data. PS2 is a pretty old standard and there are a lot of diagrams out there for it.



VHDL

user_logic.vhd

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;

library proc_common_v3_00_a;
use proc_common_v3_00_a.proc_common_pkg.all;

-- DO NOT EDIT ABOVE THIS LINE --------------------

--USER libraries added here

------------------------------------------------------------------------------
-- Entity section
------------------------------------------------------------------------------
-- Definition of Generics:
--   C_NUM_REG                    -- Number of software accessible registers
--   C_SLV_DWIDTH                 -- Slave interface data bus width
--
-- Definition of Ports:
--   Bus2IP_Clk                   -- Bus to IP clock
--   Bus2IP_Resetn                -- Bus to IP reset
--   Bus2IP_Data                  -- Bus to IP data bus
--   Bus2IP_BE                    -- Bus to IP byte enables
--   Bus2IP_RdCE                  -- Bus to IP read chip enable
--   Bus2IP_WrCE                  -- Bus to IP write chip enable
--   IP2Bus_Data                  -- IP to Bus data bus
--   IP2Bus_RdAck                 -- IP to Bus read transfer acknowledgement
--   IP2Bus_WrAck                 -- IP to Bus write transfer acknowledgement
--   IP2Bus_Error                 -- IP to Bus error response
------------------------------------------------------------------------------

entity user_logic is
  generic
  (
    -- ADD USER GENERICS BELOW THIS LINE ---------------
    --USER generics added here
    -- ADD USER GENERICS ABOVE THIS LINE ---------------

    -- DO NOT EDIT BELOW THIS LINE ---------------------
    -- Bus protocol parameters, do not add to or delete
    C_NUM_REG                      : integer              := 4;
    C_SLV_DWIDTH                   : integer              := 32
    -- DO NOT EDIT ABOVE THIS LINE ---------------------
  );
  port
  (
    -- ADD USER PORTS BELOW THIS LINE ------------------
    
	 --USER ports added here
--	 clk, rst : in std_logic;
		ps2d, ps2c : in std_logic;
--		rx_en : in std_logic;
--		rx_done_tick : out std_logic;
		shift_en : out std_logic;
		dout : out std_logic_vector(7 downto 0);
		myinterrupt : out std_logic;
		
    -- ADD USER PORTS ABOVE THIS LINE ------------------

    -- DO NOT EDIT BELOW THIS LINE ---------------------
    -- Bus protocol ports, do not add to or delete
    Bus2IP_Clk                     : in  std_logic;
    Bus2IP_Resetn                  : in  std_logic;
    Bus2IP_Data                    : in  std_logic_vector(C_SLV_DWIDTH-1 downto 0);
    Bus2IP_BE                      : in  std_logic_vector(C_SLV_DWIDTH/8-1 downto 0);
    Bus2IP_RdCE                    : in  std_logic_vector(C_NUM_REG-1 downto 0);
    Bus2IP_WrCE                    : in  std_logic_vector(C_NUM_REG-1 downto 0);
    IP2Bus_Data                    : out std_logic_vector(C_SLV_DWIDTH-1 downto 0);
    IP2Bus_RdAck                   : out std_logic;
    IP2Bus_WrAck                   : out std_logic;
    IP2Bus_Error                   : out std_logic
    -- DO NOT EDIT ABOVE THIS LINE ---------------------
  );

  attribute MAX_FANOUT : string;
  attribute SIGIS : string;

  attribute SIGIS of Bus2IP_Clk    : signal is "CLK";
  attribute SIGIS of Bus2IP_Resetn : signal is "RST";

end entity user_logic;

------------------------------------------------------------------------------
-- Architecture section
------------------------------------------------------------------------------

architecture IMP of user_logic is

  --USER signal declarations added here, as needed for user logic
	type statetype is (idle, dps, load);
	signal state_reg, state_next : statetype;
	-- filter
	signal filter_reg, filter_next : std_logic_vector(7 downto 0);
	signal f_ps2c_reg, f_ps2c_next : std_logic;

	signal b_reg, b_next : std_logic_vector(10 downto 0);
	signal n_reg, n_next : unsigned(3 downto 0);
	signal shift_reg, shift_next : std_logic := '0';
	
	signal fall_edge : std_logic;
	signal end_buff : std_logic;
--	signal rx_en : std_logic;
	signal zeros : std_logic_vector(C_SLV_DWIDTH-1 downto 0);
	
  ------------------------------------------
  -- Signals for user logic slave model s/w accessible register example
  ------------------------------------------
  signal slv_reg0                       : std_logic_vector(C_SLV_DWIDTH-1 downto 0);
  signal slv_reg1                       : std_logic_vector(C_SLV_DWIDTH-1 downto 0);
  signal slv_reg2                       : std_logic_vector(C_SLV_DWIDTH-1 downto 0);
  signal slv_reg3                       : std_logic_vector(C_SLV_DWIDTH-1 downto 0);
  signal slv_reg_write_sel              : std_logic_vector(3 downto 0);
  signal slv_reg_read_sel               : std_logic_vector(3 downto 0);
  signal slv_ip2bus_data                : std_logic_vector(C_SLV_DWIDTH-1 downto 0);
  signal slv_read_ack                   : std_logic;
  signal slv_write_ack                  : std_logic;

begin

  --USER logic implementation added here

-- filter 
process (Bus2IP_Clk, Bus2IP_Resetn) 
begin
  if (Bus2IP_Resetn = '0') then
    filter_reg <= (others => '0');
    f_ps2c_reg <= '0';
  elsif (Bus2IP_Clk'event and Bus2IP_Clk='1') then
    filter_reg <= filter_next;
    f_ps2c_reg <= f_ps2c_next;
  end if;
end process;


filter_next <= ps2c & filter_reg(7 downto 1);
f_ps2c_next <= '1' when filter_reg = "11111111" else
               '0' when filter_reg = "00000000" else
               f_ps2c_reg;

fall_edge <= f_ps2c_reg and (not f_ps2c_next);

-- rx_en will need to be set to 1 always by this design
--rx_en <= '1';
zeros <= (others => '0');

-- registers
process (Bus2IP_Clk, Bus2IP_Resetn)
begin
	if (Bus2IP_Resetn = '0') then
		state_reg <= idle;
		n_reg <= (others => '0');
		b_reg <= (others => '0');
		slv_reg0 <= (others => '0');
	elsif (Bus2IP_Clk'event and Bus2IP_Clk='1') then
		state_reg <= state_next;
		n_reg <= n_next;
		b_reg <= b_next;
		shift_reg <= shift_reg;
		slv_reg0 <= zeros or  b_reg(8 downto 1);
	end if;
end process;

-- next-state logic
process(state_reg, n_reg, b_reg, fall_edge, ps2d)

begin
	myinterrupt <= '0';
	--rx_done_tick <= '0';
	state_next <= state_reg;
	n_next <= n_reg;
	b_next <= b_reg;
  
  case state_reg is 
    when idle =>
--      myinterrupt <= '1';
      if (fall_edge = '1') then 
        --shift in start bit
        b_next <= ps2d & b_reg(10 downto 1);
        n_next <= "1001"; -- set count to 8 again
        state_next <= dps;
      end if;
    when dps => 
 --     myinterrupt <= '0';
      if (fall_edge = '1' ) then
        b_next <= ps2d & b_reg(10 downto 1);
        if (n_reg = 0) then 
          state_next <= load;
        else 
          n_next <= n_reg - 1;
        end if;
      end if;
    when load =>
		-- here we handle if signal f0 and following signal are 
		-- asserted - we don't want to transmit them to dout.
      -- one more state to complete last shift
		state_next <= idle;
--		rx_done_tick <= '1';
		myinterrupt <= '1';
		if (b_reg(8 downto 0) = x"12" or b_reg(8 downto 0) = x"59") then
			shift_next <= not shift_reg;
			if (shift_reg = '1') then
--				rx_done_tick <= '0';
				myinterrupt <= '0';
			end if;
		elsif (b_reg(8 downto 0) = "11110000") then
			end_buff <= '1';
--			rx_done_tick <= '0';
			myinterrupt <= '0';
		elsif (end_buff = '1') then
			end_buff <= '0';	
--			rx_done_tick <= '0';
			myinterrupt <= '0';
		end if;
  end case;
end process;

shift_en <= shift_reg;
dout <= b_reg(8 downto 1);

  slv_reg_write_sel <= Bus2IP_WrCE(3 downto 0);
  slv_reg_read_sel  <= Bus2IP_RdCE(3 downto 0);
  slv_write_ack     <= Bus2IP_WrCE(0) or Bus2IP_WrCE(1) or Bus2IP_WrCE(2) or Bus2IP_WrCE(3);
  slv_read_ack      <= Bus2IP_RdCE(0) or Bus2IP_RdCE(1) or Bus2IP_RdCE(2) or Bus2IP_RdCE(3);


  -- implement slave model software accessible register(s) read mux
  SLAVE_REG_READ_PROC : process( slv_reg_read_sel, slv_reg0, slv_reg1, slv_reg2, slv_reg3 ) is
  begin

    case slv_reg_read_sel is
      when "1000" => slv_ip2bus_data <= slv_reg0;
      when "0100" => slv_ip2bus_data <= slv_reg1;
      when "0010" => slv_ip2bus_data <= slv_reg2;
      when "0001" => slv_ip2bus_data <= slv_reg3;
      when others => slv_ip2bus_data <= (others => '0');
    end case;

  end process SLAVE_REG_READ_PROC;
--
--  ------------------------------------------
--  -- Example code to drive IP to Bus signals
--  ------------------------------------------
  IP2Bus_Data  <= slv_ip2bus_data when slv_read_ack = '1' else
                  (others => '0');

  IP2Bus_WrAck <= slv_write_ack;
  IP2Bus_RdAck <= slv_read_ack;
  IP2Bus_Error <= '0';

end IMP;




ps2_keyboard.vhd

port
  (
    -- ADD USER PORTS BELOW THIS LINE ------------------
    --USER ports added here
	 ps2d, ps2c : in std_logic;
	 myinterrupt : out std_logic;
    -- ADD USER PORTS ABOVE THIS LINE ------------------

UCF and MPD files

The MPD file needs to be modified first. This will then allow us to add the io ports when mapping the device.

Microblaze Interrupt Handler

microblaze_register_handler(interrupt_handler_dispatcher, NULL);
                XIntc_EnableIntr(XPAR_INTC_0_BASEADDR, (XPAR_FIT_TIMER_0_INTERRUPT_MASK | XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK  | XPAR_PS2_KEYBOARD_0_MYINTERRUPT_MASK | XPAR_AXI_AC97_0_INTERRUPT_MASK ));
                XIntc_MasterEnable(XPAR_INTC_0_BASEADDR);
                microblaze_enable_interrupts();

Next

void interrupt_handler_dispatcher(void* ptr) {
        int intc_status = XIntc_GetIntrStatus(XPAR_INTC_0_BASEADDR);

  // Check the AC97. Just one method - no need for a separate handler
  if (intc_status & XPAR_AXI_AC97_0_INTERRUPT_MASK) {
          XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_AXI_AC97_0_INTERRUPT_MASK);
          fillSound();

  }

        // Check the FIT interrupt first.
        if (intc_status & XPAR_FIT_TIMER_0_INTERRUPT_MASK){
                XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_FIT_TIMER_0_INTERRUPT_MASK);
                timer_interrupt_handler();
        }
        // Check the push buttons.
        if (intc_status & XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK){
                XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_PUSH_BUTTONS_5BITS_IP2INTC_IRPT_MASK);
                pb_interrupt_handler();
        }
  if (intc_status & XPAR_PS2_KEYBOARD_0_MYINTERRUPT_MASK) {
                XIntc_AckIntr(XPAR_INTC_0_BASEADDR, XPAR_PS2_KEYBOARD_0_MYINTERRUPT_MASK);
                ps2_interrupt_handler();
  }
}

PS2 Interrupt Handler

void ps2_interrupt_handler() {
  int buttonValue = XGpio_ReadReg(XPAR_PS2_KEYBOARD_0_BASEADDR, 0x0);
  xil_printf("rnValue0=%d",buttonValue);

  if (getGameInAction() == 0) {
                switch (buttonValue) {
                                // left button
                        case 28:
                                        setTankPositionGlobal(getTankPositionGlobal() - 5);
                                        drawTank(framePointer0);
                                        break;
                                case 27:
                                        if (!isHaveTankBullet()) {
                                                setHaveTankBullet(1);
                                                setHaveTankBulletSound(1);
                                                setTankBulletPositionX(getTankPositionGlobal() + 15);
                                                setTankBulletPositionY(TANK_Y_POSITION - 2*TANK_BULLET_HEIGHT);
                                                drawTankBullet(framePointer0);
                                        }
                                        break;
                                case 35:
                                        setTankPositionGlobal(getTankPositionGlobal() + 5);
                                        drawTank(framePointer0);
                                        break;
    }
  }
}

Yeoman’s Gruntfile.js with html5 hashbang

Description

Recently I worked on trying to make my angular application crawlable by google robots. In order to accomplish this I moved my application to html5. The problem however was all sites needed to be redirected from foo.com/newpage to foo.com/#!/newpage. This is required in order to load all the css and javascript for the page. No problem – Nginx is awesome and did this for me. I still had a problem. I want to use grunt serve to do local development work on the application. In order to accomplish this I found a great article talking about angular with html5mode when your application was constructed using yeoman. I ended up having to add mp3 and pdf file types to the mod_rewrite in order to get everything on my site to work. Either way – great article.

Async functions in AngularJS to behave synchronously

Description

Having a background in server side code entering the world of javascript’s asynchronous functional programming took a bit to wrap my head around and understand. Angular has some awesome libraries that let you make rest endpoint requests using $http module. There was a scenario I ran into recently where I needed to make a rest call to get some ip address information and then make another request based off of the information I received. Under normal synchronous programming this is not a problem, but there is no such guarantee with javascript. I needed to finally learn about callbacks and promises. Although they are similar I decided to go with a callback approach, which I will share here.

The basic premise to callbacks is you are passing functions as objects. The object is read and processed at a certain point. After understanding that functions are just objects in javascript the wheels started clicking in my brain and I was able to get my service to work properly. I made a service that handled the multiple http calls and then I just pass that service as a dependency injection of my controller. Below is just psuedo code on how I was able to accomplish this.




 
//Controller logic
//This makes the call to the service and when the service is done processing what it needs it then processing the function part of this.
$scope.getQuestion() = function() {
  MyService.getQuestion(index, function(question) {
    $scope.questionVariable = question;
  });
}

//Service Logic
this.getQuestion = function(id, cb) {
  this.getIPInfo(id, cb, this.retrieveQuestion);
};

this.getIPInfo(id, cb, retrieveQuestion) {
  $http.get("http://ipinfo.io").success(function (response){
    //On success then we call another function based on what we passed in;
    retrieveQuestion(id, cb);
  });
};

this.retrieveQuestion = function(id,cb) {
  // The cb is the callback from the original controller variable.
  $http.getsomething based off geolocation.success(function(data){
    // On successful call do some logic and set what we need in the question data
    cb(question);
    //This now has the var question completely set the way we need it to populate the original function call.
  });
};

Conclusion

Passing functions as objects is really a neat idea. Event driven asynchronous programming is taking me a while to wrap my head around, but it is really powerful and can accomplish the same end goal as synchronous programming — You just need to know how the beast of javascript behaves.

Review of CAD U37 USB recording microphone

Description

I have a couple of various websites that need to have lots of audio recordings in them. At first I tried using the microphone build into my computer screen. It’s great for video chatting, but when quality matters I needed a different solution. I spent time looking around on the internet for a couple of days to see what most people used for hobbyist or amateur recording microphones. After much delineation I chose to buy the CAD U37. Other models like the YETI have more features, which I probably will never use, and they come at a much higher price tag — $200+.

Pros

  • The microphone is under $50.
  • Has two control switches
    • Switch one is for removing loud noises or people who talk too loud
    • Switch two is to filter base or large frequency sounds – such as normal house ventilation.
  • Looks slick and works right out of the box
  • This is a directional microphone so it doesn’t pick up noises off to the side or in another room

Cons

The main con I have had was initially mounting this to the suspension boom. The boom did not come with a piece that could hold the microphone, however, the stand that the microphone came with could screw into the boom — You only need to unscrew the end from the boom and take the female extension out of the microphone mount and put that extension into the CAD U37 stand piece.

Conclusion

I highly recommend anyone who is starting to record – whether for music, your own podcast, or other hobbyist fun – should get this microphone. If you decide to buy it for just a few dollars more you should get the pop filter for it. The pop filter will help reduce spit sounds and odd air movements – like heavy breathing and etc. The pop filter also helps clarify the differences between a “B” and “P”. The CAD U37 microphone is the cheapest of the high quality microphones.

How to get google to crawl your angular application

Description

I first discovered there was a problem when I went to google’s webmaster tools -> fetch as google -> and submitted a page of one of my sites to be crawled. It had a hash “#” in the URL as that was the default routeProvider using the yeoman framework. To my surprise google would not crawl that page. After doing some research google stops indexing pages after a “#”, unless u do something kind of crazy to trick it.



Step 1: Enable HTML 5 routes in angular with bang prefix

Inside my app.js you need to enable html

.config(function ($routeProvider, $locationProvider) {
//
//
.otherwise({
        redirectTo: '/'
      });
      $locationProvider.hashPrefix('!');
      $locationProvider.html5Mode(true);
  });

This now takes all my URL’s from host.com/#/foo to host.com/foo. The biggest caveat to this approach is if I want to browse directly to host.com/foo my angular app throws a 404. This apparently is because the application didn’t load all the javascript it needed. I would have to go to the main page and click to each link I want to go. This simply won’t work – what production level site on the internet does this?

Step 2: NGinX magic

Come to find out if you go to host.com/#!/foo the page will load and then redirect you to host.com/foo and load everything for you. Well I don’t want people to see that happen in their browsers. Solution? Add a some rewrite logic to the nginx conf file to handle all these type of redirects for me.

  if ($args ~ "_escaped_fragment_=/?(.+)") {
    set $path $1;
    rewrite ^ /snapshots/$path;
  }




Conclusion

Now my site in production, which runs using angular’s routing, now has prettier URLs and can go directly to the page I need. I still need to figure out how to get my grunt serve to do the same magic as my nginx configuration. Every time livereload happens I get a 404. For more information on why I used a hashbang “#!” as my escaped_fragment – google has some good documentation they provided their developers as to why they make their search crawler act that way. When I made the change I went back to the Fetch as Google section and sent in my page with no hash marks in the middle. Google finally will be able to index all the pages of my angular app.

Using Curl In Bash For Endpoint Rest Testing

Description

Sometimes I am shelled into an environment or server that I cannot revers proxy through and I can’t run programs like Postman or Advanced Rest Client, which are great programs. I use the following aliases inside my .bashrc files in every server I set up because of how useful they are. This way we can test if a server has access to a particular endpoint or we can see the response of an endpoint called from the server.



# curl aliases
alias get='curl -X GET'
alias geti='curl -i -X GET'
alias post='curl -X POST'
alias posti='curl -i -X POST'
alias put='curl -X PUT'
alias puti='curl -i -X PUT'
alias delete='curl -X DELETE'
alias deletei='curl -i -X DELETE'