Posts tagged with tips

  • Laravel unit testing in workbench note

    Just want to note down my experiences when doing unit testing with Laravel.

    Mockery

    Use Mockery to mock all the dependencies if possible to save time when executing the tests.

    Database Testing with Sqlite (in memory)

    If the tests involve a very complex SQL query/database, then should first try to do the testing using SQLite in memory. This will speed up execution time a lot as the database will be destroyed and re-created every time a single method runs. A database running in memory will speed up the process.

    However, there are some...

    Read More
  • Raspberry Pi setup notes

    This is just to document some setup issues and notes for Raspbian Wheezy:

    Upgrade and keep software up to date

    $ sudo apt-get update
    $ sudo apt-get upgrade
    

    Configuration

    $ sudo raspi-config
    

    Software installations

    # install vim
    $ sudo apt-get install vim
    
    # install LAMP
    $ sudo apt-get install apache2
    $ sudo apt-get install mysql-server
    $ sudo apt-get install php5
    

    Keyboard Issues & Fixes

    I keep having problems initially when press certain characters such as |, ~ does not appear correctly. The fix is to change keyboard locale to...

    Read More
  • Understand Simple & Effective Search Engine Optimizations

    Recently, I have read about search engine optimizations. I am quite new to this game :) It is quite interesting. Previously I was only aware about on-site optimization techniques. Basically, we could optimize the followings for our website:

    1. Friendly URLs containing keywords
    2. Friendly HTML titles, meta tags, keywords & description
    3. Image "Alt" tag
    4. Hyperlink anchors to contain the keywords
    5. Include keywords in headers (h1, h2,h3)
    6. Do internal linking
    7. Have a proper sitemap.xml
    8. Put javascript in external files.

    The more interesting aspect...

    Read More
  • Dealing with dynamic dropdowns with CasperJS

    In my experiment with CasperJS to extract the data from an aspx page, I faced some issues with dynamic drop-down. What happened is that there can be 2-3 dropdowns box that depend on each other e.g. User selects a category in dropdown1 , an AJAX request is triggered to create and populate sub-categories in dropdown2.

    My first reaction to this problem is to use Chrome Network Tool to capture the POST request when the form is submitted to find out all the parameters. Then, I attempt to simulate this by filling the form with all the...

    Read More
  • Fun scraping with casperjs and phantomjs

    Recently, I have been playing around with CasperJS and PhantomJS for web scraping. I always find screen scraping fun and fascinating. I mean there are just so many applications:

    1. We have bills/accounts all over the place in different websites. The scraping tools can be used to develop a program for personal use that can combine the results in a single place. It also can be used to trigger notifications e.g. bill payments reminder, manga notification, movies notification. The possibility is just endless :)

    2. We want to find and compare the...

    Read More