WatchKit is coming!

WatchKit comes as it’s supposed to be. I always think it is a brilliant chance to develop a series of watch apps.

While looking up the documentations Apple gives out, I find there are something interesting, or unbelievable.

For example, could you design the resolutions of your Apple Watch like this?



Apple is so kind to add a few lines below the picture: Provide image assets for different screen sizes as needed.

Now we are not only dealing with varies of sizes on iPhone or iPad but also on Apple watch – a single product line.

Anyway, what are you planing for the upcoming chances?



Create Index Page for App Store AdHoc Apps

Usually we use AdHoc distributions to share our apps to testers or important clients.

When we create those apps, we will get a plist file and an ipa file and upload these two files to our web server.

It’s better to have an automatically generated index page rather than manually modifying an HTML page.

This is an example to create such a dynamic page using PHP 5.

At the beginning, we need to support iPhone / iPad devices by adding the following viewport option:

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

First, we will scan the current folder and gather all the plist file infos:

$plists = array();

// read all plist files in the current folder
if ($handle = opendir(‘.’))

// enum current folder
while (($entry = readdir($handle)) !== false)
// check extension to accept .plist only
$ext = pathinfo($entry, PATHINFO_EXTENSION);
if ($ext != “plist”) continue;

$plists[] = array(‘file’ => $entry, ‘time’ => filemtime($entry));


Secondly, we’d better sort the list by the last modified time, of course, descending:

// sort plists by last modified time
function cmp($a, $b)
if ($a[‘time’] == $b[‘time’]) return 0;
return $a[‘time’] > $b[‘time’] ? -1 : 1;
uasort($plists, ‘cmp’);

We should create links directly to the plist files. Here’s the prefix of those links:

// generate link prefix
$prefix = ‘itms-services://?action=download-manifest&url=http://’.$_SERVER[‘HTTP_HOST’].dirname($_SERVER[‘PHP_SELF’]).’/’;

At last, we enum each plist file info and output them as a <li> tag:

// show all plists
foreach ($plists as $info)
$url = $prefix.$info[‘file’];

// extract plist info
$plist = simplexml_load_file($info[‘file’]);

// // fetch url link
// $url = $plist->dict->array->dict->array->dict->string[1];

// fetch metadata
$node = $plist->dict->array->dict->dict;
$meta = array();
for ($i=0; $i < count($node->key); $i++)
$meta[$node->key[$i].”] = $node->string[$i];

// fetch version and title
$version = $meta[‘bundle-version’];
$title = $meta[‘title’];
$subtitle = isset($meta[‘subtitle’]) ? $meta[‘subtitle’] : ”;

<a href=”<?php echo $url?>”><?php echo $title?></a>
<span class=”note”> (<?php echo $version?>) </span>
<div><?php echo $subtitle?></div>


That’s it!

In this approach, we can even use SubTitle field to add extra Html information into our index page list.

AJAX jQuery Preview a photo/image before upload

<!DOCTYPE html>
<script src="<jquerypath>/jquery.min.js"></script>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();

reader.onload = function (e) {

<input type='file' onchange="readURL(this);" />
<img id="img_prev" src="#" alt="your image" />

CSS: Three/3 Columns Div – fluid, fixed, fluid

It is a classic problem.


#header_left {width:50%; float:left; margin-right:-500px;}
#header_left_in {height:100px; margin-right:500px; background-color:red;}
#header_center {height:100px; width:1000px; float:left; background-color:yellow; position:relative; z-index:-10;}
#header_right {width:50%; float:right; margin-left:-500px;}
#header_right_in {height:100px; margin-left:500px; background-color:blue;}


<div id=”header_left”><div id=”header_left_in”></div></div>
<div id=”header_center”></div>
<div id=”header_right”><div id=”header_right_in”></div></div>

That’s it!

#header_left/right_in is necessary.

Merge existing repository into a subdirectory/subfolder

How to merge an existing repository into a new subdirectory of the current repository?

Here is the answer!

If the exist repo path is: /path/to/ex/repo, and you can give it a new name such as: ExRepo

If you want to import this repo to the current repository as sub-directory SubDir:

  1. git remote add -f ExRepo /path/to/ex/repo
  2. git merge -s ours –no-commit ExRepo/master
  3. git read-tree –prefix=SubDir/ -u ExRepo/master
  4. git commit -m “Merge ExRepo as our subdirectory SubDir

It’s done! Just four lines. What do these steps mean?

  1. fetch the other project “ExRepo
  2. prepare for the later step to record the result as a merge
  3. read “master” branch of ExRepo to the subdirectory “SubDir
  4. record the merge result

You may commit exist changes first if you have got the error “Merge with strategy ours failed“.

One more thing, how to update SubDir after merging is simple the same. Just type:

  1. git pull -s subtree ExRepo master

Enjoy & Good lock!



How to delete user password in Linux?

How do I delete user Password under Linux? I’d like to disable a password for an account.

After Google, I’ve found the solution.

All user encrypted passwords are stored in /etc/shadow file. The quick way to remove/delete a user password is pass –delete option to passwd command. First, login in as a root user.

Command to delete user password under Linux

Type the following command to delete a user password:

# passwd --delete username


# passwd -d username

Above command delete a user’s password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless. User will not able to login. It is also a good idea to setup user shell to nologin to avoid security related problems:

# usrmod -s /sbin/nologin username

For example to delete password for user vivo, Type:

# passwd -d vivo
# usrmod -s /sbin/nologin vivo