The Mobile Galaxy The New Mobile Era Has Come | Mobile – A Time To Remember

26Sep/110

Installing PyGTK on Mac Lion

NOTE: IF YOU HAVE USED MACPORTS/FINK, REMOVE ALL TRACES OF IT BEFORE CONTINUING

I assume you want to install gtk at ~/gtk, if not change the instructions accordingly.

First we need to install JHBuild:
curl -o gtk-osx-build-setup.sh https://raw.github.com/jralls/gtk-osx-build/master/gtk-osx-build-setup.sh
sh gtk-osx-build-setup.sh
Once JHBuild is installed run these commands:
export PATH=$HOME/.local/bin:$PATH
vi  ~/.jhbuildrc-custom

add the line:

build_policy = "updated-deps"

Save and exit the file.

By default JHBuild will install gtk to ~/gtk, if you want a different location edit ~/.jhbuildrc and change the install directory.

We are now ready to build GTK:
jhbuild bootstrap
Fix gettext error:

Fix gettext issue with compilation under OS X Lion by editing a single line in the source (I use vi, but use whatever editor you like):
vi ~/gtk/source/gettext-0.18.1.1/gettext-tools/gnulib-lib/stpncpy.c
Change line 34, replacing __stpncpy with __stncpy (no “p”) at the beginning of the line. Save and exit the file.

Once done then run:
jhbuild build meta-gtk-osx-bootstrap
jhbuild build meta-gtk-osx-core

Fix error:
GTK doesn't build on Lion because of a small problem at the linking step with a test program named "autotestkeywords". Please find the build log and patch attached. Does anyone know why including only headers in a file like autotestkeywords.cc would cause the symbol "_objc_msg_send_fixup" to be generated when using the 10.7 SDK as opposed to the 10.6 SDK? In any case, the patch causes linkage with the requisite frameworks.

vi ~/gtk/source/gtk+-2.24.0/tests/Makefile.in

tests/Makefile.in

old new
89 89 @HAVE_CXX_TRUE@am_autotestkeywords_OBJECTS =  \
90 90 @HAVE_CXX_TRUE@ autotestkeywords-autotestkeywords.$(OBJEXT)
91 91 autotestkeywords_OBJECTS = $(am_autotestkeywords_OBJECTS)
92 autotestkeywords_LDADD = $(LDADD)
93 92 AM_V_lt = $(am__v_lt_$(V))
94 93 am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
95 94 am__v_lt_0 = --silent
685 684 testtooltips_DEPENDENCIES = $(TEST_DEPS)
686 685 testvolumebutton_DEPENDENCIES = $(TEST_DEPS)
687 686 testwindows_DEPENDENCIES = $(TEST_DEPS)
687 autotestkeywords_LDADD = $(LDADDS)
688 688 flicker_LDADD = $(LDADDS)
689 689 simple_LDADD = $(LDADDS)
690 690 print_editor_LDADD = $(LDADDS)
jhbuild build meta-gtk-osx-python

jhbuild build meta-gtk-osx-themes
GTK and PyGTK should now have been built.

Now navigate to ~/gtk/inst/lib/python2.7/site-packages and copy the contents of the site-packages folder to
/Library/Python/2.7/site-packages

Or run:
echo "import site; site.addsitedir('~/gtk/inst/lib/python2.7/site-packages')" > /Library/Python/2.7/site-packages/gtkredirect.pth
Obviously replace ~/gtk/inst with the path to your gtk installation.

You got it, PyGTK.
The attached is compiled package. PyGTK2.24.6.Don't forget to modify
/Library/Python/2.7/site-packages/gtkredirect.pth to this package. :)
Share
Tagged as: , No Comments
26Sep/110

Fetching tiles for Offline Map

BE WARE: If you are trying to cache the tiles that Google serves, that may be a violation of Google's Terms of Service.
Google Maps API Premier License Agreement

3.4 Cache Restrictions. Customer may not pre-fetch, retrieve, cache, index, or store any Content, or portion of the Services with the exception being Customer may store limited amounts of Content solely to improve the performance of the Customer Implementation due to network latency, and only if Customer does so temporarily, securely, and in a manner that (a) does not permit use of the Content outside of the Services; (b) is session-based only (once the browser is closed, any additional storage is prohibited); (c) does not manipulate or aggregate any Content or portion of the Services; (d) does not prevent Google from accurately tracking Page Views; and (e) does not modify or adjust attribution in any way.

using System.Collections.Generic;
using System.Text;
namespace MapTileURL
{
    class Program
    {
        private static Dictionary<string, string> MapTypeURLs = new Dictionary<string, string>
        {
            { "GoogleSatURL", "<a href="http://khm{GOOG_DIGIT}.google.com/kh/v=58&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://khm{GOOG_DIGIT}.google.com/kh/v=58&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleMapURL", "<a href="http://mt{GOOG_DIGIT}.google.com/vt/lyrs=m@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.com/vt/lyrs=m@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleHybURL", "<a href="http://mt{GOOG_DIGIT}.google.com/vt/lyrs=h@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.com/vt/lyrs=h@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleTerURL", "<a href="http://mt{GOOG_DIGIT}.google.com/vt/lyrs=t@108,r@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.com/vt/lyrs=t@108,r@121&hl=en&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "GoogleChinaURL", "<a href="http://mt{GOOG_DIGIT}.google.cn/vt/lyrs=m@121&hl=en&gl=cn&x={X}&y={Y}&z={ZOOM}&s={GALILEO">http://mt{GOOG_DIGIT}.google.cn/vt/lyrs=m@121&hl=en&gl=cn&x={X}&y={Y}&z={ZOOM}&s={GALILEO</a>}" },
            { "YahooMapURL", "<a href="http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1">http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1</a>" },
            { "YahooSatURL", "<a href="http://maps{Y_DIGIT}.yimg.com/ae/ximg?v=1.9&t=a&s=256&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1">http://maps{Y_DIGIT}.yimg.com/ae/ximg?v=1.9&t=a&s=256&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1</a>" },
            { "YahooInMapURL", "<a href="http://maps.yimg.com/hw/tile?locale=en&imgtype=png&yimgv=1.2&v=4.1&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2">http://maps.yimg.com/hw/tile?locale=en&imgtype=png&yimgv=1.2&v=4.1&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2</a>}" },
            { "YahooInHybURL", "<a href="http://maps.yimg.com/hw/tile?imgtype=png&yimgv=0.95&t=h&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2">http://maps.yimg.com/hw/tile?imgtype=png&yimgv=0.95&t=h&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM_2</a>}" },
            { "YahooHybURL", "<a href="http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&t=h&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1">http://maps{Y_DIGIT}.yimg.com/hx/tl?v=4.3&t=h&.intl=en&x={X}&y={YAHOO_Y}&z={YAHOO_ZOOM}&r=1</a>" },
            { "MicrosoftBrMapURL", "<a href="http://imakm{MS_DIGITBR}.maplink3.com.br/maps.ashx?v={QUAD}|t&call=2.2.4">http://imakm{MS_DIGITBR}.maplink3.com.br/maps.ashx?v={QUAD}|t&call=2.2.4</a>" },
            { "MicrosoftHybURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/h{QUAD}.png?g=441&mkt=en-us&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/h{QUAD}.png?g=441&mkt=en-us&n=z</a>" },
            { "MicrosoftSatURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/a{QUAD}.png?g=441&mkt=en-us&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/a{QUAD}.png?g=441&mkt=en-us&n=z</a>" },
            { "MicrosoftMapURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&n=z</a>" },
            { "MicrosoftTerURL", "<a href="http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&shading=hill&n=z">http://ecn.t{MS_DIGIT}.tiles.virtualearth.net/tiles/r{QUAD}.png?g=441&mkt=en-us&shading=hill&n=z</a>" },
            { "OpenStreetMapURL", "<a href="http://tile.openstreetmap.org/{ZOOM}/{X}/{Y}.png">http://tile.openstreetmap.org/{ZOOM}/{X}/{Y}.png</a>" },
            { "OSMARenderURL", "<a href="http://tah.openstreetmap.org/Tiles/tile/{ZOOM}/{X}/{Y}.png">http://tah.openstreetmap.org/Tiles/tile/{ZOOM}/{X}/{Y}.png</a>" },
            { "OpenAerialMapURL", "<a href="http://tile.openaerialmap.org/tiles/?v=mgm&layer=openaerialmap-900913&x={X}&y={Y}&zoom={OAM_ZOOM">http://tile.openaerialmap.org/tiles/?v=mgm&layer=openaerialmap-900913&x={X}&y={Y}&zoom={OAM_ZOOM</a>}" },
            { "OpenCycleMapURL", "<a href="http://andy.sandbox.cloudmade.com/tiles/cycle/{ZOOM}/{X}/{Y}.png">http://andy.sandbox.cloudmade.com/tiles/cycle/{ZOOM}/{X}/{Y}.png</a>" }
        };
        readonly static char[] Lookup = new[] { 'q', 't', 'r', 's' };
        public static string GetQuadtreeFromXYZoom(int x, int y, int zoom)
        {
            var quad = new StringBuilder();
            for (int i = 0; i < zoom; i++)
            {
                int rx = x % 2;
                int ry = y % 2;
                x /= 2;
                y /= 2;
                quad.Insert(0, Lookup[rx * 2 + ry]);
            }
            quad.Insert(0, 't');
            return quad.ToString();
        }
        public static string BuildUrl(string tileType, int x,int y,int zoom)
        {

            string url = "";
            // Edited by Shustrik - compacted the switch statement
            switch (tileType)
            {
                case "GoogleSat":
                case "GoogleSatH":
                    url = MapTypeURLs["GoogleSatURL"];
                    break;
                case "GoogleMap":
                    url = MapTypeURLs["GoogleMapURL"];
                    break;
                case "GoogleHyb":
                    url = MapTypeURLs["GoogleHybURL"];
                    break;
                case "GoogleTer":
                    url = MapTypeURLs["GoogleTerURL"];
                    break;
                case "GoogleChina":
                    url = MapTypeURLs["GoogleChinaURL"];
                    break;
                case "MicrosoftMap":
                    url = MapTypeURLs["MicrosoftMapURL"];
                    break;
                case "MicrosoftSat":
                    url = MapTypeURLs["MicrosoftSatURL"];
                    break;
                case "MicrosoftHyb":
                    url = MapTypeURLs["MicrosoftHybURL"];
                    break;
                case "MicrosoftTer":
                    url = MapTypeURLs["MicrosoftTerURL"];
                    break;
                case "MicrosoftBrMap":
                    if (zoom <= 10)
                        url =  MapTypeURLs["MicrosoftMapURL"];
                    else
                        url = MapTypeURLs["MicrosoftBrMapURL"];
                    break;
                case "YahooMap":
                    url = MapTypeURLs["YahooMapURL"];
                    break;
                case "YahooSat":
                case "YahooSatH":
                case "YahooSatH2":
                    url = MapTypeURLs["YahooSatURL"];
                    break;
                case "YahooHyb":
                    url = MapTypeURLs["YahooHybURL"];
                    break;
                case "YahooInMap":
                    url = MapTypeURLs["YahooInMapURL"];
                    break;
                case "YahooInHyb":
                    url = MapTypeURLs["YahooInHybURL"];
                    break;
                case "OpenStreetMap":
                    url = MapTypeURLs["OpenStreetMapURL"];
                    break;
                case "OSMARender":
                    url = MapTypeURLs["OSMARenderURL"];
                    break;
                case "OpenAerialMap":
                    url = MapTypeURLs["OpenAerialMapURL"];
                    break;
                case "OpenCycleMap":
                    url = MapTypeURLs["OpenCycleMapURL"];
                    break;
            }

            // Edited by Shustrik - added variables for configuration settings other than Google
            string quadcode = "";
            for (int i = (int)zoom - 1; i >= 0; i--)
                quadcode = quadcode + (((((y >> i) & 1) << 1) + ((x >> i) & 1)));
            url = url.Replace("{X}", x.ToString());
            url = url.Replace("{Y}", y.ToString());
            url = url.Replace("{Z}", ((int)zoom).ToString());
            url = url.Replace("{ZOOM}", ((int)zoom).ToString());
            url = url.Replace("{QUAD}", quadcode);
            url = url.Replace("{YAHOO_Y}", (((1 << ((int)zoom)) >> 1) - 1 - y).ToString());
            url = url.Replace("{YAHOO_ZOOM}", ((int)zoom + 1).ToString());
            url = url.Replace("{YAHOO_ZOOM_2}", (17 - (int)zoom + 1).ToString());
            url = url.Replace("{OAM_ZOOM}", (17 - (int)zoom).ToString());
            url = url.Replace("{GOOG_DIGIT}", ((x + y) & 3).ToString());
            url = url.Replace("{GOOG_QUAD}", GetQuadtreeFromXYZoom(x, y, zoom));
            url = url.Replace("{MS_DIGITBR}", ((((y & 1) << 1) + (x & 1)) + 1).ToString());
            url = url.Replace("{MS_DIGIT}", ((((y & 3) << 1) + (x & 1))).ToString());
            url = url.Replace("{Y_DIGIT}", ((x + y + zoom) % 3 +1).ToString());
            url = url.Replace("{GALILEO}", "Galileo".Substring(0, ((3 * x + y) & 7)));
            // support old style {} vars
            url = url.Replace("QQQQ", GetQuadtreeFromXYZoom(x,y,zoom));
            url = url.Replace("XXXX", x.ToString());
            url = url.Replace("YYYY", y.ToString());
            url = url.Replace("ZZZZ", (17 - (int)zoom).ToString());
            url = url.Replace("{OSM_ZOOM}", ((int)zoom).ToString());
            url = url.Replace("{MS_QUADCODE}", quadcode);
            url = url.Replace("*", ((x+y+zoom) %4).ToString());
            return url;
        }
        static void Main(string[] args)
        {
            string url = BuildUrl("GoogleMap", 1, 1, 1);
            //return <a href="http://mt2.google.com/vt/lyrs=m@121&hl=en&x=1&y=1&z=1&s=Gali">http://mt2.google.com/vt/lyrs=m@121&hl=en&x=1&y=1&z=1&s=Gali</a>
        }
    }
}
Share
Tagged as: , , , No Comments
25Sep/110

How to get the center coordinate of google map?

Sometimes, When we download offline map, we need a center coordinate of a map.

1. open google map;

2. adjust map and make sure the point  what you want at the center;

3. paste the following code at the url address input area of your explorer.

javascript:void(prompt('',gApplication.getMap().getCenter()))

 

Share
Filed under: HTML5, iPhone, Other, PHP No Comments
25Sep/111

Today, InMotion Hosting was hacked

Today, My website was hacked. A message show all InMotion servers were hacked. I just moved to InMotion Hosting because of Rank #1,  before I had rent three different web hosting, all never occurred to be hacked. Sad.

Solution:

index.php pages were replaced or added to folders. Simply restoring from a backup should fix the problem. If you don’t have a backup and if you have un-modified index.php from wordpress or oscommerce you can just overwrite download that version of software you’re running and overwrite the index.php they put in.

How to fix Inmotion Hosting hack by Tiger M@te

 

 

see: http://www.ilovefreesoftware.com/25/articles/inmotion-hosting-hacked.html

Servers of InMotion Hosting have been hacked. The home page of InMotion Hosting is showing hacked, though some of the internal website pages are working fine.

Update 25-Sept, 4.45 AM CST: I was able to get in touch with the support team of Inmotion Hosting, and got this info:

there appears to be a mass server hack that has replaced the index file in the public_html of several accounts, we are working to do a full server restore on all servers to get that back up and running, unfortunately as there is an investigation going on now my details given to me are limited

Update 25-Sept, 5.02 AM CST: Many customers of InMotion Hosting have mentioned in comments below that it is easy to get your hacked website back up. If you have some old Index.php file, just copy that to the existing Index.php, and your website will probably be back up. This is because hackers seem to have replaced Index.php files on many accounts (InMotion support team also confirmed that above). I am trying this right now.

Update 25-Sept, 5.15 AM CST: Home Page of InMotion Hosting has been restored. Still no word from management on when will they restored the affected websites of customers, and how did this large scale hack happened.

I have a couple of websites with InMotion Hosting, and they are also showing the same “Hacked” page.

There is no official word yet from InMotion Hosting on the extent of hack, and time it will take for websites to get back up.

What worries me most is that hackers might steal the credit card info that InMotion hosting would have stored. Also, I am really hoping that InMotion Hosting is able to get my websites back up, with all the data, and I don’t end up losing everything.

Share
Tagged as: , 1 Comment
24Sep/110

Objective-C 声明中加减号区别

减号表示一个函数、或者方法、或者消息的开始,或者可以说是实例方法。

-(void) action:(bool) enable
{
    //do something
}
在Objective-C里面没有public和private的概念,你可以认为全是public。
而用加号的意思就是其他函数可以直接调用这个类中的这个函数,而不用创建这个类的实例及类方法。
Share
10Sep/110

iPhone耳机使用技巧

你的iPhone 耳机是不是从买回来就放在盒子里从来不用呢?被我
说中了吧,其实过去我也这样,直到我真正了解到它的功能。
耳机最主要的用途是听音乐、打电话。本人喜欢音乐,所以先说在
听音乐上的使用。你知道吗,它可以让你从此不用再摸手机了,把手机
放心地放在包包里吧,跟我把注意力集中在耳机线上那个小方块——中
央控制按钮上。
基本功能如下。
暂停/ 播放:按一下开始播放,再按一下停止播放。
跳到下一首歌曲:快速连按两下。注意速度要快(可以自己感觉一
下节奏)。
返回到上一首歌:快速连按三下,同样需要注意速度。
如果你只想听一段歌曲的高潮部分,或是和别人分享相声最好玩的
那段,也就是想要快进和倒回该怎么办?这显然通过跳转或返回是不能
实现的。
现在就揭晓这个窍门,还是连按两下小方块,这时注意,第二下按
下去不要松手,直到你想停的地方再松手,这就是快进。想要倒回,连
按三下,第三下按住不放就可以了。
这是耳机技巧的全部吗?当然不是。如果你想听一首歌,难道要
通过跳转和返回一首一首去找吗?不用。例如,你想听《忐忑》,那么
按住耳机中央控制按钮不放,直到听到“咚咚”两声提示音。现在放开
控制按钮,对着话筒(就是按钮背面那个小孔)说“播放 忐忑”,这时
奇迹发生了,《忐忑》开始播放了。需要注意的是这两个词中间留点空,
而且为了识别准确需要说标准的普通话。
通过耳机对语音识别,可以帮你彻底把手从手机上解放出来,甚至
比操作手机还要有效率。再如,你想听王菲的歌,那么把上面那句“播
放 忐忑”改成“播放 王菲”,这时所有王菲的歌就会依次播放,神奇吧。
想要拨打电话吗?不用动手机,不用翻看通讯录一个个查找。举个
例子,想要给李明打电话,按照刚才的方法启动语音控制,对着话筒说“呼
叫 李明”,这时就会自动拨打李明的电话。如果想要拨打的电话号码没
存在你的通讯录里,那么直接说“呼叫 1860220****”也可以,是不是
很方便。通过按下中央按钮也可以接听或挂断电话。想想这和我们前面
提到的哪个功能类似呢?是的,就是“语音控制”,这样看来中央按钮
相当于是手机上的Home 键,用它来触发语音控制系统。
说到这里,我们不得不为iPhone 所惊叹,它是这样智能方便,就
连一个小小的耳机都能演绎得如此精彩。如果这时你得意地认为它的光
彩已经被完全释放,那么你就错了。试想一下,有没有遇到半夜醒来拿
手机看时间,眼睛被突然亮起的屏幕刺激很不舒服?你可能会问,这个
iPhone 也能帮忙?
是的,方法还是刚才所说的,启动语音控制,对话筒说“现在时间”,
有一个甜美的声音会对你说:“现在时间× 点× 分”,是不是很人性化,
之所以这样设计,小D 认为也是苹果公司兑现“无障碍使用承诺”的体
现之一吧。

Share
Tagged as: No Comments
5Sep/110

zbar扫描条形码/二维码

1.新建一个工程A:view-base   
2.拖动zbar框架到工程目录下  
3.然后把zbar/iphone目录下的工程.xproj文件拖到A  
4.在工程的Link Binary添加框架如下:  
libzbar.a  
QuartzCore.framework  
libiconv.dylib  
5.添加#import "ZBarReaderController.h"  
-(IBAction) startScan  
{  
    ZBarReaderController *reader = [[[ZBarReaderController alloc] init] autorelease];  
    reader.delegate = self;  
    reader.cameraMode = ZBarReaderControllerCameraModeSampling;  
      
    ZBarImageScanner *scanner = reader.scanner;  
    [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to:0];  
      
    [self presentModalViewController: reader animated:YES];  
      
}  
- (void) imagePickerController: (UIImagePickerController*) picker didFinishPickingMediaWithInfo: (NSDictionary*) info  
{  
    UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];  
      
    id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];  
    ZBarSymbol *symbol = nil;  
      
    for(symbol in results)  
    {  
        break;  
    }  
      
    if(!symbol || !image)  
    {  
        return;  
    }  
      
    NSLog(@"symbol.data = %@", symbol.data);  
      
//最关键的移行代码  
    self.resultLabel.text = symbol.data;  
      
    [picker dismissModalViewControllerAnimated: YES];  
}  
6.给.h添加<UINavigationControllerDelegate,UIImagePickerControllerDelegate>
Share
2Sep/110

Unhide Library Folder in Mac OS X 10.7 Lion

Okay, so I know most of you probably don't have the dev release of Mac OS X 10.7 Lion, but I got it today, and a really big thing was changed... Apple hid the Library folder which is usually in your Home folder. After a little bit of searching, I found the answer on how to unhide it.

Because it is a folder hidden by Apple, it is flagged, so the Terminal command would be:

chflags nohidden /Users/<Username>/Library

or use an easier way.

chflags nohidden ~/Library/

This is especially helpful in Lion, yet it can be used in previous versions of Mac OS X.

Just a tip, if you want to unhide any file or folder on Mac that you hid using a period in front of its name, you can use this command:

mv /path/to/file/.name /path/to/file/newname

Hope this saves you the hassle of looking all over for these commands like I had to do!

Share
Tagged as: No Comments
2Sep/110

Improve large file process performance

Using "NSDataReadingMapped" option can extremely improve read speed for a large data file.

The following statement run fastly.

 NSError *error = nil;
    NSBundle *bundle = [NSBundle mainBundle];
    NSData *data = [NSData dataWithContentsOfFile:[bundle pathForResource:@"LargeFile(100M)" ofType:@"dat"] options: NSDataReadingMapped error:&error];

The following statement run slowly.

 NSError *error = nil;
    NSBundle *bundle = [NSBundle mainBundle];
    NSData *data = [NSData dataWithContentsOfFile:[bundle pathForResource:@"LargeFile(100M)" ofType:@"dat"] options: 0 error:&error];
Share
2Sep/110

Coordinate and Address

Get current location coordinate:

@implementation CurrentLocation

@synthesize locationManager;
@synthesize target,callBack;

#pragma mark --
#pragma mark Public
-(void) startUpdatingLocation{
	[[self locationManager] startUpdatingLocation];
}
#pragma mark --
#pragma mark Memory management
-(void) dealloc{
	[super dealloc];
	[locationManager release];
}
#pragma mark --
#pragma mark Location manager
/*
 Return a location manager -- create one if necessary.
 */
- (CLLocationManager *)locationManager {
    if (locationManager != nil) {return locationManager;}
    locationManager = [[CLLocationManager alloc] init];
    [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
    [locationManager setDelegate:self];
    return locationManager;
}
#pragma mark --
#pragma mark CLLocationManagerDelegate methods
/*
 Conditionally enable the Add button:
 If the location manager is generating updates, then enable the button;
 If the location manager is failing, then disable the button.
 */
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation {
	NSLog(@"got the coordinate!");
}
- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error {
        NSLog(@"Failure!");
 }
@end

Get current location address:

@implementation AddressReverseGeoder

#pragma mark --
#pragma mark Public
//根据经纬度开始获取详细地址信息
- (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude{
	CLLocationCoordinate2D coordinate2D;
	coordinate2D.longitude = longitude;
	coordinate2D.latitude = latitude;
	//
	MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate2D];
	geoCoder.delegate = self;
	[geoCoder start];
}
#pragma mark --
#pragma mark MKReverseGeocoderDelegate methods
//获得地址信息
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
	NSString *address = [NSString stringWithFormat:@"%@ %@ %@ %@ %@%@", 
									  placemark.country,
									  placemark.administrativeArea,
									  placemark.locality,
									  placemark.subLocality,
									  placemark.thoroughfare,
									  placemark.subThoroughfare];
	NSLog(@"经纬度所对应的详细:%@", address);
	geocoder = nil;
}
//错误处理
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
	NSLog(@"error %@" , error);
}
#pragma mark --
#pragma mark Memory management
- (void)dealloc {
    [super dealloc];
}
@end
Share