Tuesday, October 28, 2014

Webhost Phpmyadmin 4.1.8 Blank Page After Login

Just got this strange result of Phymyadmin 4.1.8 successful login return
white/blank screen. If you do think already input the correct
user and password of a database than simply reload the page and
you will get the phpmyadmin panels working.

Happy coding ^^

Android SQLite Example

 Stress out to find a good example of `How to Android SQLite` had leaded me
to collect piece-by-piece. The result a working apk that uses SQLite as database. The example below is from |1| but with little changes


package com.example.webview2;

import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

 // Constants
 public static final String DATABASE_NAME = "highscores.db";
 public static final String HIGH_SCORE_TABLE = "highscore";
 public static final String COLUMN_ID = "ID";
 public static final String COLUMN_SCORE = "SCORE";
 public static final String COLUMN_NAME = "NAME";

 public static SQLiteDatabase scoreDB;

 /** Called when the activity is first created. */
 public void onCreate(Bundle savedInstanceState) {

  final EditText editTextName = (EditText) findViewById(R.id.editTextName);
  final EditText editTextScore = (EditText) findViewById(R.id.editTextHighScore);
  final WebView webview = (WebView) findViewById(R.id.webview);

  // initial the database

  Button saveHighScore = (Button) findViewById(R.id.buttonSaveHighScore);

  OnClickListener clickListener = new OnClickListener() {

   public void onClick(View v) {

    // First get the values from the EditText
    String name = editTextName.getText().toString();
    int score = 0;

    try {
     score = Integer
    } catch (NumberFormatException e) {

    // Add the values
    ContentValues values = new ContentValues();
    values.put(COLUMN_NAME, name);
    values.put(COLUMN_SCORE, score);
    scoreDB.insert(HIGH_SCORE_TABLE, null, values);

    // Retrieve the new list of scores





  public void initDB()
    scoreDB = openOrCreateDatabase(DATABASE_NAME,
        | SQLiteDatabase.OPEN_READWRITE, null);

      + " VARCHAR, " + COLUMN_SCORE + " INT)");
 public void readData(WebView webview){

    Cursor c = scoreDB.query(HIGH_SCORE_TABLE, new String[] {
      COLUMN_NAME, COLUMN_SCORE }, null, null, null, null,
      COLUMN_SCORE + " DESC ");

    StringBuilder builder = new StringBuilder();

High Scores

"); c.moveToFirst(); for(int i=c.getCount()-1; i>=0; i--) { // Get the data builder.append(" "); // Move the cursor c.moveToNext(); } builder.append("
"); builder.append(c.getString(0)); builder.append(""); builder.append(c.getString(1)); builder.append("
"); webview.loadData(builder.toString(), "text/html", "UTF-8"); // Close the cursor c.close(); } @Override protected void onResume() { super.onResume(); initDB(); } @Override protected void onPause() { super.onPause(); if (scoreDB.isOpen()) { scoreDB.close(); } } }

For some of you who new to Android development then you could
continue to below instructions. For those who needs quick snippet
hope the code above will help.

1. Linux OS, i am using Fedora19 64bit. If you are using
    winOS or MaxOS you need to consult the manual from the
    Android Developer Website
2. Android SDK dan NDK 64bit, i don't use ADT (Eclipse) so excuse me
    if the next instructions are Command Line related.
3. Follow this official Android Developer tutorial on how to build an apk
4. Once a project created, then simply copy-paste the code above
    MainActivity.java located under /src///MainActivity.java
    Wheren subX and SubY depends how you defined your package during
    project creation
5. $ android 
    The syntax above is to run the android manager and do some updates.
    Make sure the build tools for your API is installed. If you don't then
    `no build tools` error will address you that the build tools needs to be
    installed via the android manager.
6. $ ant debug
    I assumed the build process will successful. If error like
    no build tools or whatever, indicates that you have not installed the build
    tools as stated at #5
7. $ android avd
    To run the emulator, but you need to set the arm images using the android
8. $ adb install -r bin/yourapp-debug.apk
    There will be upload indicator shown. The command line above was
    taken from here and thank you the easy way of install/uninstall
9. Your apk supposed to be in the emulator by this point.

Internet references
|1| Android and SQLite
|2| Android Developer Data Storage

Wednesday, October 8, 2014

Kivy 1.8.0 Python-for-Android Failed to Build Twisted module

Failed to built Twisted module in python-for-android ? Well you are in luck :D
You  could try this command below:

1. you are on python-for-android root dir

$ pwd

Your python-for-android root could be somewhere but mine is located
on /opt

$ ./distribute -m "zope setuptools pkg_resources twisted"

I found that at the end of the build virtualenv is being auto built
and in my case it failed to build but we don't need it anyway.
At this point i assume you are already successful to build twisted module.

Have fun ^^

Thursday, October 2, 2014

Linux Python 2.7.X Failed to Compile cmathmodule.c undefined reference to `_Py_log1p`

Compile Python 2.7.5 was never thought by me. As this article written
i had to compile Python from scratch. Just to troubleshoot why
Python-for-android `distribute.sh -m ``kivy``` failed to build.

Here is the log:

And found out that `_math.o` is required since where it has
the _Py_log1p defined. I manually exec this compile and
linker command as follow:

$ pwd

$ gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -c ./Modules/_math.c -o Modules/_math.o

$ ar rc libpython2.7.a Modules/threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/arraymodule.o Modules/_math.
_math.c  _math.h  _math.o

$ ar rc libpython2.7.a Modules/threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/arraymodule.o Modules/_math.o Modules/cmathmodule.o  Modules/mathmodule.o  Modules/_struct.o  Modules/timemodule.o  Modules/operator.o  Modules/_weakref.o  Modules/_randommodule.o  Modules/_collectionsmodule.o  Modules/itertoolsmodule.o  Modules/stropmodule.o  Modules/_functoolsmodule.o  Modules/_elementtree.o  Modules/datetimemodule.o  Modules/_bisectmodule.o  Modules/fcntlmodule.o  Modules/selectmodule.o  Modules/socketmodule.o  Modules/md5module.o Modules/md5.o  Modules/shamodule.o  Modules/sha256module.o  Modules/sha512module.o  Modules/binascii.o  Modules/parsermodule.o  Modules/cStringIO.o  Modules/cPickle.o  Modules/zlibmodule.o  Modules/xmlparse.o Modules/xmlrole.o Modules/xmltok.o Modules/pyexpat.o  Modules/xxsubtype.o

$ ranlib libpython2.7.a

$ gcc -pthread  -Xlinker -export-dynamic -o python Modules/python.o libpython2.7.a -lpthread -ldl  -lutil -L/usr/local/lib -lz    -lm

$ make

And Python 2.7.5 built success! I actually got the above syntax-es
from make, here how i did:

$ pwd

$ make -d > build.log

`make -d` will throw alot of commands that being executed.
Capture the output for later review and copy-paste. Share your