2
Oct/09
0

Sphinx Search default limit is 20

When using the sphinx api, you must use SetLimts if you want more than 20 records.  Currently, it is not documented on the sphinx api doc.

8
Jun/09
0

Google maps info window size problem with images

One strange thing when using Google Maps API with pictures in the info window is that sometimes the window is not tall enough to enclose all the content. It overflows the white info window background. The problems is because Google maps API tries to calculate the height of all the content while the photos are being pulled by other http requests. They are asynchronous and the photos might take longer to load than it takes for Google Maps API to determine what the height of the info window should be. It has been said that setting the height of the element would give Gmaps a hint as to how tall the photos might be and adjust accordingly. So doing something like the following would help.

<img src=”pic.jpg” height=”80″ />

Also, if you are using any sort of table or div containers for the image, it would also help to specify the height of the container element to make sure Gmaps knows to account for it.

<table>
<tr height=”80″>
<td>
<img src=”pic.jpg” height=”80″ />
</td>
</tr>
</table>

Hope that helps you solve this little problem.

22
Jan/09
0

asp.net formview problem updating data

Very strange behavior with formviews on asp.net.  For some reason, if I declare the SqlDataSource on the page source but then do the binding of the SqlDataSource to the formview in code behind, no error are shown but the data does NOT get updated on edit.

So instead of doing this in code behind

summary.DataSourceID = "summaryDS";
summary.DataBind();

I need to do this on the page

<asp :FormView ID="summary"
runat="server"
DataSourceID="summaryDS">

A previous problem I encountered with formview

14
Jan/09
0

Develop and Debug – Android On A G1

Develop and Debug – Android.

This is a great way to debug your Android app on a G1 or any Android driven device via USB.  It is a much better way to go than the emulator if you have the resources.

Filed under: Coding, android
11
Dec/08
3

Update Delayed on Mysql and PHP

Wouldn’t it be nice if we could use UPDATE DELAYED in mysql just like we do use INSERT DELAYED? Unfortunately, the work around mysql created for this is to insert a record into the events table in order to separate UPDATE statement into another thread. There is a large overhead to inserting to then execute an update.

If you are using PHP with mysql, there is another work around.  PHP has a function called, register_shutdown_function, which will execute a function during the shutdown of processing a script file. So if we add an UPDATE LOW_PRIORITY sql statement wrapped in a function that is passed to register_shutdown_function, we can allow the user to receive the page without delay while the UPDATE statement waits until all locks on the table has been release before proceeding.

function update_delayed()
{
$sql = "UPDATE LOW_PRIORITY table_name SET col1 = 'something'";
mysql_query($sql, $conn);
}

register_shutdown_function('update_delayed');

I wonder if there are even better ways to handle this problem.

6
Nov/08
12

Getting Android emulator working with Google Maps API Key

I was trying to get an Android app that uses Google Maps API to display a MapView running on the emulator.  It took quite a bit of hair pulling to finally get it working.

First, I tried using a self-signed keystore instead of the the debug.keystore provided through the Android SDK.  I created my keystore using keytool -genkey from JDK.  Then I switch the app from using the default, debug.keystore, to my-new-self-signed.keystore.  Using keytool -list, I got the MD5 of the certificate that is needed to obtain a Google Map API key.  Then the API key was put into the MapView android:apikey attribute.  When I brought up the app in the emulator, I got a blank map grid screen.  The reason I wanted to use the self-signed keystore instead of the debug keystore is so I don’t have to obtain a new Map API key and change the code to reflect this upon releasing the app.

So, I decided to go with the debug.keystore and that worked fine.  Here is what I had to do.

  1. $ keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android
  2. Copy that MD5 and goto http://code.google.com/android/maps-api-signup.html
  3. Signup for an API key
  4. In my xml file that has the views for the activity, add
    <com.google.android.maps.MapView
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:enabled="true"
     android:clickable="true"
     android:apiKey="example_Maps_ApiKey_String"
     />
  5. In the Manifest.xml file, add the permissions needed
    <uses-permission android:name=”android.permission.INTERNET”></uses-permission>
    <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
  6. In the Manifest.xml file, add the maps library
    <uses-library android:name=”com.google.android.maps” />
    within the application tag
  7. The entire Manifest.xml looks like this
    <?xml version=”1.0″ encoding=”utf-8″?>
    <manifest xmlns:android=”http://schemas.android.com/apk/res/android”
    package=”com.informationideas.mapapp”
    android:versionCode=”1″
    android:versionName=”1.0.0″>
    <uses-permission android:name=”android.permission.INTERNET”></uses-permission>
    <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
    <application android:icon=”@drawable/icon” android:label=”@string/app_name”>
    <uses-library android:name=”com.google.android.maps” />
    <activity android:name=”.ShowDesktop”
    android:label=”@string/app_name”>
    <intent-filter>
    <action android:name=”android.intent.action.MAIN” />
    <category android:name=”android.intent.category.LAUNCHER” />
    </intent-filter>
    </activity>
    </application>
    </manifest>
  8. The default activity file should look like this

    package com.informationideas.mapapp;
    import android.os.Bundle;
    import com.google.android.maps.MapActivity;

    public class ShowDesktop extends MapActivity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    }

    @Override
    protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
    }
    }

Now off to building cool things with the map!

24
Jul/08
1

PHP header redirect

Something to remember when using header location to redirect a page from a server-side script.  The output is redirected to the new page, but the logic on the original file will continue to execute.  Therefore, if there are database calls the changes to the data will still be made even though a header redirect was issued.

To solve the problem, make sure to issue an exit() command after a header location command.

Filed under: Coding
29
May/08
0

Google Earth / Map Implementation Problem

One thing that was not documented fully at Google for integrating Google Earth into Google Map is that the function, getEarthInstance, is only available in the newest version of the Map API. I could not find exactly which version so the best way is to use v=2.x like in “http://maps.google.com/maps?file=api&v=2.x&key=yourkey” instead of specifying an exact version. Have fun with this new feature.

19
May/08
0

php strip_tags problem

I found that using php function, strip_tags, does not remove all the markup elements correctly from the subject content.  First of all, if an anchor link includes a line break, it will not be removed correctly.  Also, the style information is not properly removed as well.  In the following script, I also added in the regex to remove any content in between script tags, but that may or may not be necessary.

function strip_all_tags($content)
{
$content = preg_replace(‘/\n/’,’ ‘,$content);
$content = preg_replace(‘/<script.*<\/script>/U’,’ ‘,$content);
$content = preg_replace(‘/<style.*<\/style>/U’,’ ‘,$content);
$content = strip_tags(strtolower($content));
return $content;
}

The function will remove all line breaks so strip_tags will not have problems with finding all markups.  Since strip_tags does not remove <style> tags, the new function will remove them using regex.