My studying notebook

2012/05/26

[Titanium]iOS: App build fails on Snow Leopard/iOS 4.3 configured machine

5/26/2012 04:55:00 PM Posted by Unknown , , 2 comments
OS
  • Lion 10.7.4
  • xCode 4.3
iPhone Simulator


Titanium SDK 1.7.5, 1.8.2, 2.0.1GA and 2.0.1.GA2. Everything does work on iPhone Simulator. But, it is very SLOW when you want to rebuild project or debug it.


Install to iOS Device

I got an error message below when i want to install project to iOS device in the couple days.  It success when i choose Titanium SDK lower 1.8x.

[ERROR] /Users/timothy/Documents/Titanium Studio Workspace/Scratch/build/iphone/Classes/NetworkModule.m:252:44: error: use of undeclared identifier 'UIRemoteNotificationTypeNewsstandContentAvailability' [2]
[ERROR] /Users/timothy/Documents/Titanium Studio Workspace/Scratch/build/iphone/Classes/NetworkModule.m:304:33: error: use of undeclared identifier 'UIRemoteNotificationTypeNewsstandContentAvailability' [2]
[ERROR] 
[ERROR] Error: Traceback (most recent call last):
File "/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.v20120410131722/iphone/builder.py", line 1318, in main
execute_xcode("iphonesimulator%s" % link_version,["GCC_PREPROCESSOR_DEFINITIONS=__LOG__ID__=%s DEPLOYTYPE=development TI_DEVELOPMENT=1 DEBUG=1 TI_VERSION=%s %s %s" % (log_id,sdk_version,debugstr,kroll_coverage)],False)
File "/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.v20120410131722/iphone/builder.py", line 1224, in execute_xcode
output = run.run(args,False,False,o)
File "/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.v20120410131722/iphone/run.py", line 41, in run
sys.exit(rc)
SystemExit: 65

Finally, i got the solution when i search an issue tracker in appcelerator. This bug has fixed in Release 2.1.0.

Reference

2011/09/22

[Notebook] How to setup iphoneofflinemap on your iPhone, cydia requirement.

9/22/2011 11:47:00 PM Posted by Unknown , , , , 3 comments

Smart phone map App may have already improved your life experience if you ever used it. You can check map anytime and anywhere on your smart phone but internet necessary. Offlinemap let you can check map without internet. It's very convenient to you when you are in oversea or can't access the internet. 

iphoneofflinemap is an iphone cydia app that you can put offline map grabbed from Google map using GMDL (Global Map Download Tool)

simple scenario 

preparing necessary tools → backup current iphone cache map → Download target offline map → modify downloaded map → upload to iPhone → setup bookmark → respring

Step1.Getting started. You need to download few tools.
  1. GMDL (Global Map Download Tool). In iphoneofflinemap project. issues 59 reported: downloaded map doesn't work with ios4. Someone update a GMDL ip4 v10 hack. You can download hacked version here that you don't need to convert maps by mapconverter anymore.
  2. SQLite manager Firefox extension that you can modify downloaded map.
  3. iFunbox that you can upload offline maps to your iPhone very easily.
  4. install iphoneofflinemap app in cydia
Step2. backup iPhone current cache map.
Attache iPhone to computer and backup "/var/mobile/Library/Caches/Map/MapTiles/MapTiles.sqlitedb"  (this is original iPhone cache map)  by iFunbox.

Step3. Grab target offline map you want to download. 
  1. Download maps by GMDL.
  2. Convert maps tiles in an SQLite DB. The only one thing you should notice is locale. "en_TW" for example.

  3. In output folder. You can see "com.apple.Maps" and "MapTiles.sqlitedb". done.
Step4. Modify download maps.
  1. Open backup cache map earlier (original MapTiles.sqlitedb) by Firefox SQLite manager can check version and locale.

  2. Modify downloaded MapTiles.sqlistedb version and locale same as cache map.
Step5. Upload offline map to your iPhone.
  1. put target offline maps MapTiles.sqlitedb to "/var/mobile/Media/Maps/ChiMai". If Media don't have "Maps" folder, create one and put maps on folder you want by iFunbox.
Step6. Setup offline map bookmark.
Without internet access. you still can view map with GPS but search and direction. Therefore, it's better to put some map books in offline map also.

  1. you can visit Google Map (my places) and make some placemarks in maps called "Thailand trip" for example.

  2. copy KML address and visit (http://vcenter.iis.sinica.edu.tw/mobile/kml/loadkml_map.html) to convert those placemarks to iPhone plist.

  3. upload Bookmarks.plist to "/var/mobile/Library/Map" (it's better to backup original one)
Step7. respring (it's very important).
  1. open iphoneofflinemap (atlas) on iphone and "remove all  caches".
  2. type your map and select copy
  3. select "Continues". Do NOT select "Map" directly. 
  4. respring your iPhone 
  5. turn off 3G, WiFi and Data. You can use offline map now.
Result.


2011/09/04

[Notebook] Using jQuery templates in Google AppEngine

9/04/2011 10:52:00 PM Posted by Unknown , , , , , , 344 comments
jQuery is a powerful javascript library that you can improve web browser experience just add some js codes. jQuery also has a lot of useful plugin you can add. lightbox, autocomplete etc.

jQuery supports Templates plugin now that you can render HTML code very simply. Here has very detail document and tutorial. Today, i will talk about how to use jQuery templates in Google AppEngine. What is the problem using jQuery templates in Google AppEngine web application.? Braces {}.

Templates syntax.
Google AppEngine Django template.
{% for item in objs %}
 {{item}},
{% endfor %}

jQuery Templates
<script id="doclistTmp" type="text/x-jquery-tmpl">
        {{each(i, o) obj}}
        <tr class="{{if i%2== 0}}odd{{else}}even{{/if}}">
            <td> ${title}</td>
            <td>${type}</td>
            <td>${folders}</td>
        </tr>
        {{/each}}
</script>

They both use brases is problem that you will meet it if you want to use jQuery templates via ajax in Google AppEngine. Then, how to setup jQuery templates in Google AppEngine.

Step1.
Register a tag in a py file called "verbatim_templatetag.py" {{if condition}} print something{{/if}}. Tell Django don't change anything within this tag.
"""
jQuery templates use constructs like:

    {{if condition}} print something{{/if}}

This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.

Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best
to output the contents with no changes.
"""

from django import template

register = template.Library()

class VerbatimNode(template.Node):

    def __init__(self, text):
        self.text = text

    def render(self, context):
        return self.text

@register.tag
def verbatim(parser, token):
    text = []
    while 1:
        token = parser.tokens.pop(0)
        if token.contents == 'endverbatim':
            break
        if token.token_type == template.TOKEN_VAR:
            text.append('{{')
        elif token.token_type == template.TOKEN_BLOCK:
            text.append('{%')
        text.append(token.contents)
        if token.token_type == template.TOKEN_VAR:
            text.append('}}')
        elif token.token_type == template.TOKEN_BLOCK:
            text.append('%}')
    return VerbatimNode(''.join(text))

Step2.
Include custom tag in your py file that you use web template
 template.register_template_library('verbatim_templatetag') 

Step3.
Add you jQuery template to html page.
 {% verbatim %}
        <script id="movieTemplate" type="text/x-jquery-tmpl">
            <tr>
                <td>${posted}</td>
                <td><a href="${link}">${response_count}</a></td>
                <td>{{html content}}</td>
            </tr>
        </script>
 {% endverbatim %} 

Step.4
call jQuery templates.
  $("#movieList").html($("#movieTemplate").tmpl( plurks )); 


Reference

2011/05/09

Manage ebooks download list with Google Reader and RTM

5/09/2011 11:29:00 PM Posted by Unknown 2 comments
cause tablet computer like iPad etc. It's very convenient to read ebook (epub, pdf, etc) in your tablet computer anywhere. I like to download pdf ebook from websites and upload to my Google Docs. Then, i have my own ebook bookshelf on the cloud. I subscript few ebooks shared website. Most of those ebooks shared from web spaces that is limited download if you don't pay money. So, i create a RTM list to manage how many ebooks i haven't download. Once i downad it and i will mark it complete.

simple scenario is:
Google Reader → send to function → RTM

step:
  1. RTM setting: create a list called "ebook"
  2. viste: https://m.rememberthemilk.com/add
    after login your RTM. you will see the a simple form.
    you can get "List" dropdown list value(id) by viewing sources code. ebook
  3. Google Reader setting:
    options > Reader settings > Send To, Create a custom link
  • Name: RTM(ebook download)
  • URL: https://m.rememberthemilk.com/add?name=${title}&url=${url}&due=2 days&priority=3&repeat=0&estimate=5 minutes&tags=download&list=[your ebook list id]
  • Icon url: http://www.rememberthemilk.com/favicon.ico

fill form out with above value. You might notice that you can assign due, priority etc. The most important here is your ebook list id (you can get it at step 2). After finishing and save.

All settings done.
Now, you can subscript ebook download site (http://www.wowebook.com/ for example) RSS. Once you get a new RSS and want to add to your RTM ebook download list. Just click "send to > RTM(ebook download)". You will redirect to http://m.rememberthemilk.com. Click "Add Task". done.

i post it to RTM forum
https://www.rememberthemilk.com/forums/tips/12673/

2010/07/07

Google Reader's Toggle Icon

7/07/2010 03:13:00 PM Posted by Unknown , 2 comments

If you have used Google Reader. There is a toggle icon you can click and expand all items view size. This toggle icon is a small blue arrow. Is it a image? No. It's just a CSS tips and tricks. How does CSS do it?
Toggle icon DOM element
...
<td id="chrome-lhn-toggle">
    <div id="chrome-lhn-toggle-icon"></div>
</td>
...

Toggle icon CSS
{
    width: 0;
    height: 0;
    border-color: #ebeff9 #68e #ebeff9 #ebeff9;
    border-style: solid;
    border-width: 5px 5px 5px 0;
}

You just need to assign the "border" CSS to toggle icon DOM element like ahove.
You may have to assign others CSS if you want this toggle icon in that correct position you want.



border Css order style
#right{
border-style:solid;
border-color: red green blue yellow;
border-style: solid;
border-width: 50px 50px 50px 50px;
width:0;
height:0;
display:inline-block;
}
#left{
border-style:solid;
border-color: #ebeff9 #68e #ebeff9 #ebeff9;
border-style: solid;
border-width: 50px 50px 50px 50px;
width:0;
height:0;
display:inline-block;
}

Whole DOM and CSS code
//DOM
...
<td id="chrome-lhn-toggle">
    <div id="chrome-lhn-toggle-icon"></div>
</td>
...
//CSS
#chrome-lhn-toggle:hover {
background: #C2CFF1;
}
#chrome-lhn-toggle, #chrome-viewer {
padding: 0px;
vertical-align: top;
}
#chrome-lhn-toggle {
background: #EBEFF9;
cursor: pointer;
width: 8px;
}
#chrome-lhn-toggle:hover #chrome-lhn-toggle-icon {
border-color: #C2CFF1 white #C2CFF1 #C2CFF1;
}
#chrome-lhn-toggle-icon {
border-color: #EBEFF9 #68E #EBEFF9 #EBEFF9;
border-style: solid;
border-width: 5px 5px 5px 0px;
height: 0px;
margin-left: 1px;
margin-top: -5px;
position: absolute;
top: 50%;
width: 0px;
}
#chrome-lhn-toggle-icon {
font-size: 1px;
line-height: 1px;
}

Conclusion
This is a simple way to make a arrow icon by pure CSS instead of assigning image.

2010/07/02

Convert rgb color to hex color

7/02/2010 11:00:00 AM Posted by Unknown , , , 2 comments
If you have written HTML file, you must know that how to assign color to DOM element. You just need to assign CSS style to
DOM element like

<span style="color:#ff0000">This is text</span>
It is very simple. But, we may want to change the color
by Javascript like color picker. What's the problem? You may get the "rgb(255, 0, 0)" color value by Javascript.
Then, you have to convert rgb to hex color or convert hex to rgb color. The following is simple code.

rgb to hex


function rgb2hex(rgb){
var hexDigits = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
var hex = function(x){
return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
};
var tmp = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
var color = hex(tmp[1]) + hex(tmp[2]) + hex(tmp[3]);
return color;
}

hex to rgb

function hex2rgb(v){
if (/^[0-9A-F]{3}$|^[0-9A-F]{6}$/.test(v.toUpperCase())) {
if (v.length == 3) {
v = v.match(/[0-9A-F]/g);
v = v[0] + v[0] + v[1] + v[1] + v[2] + v[2];
this.value = v;
}

var r = parseInt(v.substr(0, 2), 16);
var g = parseInt(v.substr(2, 2), 16);
var b = parseInt(v.substr(4, 2), 16);
return [r, g, b].join(',');
}
return v;
}

Result

var input = $(this).css('color'); // rgb(255,0,0)

var hex = rgb2hex(input); //ff0000
var rgb = hex2rgb(hex); //255,0,0