UITableViewController doesn't show content with static cell

I’ve been struggle for some time just because of the tableView doesn’t show any content to me.

The situation is, I’m trying to create a tableView with some sections and static cells, and it served as a rootViewController of a navigationController.

Read More

RSA encryption in iOS and decrypt it using PHP

I’ve been suffer for few weeks on RSA encryption in iOS. Now I would like to share the way of doing this.

First, generate a key-pair using SSL.

Read More

Ajax change dropdown list value with jQuery

A typical example for this is Country and State/Province.

You may have seen some website that provide such a dropdown list. When you change the Country, the State will be reloaded.

Read More

Generate a random string with JavaScript

In order to generate a random string, we must first specify length of string and character set

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function generateRandom(lengthOfString, charset) {
// The scope of the character
if(charset == null) charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';

var rand = '';

while(lengthOfString > 0) {
/*
since the index of char is start from 0, so no need to +1 on the random number
we want the range from 0 - lengthOfString
*/
rand += charset.charAt(Math.floor(Math.random() * charset.length));
lengthOfString--;
}
return rand;
}

Read More

Remove Macbuntu from Ubuntu 12.10

About a month ago, I follow the instruction from here installed some components to make my desktop like OS X.

Read More

iOS: UITabelView - didSelectRowAtIndexPath is not called

I had come across a problem which didSelectRowAtIndexPath doesn’t execute when I tap the cell.

1
2
3
4
5
6
7
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Successfully tapped");
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

Read More

Crawling sequantial images with shell script

Let say you want to download from http://www.domain.com/images/, and you know that the images name is from 001 to 100

Read More

How $_POST store array elements in PHP

Sometime we need an array form elements like this

1
2
3
4
<input type="text" name="foo[]" value="a" />
<input type="text" name="foo[3]" value="b" />
<input type="text" name="foo[]" value="c" />
<input type="text" name="foo[7]" value="d" />

Read More

OS X failed bundle install

When I try to setup octopress in OS X, I run bundle install, it always come out an error like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
$ bundle install
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/..
/Users/jslim/.rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler.rb:263: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Using rake (0.9.2.2)
Installing RedCloth (4.2.9) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/jslim/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb
checking for main() in -lc... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/jslim/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
--with-redcloth_scan-dir
--without-redcloth_scan-dir
--with-redcloth_scan-include
--without-redcloth_scan-include=${redcloth_scan-dir}/include
--with-redcloth_scan-lib
--without-redcloth_scan-lib=${redcloth_scan-dir}/lib
--with-clib
--without-clib
/Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:369:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:449:in `try_link0'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:464:in `try_link'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:607:in `try_func'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:833:in `block in have_library'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:778:in `block in checking_for'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:272:in `block (2 levels) in postpone'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:242:in `open'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:272:in `block in postpone'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:242:in `open'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:268:in `postpone'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:777:in `checking_for'
from /Users/jslim/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/mkmf.rb:828:in `have_library'
from extconf.rb:5:in `<main>'


Gem files will remain installed in /Users/jslim/.rvm/gems/ruby-1.9.3-p327/gems/RedCloth-4.2.9 for inspection.
Results logged to /Users/jslim/.rvm/gems/ruby-1.9.3-p327/gems/RedCloth-4.2.9/ext/redcloth_scan/gem_make.out
An error occurred while installing RedCloth (4.2.9), and Bundler cannot continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.

Read More

ls command in OS X

ls by default in OS X has no --group-directories-first

Open up your terminal

1
$ brew install coreutils

Read More