2013-08-16

FIX: Errors with installing MySQL on Ubuntu

In order to install a LNMP environment on a VPS, I've tried the following command to install MySQL server, but what I got is:


130816 18:53:17  InnoDB: Waiting for the background threads to start
130816 18:53:18 InnoDB: 5.5.32 started; log sequence number 1595675
130816 18:53:18  InnoDB: Starting shutdown...
130816 18:53:19  InnoDB: Shutdown completed; log sequence number 1595675
start: Job failed to start
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.5 (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Processing triggers for ureadahead ...
Errors were encountered while processing:
 mysql-server-5.5
E: Sub-process /usr/bin/dpkg returned an error code (1)

It's really an error message that says nothing. The ubuntu is freshly installed. After hours of trying with solutions from Internet, I've found the following solution working for me:


sudo apt-get clean

sudo apt-get autoclean

sudo apt-get remove --purge mysql-client-5.5 mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5

sudo apt-get install mysql-server




before reinstalling, you may need also the following commands:


rm -rf /var/lib/mysql
rm -rf /etc/mysql*



So it is.

2013-08-15

FIX: Xcode failed to get the task for process XXX

Recently by debugging an app on devices, Xcode keeps throwing the error message "Failed to get the task for process XXX" like this:

enter image description here

After long searching on the internet, one solution has saved my day:

It turns out that using a different provisioning profile (one with a wildcard rather than one without) solved this issue.

So I changed the provisioning profile by debugging from app specified to ios team provisioning profile. BRAVO,  now it works like a charm.

via StackOverflow

2013-08-13

Workaround for "AssertMacros: queueEntry, file: /SourceCache/IOKitUser_Sim/IOKitUser-920.1.11/hid.subproj/IOHIDEventQueue.c, line: 512"

I am busy recently with testing some apps under iOS 7 Beta 5. Now while running the app, the debug console keeps outputting some useless information like:

AssertMacros: queueEntry, file: /SourceCache/IOKitUser_Sim/IOKitUser-920.1.11/hid.subproj/IOHIDEventQueue.c, line: 512

 It is really annoying and makes the debug info useless, since it appears every time when I touch the screen. Thanks 0xced, now here is a workaround solution for that:


Here is a workaround to this annoying problem.

  1. Download fishhook
  2. Copy fishhook.h and fishhook.c in your project
  3. Compile this file (QuietAssertMacros.c) in your project:



#include <dlfcn.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "fishhook.h"

int slient_fprintf(FILE * restrict stream, const char * restrict format, ...)
{
    if (strncmp(format, "AssertMacros:", 13) == 0)
    {
        return 0;
    }
    else
    {
        va_list args;
        va_start(args, format);
        int result = vfprintf(stream, format, args);
        va_end(args);
        return result;
    }
}

__attribute__((constructor)) void QuietAssertMacros(void)
{
    rebind_symbols((struct rebinding[1]){{"fprintf", slient_fprintf}}, 1);
}
Unfortunately, you will have to repeat these steps for every project you are working on.

via devforum apple

2013-07-30

MySQL Error 1130 "Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server."

When I tried to connect a mysql server from outside today morning, I got a mysql error like:

ERROR 1130: Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server.


That means the mysql server is configured to allow only local connections. The configuration can be modified easily in mysql tables.

Under terminal, type the following commands

> mysql -u root -pmypassword

mysql> use mysql;

mysql> update user set host = '%' where user = 'root';

mysql> flush privileges;



Now you could connect the mysql server from the outside client.

2013-06-26

Strange Behavior: UIButton Text will be not shown.

Because of a multilingual project, all the texts should be translated and replaced with the correct language version. Everything was fine until I found that a button won't show the text assigned.

The code:


 [button titleLabel].text = @"I won't be changed";


The result is: the button shows always the text that is set up in the storyboard. If I delete the text in Storyboard, it will even disappear when I tap!

The solution is also simple:


[button setTitle:@"I will change" forState:UIControlStateNormal]


via StackOverflow

2013-06-17

One Class for One Problem

The keyboard on iOS devices is sometimes a nightmare for a programmer.  Take the UITextField as an example, when a keyboard appears, it will cover most screen area and let the text fields hidden in the back of the soft keyboard. A solution provided by Apple is using the UIScrollView, but there are a lot of mathematical calculation for a programmer. :(

After a while research on the internet, I've found that Michael Tyson has built a drop-in solution for such kind of problems. He packs everything that one needs into a class and puts the sources on GitHub.

If you follow the instruction on the Github, the task with UITextField and Keyboard is easy as a cake!

Usage

For use with UITableViewController classes, drop TPKeyboardAvoidingTableView.m and TPKeyboardAvoidingTableView.h into your project, and make your UITableView a TPKeyboardAvoidingTableView in the xib. If you're not using a xib with your controller, I know of no easy way to make its UITableView a custom class: The path of least resistance is to create a xib for it.
For non-UITableViewControllers, drop the TPKeyboardAvoidingScrollView.m and TPKeyboardAvoidingScrollView.h source files into your project, pop a UIScrollView into your view controller's xib, set the scroll view's class toTPKeyboardAvoidingScrollView, and put all your controls within that scroll view. You can also create it programmatically, without using a xib - just use the TPKeyboardAvoidingScrollView as your top-level view.


Well done, Michael!

via ATasty Pixel

HOWTO: UIScrollView scroll to bottom programmatically

The autolayout function of a view controller is very useful. The UI elements can find their position after a rotation automatically. Except for UIScollerview...Orz

The reason is: The Layout in Storyboard is normally designed for portrait, not for landscape. So if an user rotates his iOS devices, the UIScrollView cannot resize its content height automatically. So a programmatical resize is needed. BUT, there is another way: just scroll the UIScrollView to the bottom(or where you want), the content will be presented in landscape correctly like in portait.

Here is the solution: Adding the following code to the view controller where the scroll view is.



-(void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
// Scroll to the bottom
CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height);
[self.scrollView setContentOffset:bottomOffset animated:YES];
}

via StackOverflow

2012-08-21

iOS: nested push animation can result in corrupted navigation bar


Today I got a very strange error by running an iOS App:

1. nested push animation can result in corrupted navigation bar
2. Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

It happens when the view controller tries to pop to top view controller without waiting for the loading end of child view controller.

Solution:

1. try to set a boolean variable to mark the view controller should pop to the top view controller
2. in viewDidAppear:(BOOL)animated method, check if a call of [self.navigationController popToRootViewControllerAnimated:YES] is needed

The reason:

popToRootViewControllerAnimated() must be called after the view appears!

2012-08-06

Fixing double entries in "Open with" menu under Mac OS X

Sometimes it is very annoying to see duplicated entries in the "Open with..." menu under MAC OS X, the reason is just the database for file types doesn't refresh for some reason. Now it can be fixed using:

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Tested under Mac OS X 10.8 (Mountain Lion).

2011-12-22

Fix the cydia crash problem after jailbreak iOS 5 with redsn0w 0.9.9b9

It is really weird. After using redsn0w 0.9.9b9 to jailbreak my iPhone 3GS with iOS 5.0.1, the iphone can be booted with the option "just boot" in redsn0w. The Cydia icon showes up on the screen. Open it and say I am a "User". The loading process can be seen, and... quit. I can ssh into the iOS, that is to say, the iphone is already jailbroken. But what happened with Cydia?!

I've tried many different methods.

1. restore the stock firmware and do the jailbreak again. -> No success.
2. reinstall Cydia with SSH on the iPhone. -> No success.
3. just boot the iphone tetherly again and again -> No success.


So I tried to read the log file of Cydia. The log file can be found at /private/var/tmp/cydia.log. I noticed that an error is repeated again and again.


2011-12-22 14:43:20.135 MobileCydia[252:e07] Setting Language: de_DE
Assertion failed: (dictionary->lockFD != -1), function IDXUserDictionaryOpen, file /SourceCache/Mecabra/Mecabra-248/mecabra/IDXUserDictionary.c, line 88.

I've googled for a while and nothing is found...but it must be something wrong with the laguage settings. I've discoved I use English as user interface language and German as date/time format. Mumm, maybe that is the problem. I've set the both as English. Now, Cydia runs smoothly without any problems.

In a short, that is a bug of Cydia, it depends on the language settings of iOS! Try to set up the language unified, then it doesn't complain again.

2011-11-19

How to install FontForge on Mac OS X Lion

Since I got some old font files before 2007 and I wanna use them, after some inspection, Font Magager told me that the name tables of the fonts are mssing. In order to add them manually, I googled a while to find out FontForge can do the job.

Now comes the problem. FontForge is open source and doesn't provide any compiled binary for Mac OS X ab 10.6. That means, one must complie it before it can be used. So after a little searching again, I found Garrick's guide [How to install fontforge on mac os lion]. Sadly, the process he used doesn't work for me.

He suggests that it can be done easily with the commands:

brew install fontforge
sudo brew link fontforge

The first command returns some fatal errors:

Error: Failed executing: make install
These existing issues may help you:
https://github.com/mxcl/homebrew/issues/7658
https://github.com/mxcl/homebrew/issues/8144
https://github.com/mxcl/homebrew/issues/8491

Then the answers in those issues suggest:

brew install cairo --use-clang

I tried

brew install fontforge

after successful execution of that command. Then it came with:

Error: Failed executing: make
If `brew doctor' does not help diagnose the issue, please report the bug:
https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue

According to the message, I ran the command:

brew doctor

The result was:

Unbrewed dylibs were found in /usr/local/lib.

If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
/usr/local/lib/libfaac.0.dylib
/usr/local/lib/libfreetype.6.dylib
/usr/local/lib/libical.0.0.0.dylib
/usr/local/lib/libicalss.0.0.0.dylib
/usr/local/lib/libicalvcal.0.0.0.dylib
/usr/local/lib/libltdl.3.1.0.dylib
/usr/local/lib/libmp3lame.0.dylib
/usr/local/lib/libmp4v2.0.dylib

Unbrewed static libraries were found in /usr/local/lib.

If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
/usr/local/lib/libdevkit.a
/usr/local/lib/libical.a
/usr/local/lib/libicalss.a
/usr/local/lib/libicalvcal.a
/usr/local/lib/libkld.a
/usr/local/lib/libltdl.a
/usr/local/lib/libredo_prebinding.a

Unbrewed .la files were found in /usr/local/lib.

If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
/usr/local/lib/libical.la
/usr/local/lib/libicalss.la
/usr/local/lib/libicalvcal.la
/usr/local/lib/libltdl.la


So I deleted all the above mentioned files manually and executed the command again.

brew install fontforge


The result:


Error: Failed executing: make
If `brew doctor' does not help diagnose the issue, please report the bug:
https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue


Very luckily I saw a warning before the compiling errors, that reads:

Warning: Building with LLVM, but this formula is reported to not work with LLVM:

Compiling cvexportdlg.c fails with error: initializer element is not constant

We are continuing anyway so if the build succeeds, please open a ticket with
the following information: 2336-10.7. So
that we can update the formula accordingly. Thanks!

If it doesn't work you can: brew install --use-gcc


So I tried the command again:

brew install fontforge --use-gcc

Now Mac OS X Lion lets me compile FontForge endly.

In conclusion, the right commands to compile FontForge on Mac OS X Lion should be:

brew install cairo --use-clang

brew install fontforge --use-gcc


In order to see FontForge in Application folder, you need to run this command:

ln -s /usr/local/Cellar/fontforge/20110222/FontForge.app /Applications

2011-11-14

iOS BUG: Synced music won't appear in iPod or Music App

Yesterday I've updated my iPhone 3GS by the means of OTA (Over The Air) to the newest firmware iOS 5.0.1. Everything runs smoothly, BUT! After I open the supplied Music App, I've seen only a very little part of my music collection? Where did they go?



Firstly I thought the update deleted my not-from-itunes-store-bought music files, then I checked the iTunes, the status bar of my iphones indicates that there are exactly 13.6GB music files on it. It appears that the mediathek file on the iphone has corrupted with the update, or maybe the update has changed the structure of the mediathek file and forgetten to update it.

What can I do? Sure, completely restore is one way but also the last way I wanna go. So I've googled around for a while to find out a better and smart way to correct it. Then I found this article [iOS 4.2 bugs: iPhone music gone after the update? Here’s the fix! ]. Okay, i am not the only one and iOs 5.0.1 is also not the only one with that bug.




  1. Grab your cable and plug your iPhone into iTunes on your Windows or Mac PC


  2. When your iPhone shows up in the sidebar, make sure you can see the content listings beneath it (click on the triangle to the left if not)


  3. Click on music


  4. Pick a song


  5. Play it in iTunes


  6. Sync your iPhone


The method in that article didn't work for me for the first time. I have to figure out why it doesn't work. The reason behind that method is: Change the play count for a song, then iTunes changes the mediathek file on the iPhone.

So it is very important for that method, just try to play a song and maybe you can forward it very quickly to the end, make SURE that the play count of that song changed and resync!

Things are gonna be alright and we don't know when apple will fix that long-lasting bug.

2011-11-10

Goodbye, Flash on mobile devices!

Now the war is over. Adobe has declared that they abandon the development of Flash on mobile devices. The winner is HTML 5.

Like Google has mentioned before, the future of Internet belongs to the browser. If we think it further, in the future there should be at least one browser on one device, that means, developers should consider how and what information should be delivered, but not on what kind of devices will support it.

In other word, HTML 5 won this war just because one of its properties, "once programmed, run everywhere". Sounds familiar, right? Sure, it is the slogan of Java.

In my opinion, the device in the future should have some CSS rules to let the end user know what kind of mobile device they use. Take Mobile Safari as an example, its UI elements on a website without CSS are looked exactly like an app on a iPhone.

Now the day is coming, are you ready for the changing?

2011-11-04

Fix the problem with Captive Network under Mac Lion 10.7.2

The Auto Logon Window for Captive Network in Mac OS X Lion is very handy, but with the update 10.7.2 there are so many problems with such a feature happened. Sadly I have to use the IE in my VM Windows to get me logged in.

Now here is the solution:

Use Terminal or Text Editor to edit the file /etc/hosts and add the following lines to the end:

127.0.0.1 crl.usertrust.com
127.0.0.1 ocsp.usertrust.com
127.0.0.1 crl.incommon.org
127.0.0.1 ocsp.incommon.org
127.0.0.1 crl.comodoca.com
127.0.0.1 crl.comodo.net
127.0.0.1 ocsp.comodoca.com

After that, the DNS cache must be cleared with Terminal Command:

dscacheutil -flushcache

Log off and log on, you will see the missing feature again under Lion 10.7.2.


The reason:

With the update 10.7.2 Lion has made some errors on CSL certificates, especially on some captive networks that need the user wait for a few seconds.

Enable AirDrop on older Macs

We all know that Apple has disabled the useful function AirDrop on its older Macs. Now with some work in Terminal, you can enable AirDrop for many older Lion systems at the Terminal command line. Enter:
defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1

After setting the defaults, A restart of Finder will be necessary:

killall Finder

Once you do, you will see the AirDrop icon on the left panel of Finder.

2011-09-16

Review of Adobe Edge Preview


Adobe has shown the newest HTML authorizing tool Adobe Edge for a while. Acoording to Adobe, with that tool the making of animated web pages should be easier. Precisely, "Adobe Edge create animated web content using HTML5, CSS3 and JavaScript with ease, power and precision". With a lot of interest I have tested the product. The version Preview 1 is of Aug. 18, 2011 and the Preview 2 of Sept. 8, 2011.

The experience from Preview 1 is really disappointed. There are only 4(!) tools available on the toolbar: select, rectangle, rounded rectangle and text. So only thing I can do is draging the tools to the stage and making some changes to the object.

Now comes the so called big part. The animation part will be done with a timeline that is very similar to that in Adobe Flash. Define the starting and ending property value, the animation (between frames) will be generated automaticly. After doing that, we can take a preview in a browser directly without saving.

If we look at the source code, Adobe Edge utilites jQuery framework actually to make the animation possible. All the animations are capsuled in one generated JavaScript file and all the propery changes will be defined in one CSS file. The part of the html contains only the UI element.

The source code of a html file looks like that:


<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<!--Adobe Edge Runtime-->
<script type="text/javascript" src="edge_includes/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="edge_includes/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="edge_includes/edge.0.1.2.min.js"></script>
<script type="text/javascript" src="edge_includes/edge.symbol.0.1.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="Untitled-1_edge.js"></script>
<link rel="stylesheet" href="Untitled-1_edge.css"/>
<!--Adobe Edge Runtime End-->

</head><body style="margin:0;padding:0;">
<div id="stage" class="symbol_stage">
</div>
</body>
</html>


That idea sounds good, because the user can use Adobe Edge as Adobe Flash. BUT, wait a second, the real world is very complicated. What about a property that is only deteminated by runtime or even by the related position to other objects? Adobe Edge seems cannot afford such kind of work at the moment.

Actually, Adobe Edge is somehow like Adobe Catalyst compared with Adobe Flash Builder. In Adobe Edge, the source code of a html file cannot be seen or edited. It is really like a tool for traditional Flash developers who begin to jump into the html world.

As fas as I said, there is still a long way for Adobe Edge to go to let the web developers accept the tool.

2011-09-09

Ubuntu (11.04) "Unity" now fails on OSX Lion (10.7) with Parallels (6.0.12094)

It is actually a discussion from
http://forum.parallels.com/showthread.php?t=112331

The story is like this. When I used Ubuntu (11.04) "Unity" on OSX Snow Leopard (10.6) with Parallels (6.0.12094), there was no problem at all. All the graphic effects can be switched on to make my eyes happy. After updating the totally new advanced operating system Mac OSX Lion(10.7), it did not work any more.

I did some research on the net. Then I found out that the issue has been reported to the Parallels company and they promised to fix it. After two months waiting on the patch (normally an update for version 6), now come the news said that the Paralles has a new version of 7. In order to fix the problem, we should take an upgrade for $49! So that is the deal, if we buy the Parallels 6 after 1. August 2011, we can get an upgrade for free. But(!) the issue is reported already right after the opening date of Mac OSX Lion, which is 22. July. So it is unfair for such people who bought the Version 6 after upgrading their mac to Mac OSX Lion.

Anyway, let's see if that fix will be ported to Paralles 6 too since the company assures that the Version 6 should also run on Lion.

Reborn

It seems somehow a long time passed by that I didn't make a new post here. The reason is very simple: the iPhone.
Since I've used the iPhone around 2009, it is always a tough job for me to post something on blogger.

There are many apps on iPhone which can do the communication well, such as twitter, Facebook and so on. But until today Google gets the blogger app on the iPhone. So I think it may be already too late for such service from google. Anyway, I will try to update my blog here from today :-)

2009-10-22

HOWTO: Install Java 1.4 & 1.5 on Snow Leopard

Because of some projects, I need to complie some Java projects in Eclipse with older Java versions, such as 1.4.2, on my MacBook, but since Snow Leopard is such a new(!) operating system, it lacks a lot of support for softwares running with older versions of libraries.

After a long while searching in the internet, finally I found the way to install JVM 1.4 & 1.5 on Snow Leopard!

Java 1.4:
Here is how to get Java 1.4 running on snow leopard.
cd /tmp/
curl -o java.1.4.2-leopard.tar.gz http://tedwise.com/files/java.1.4.2-leopard.tar.gz
tar -xvzf java.1.4.2-leopard.tar.gz
sudo mv 1.4.2 /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2
cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo ln -s 1.4.2 1.4
open "/Applications/Utilities/Java Preferences.app"
and Java 1.5:
cd /tmp/
curl -o java.1.5.0-leopard.tar.gz http://tedwise.com/files/java.1.5.0-leopard.tar.gz
tar -xvzf java.1.5.0-leopard.tar.gz
sudo mv 1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leo
cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo rm 1.5.0
sudo mv 1.5.0-leo 1.5.0
sudo ln -s 1.5.0 1.5
open "/Applications/Utilities/Java Preferences.app"
It really works! ;-)

via [OneSwarm]

Update (2014-05-05): the broken links are fixed.

2009-09-29

Some Reasons Why I Don't Update My iPhone (1st Gen) To Firmware 3.1

The firmware 3.1 for iPhone has been released for a while. Every time when I plug in my iPhone to my Macbook, the iTunes reminds me always of a new iPhone OS available. But I must say no to iTunes every time. So why I don't want update my iPhone to that version 3.1? There are 5 reasons or at least my considerations.

PROs:
1. PwnageTool 3.1 (http://blog.iphone-dev.org/) is ready for the go. AppSync for OS 3.1 in Cydia is appeared too. (Instructions)
2. iPhone OS 3.1 has the funtion that man can arrange the application layout directly in iTunes.
3. Genius Mix will be supported.

CONs:
1. For non-Standard accessories there are still no hacks appeared like 3.01. The magic is called iapd. It fixs the problem with the message "This Accessory is not made to work with iPhone"

2. It's possible to develope iPhone applications for jailbroken iPhone 3.0 with a patched XCode 3.1.3. (Source) But until now, I didn't get how to make it work with iPhone OS 3.1 and XCode 3.2.


Updates!
1. MichaelS confirmed that the pathed iapd for 3.0 also works for 3.1.2!
2. Xcode 3.2 works
with jailbroken iPhone 3.1 too according to
the "Float Middle" Blog.


So, now it is the time to update! :)