MISC


10
May 12

ios dev: unrecognized selector sent to instance

Today is the first day I started to programmed on iOS. I compiled a very small, simple app. That went well until I ran it and clicked on a button. Instantly I got this error:


unrecognized selector sent to instance

If you google this error, it leads you to very complicated topics for a beginner:

http://stackoverflow.com/questions/861626/how-to-resolve-unrecognized-selector-sent-to-instance

Actually, my problem is much simpler. I forgot to define ancestor method for a property. I added a outlet in .h file, but in .m file I forgot to define getter and setter method, or in otherwords, I didn’t put indicator @synthesize .

I noted here so if you see something with above message, make sure you didn’t forgot any @synthesize or you need to define 2 accessor methods yourself:

  • - (NSString *)userName
  • - (void)setUserName:(NSString *)newUserName

4
May 12

Homebew and XCode 4.3: make, cmake issue

If you used previous version XCode, you maybe never got some errors complain about make, cmake or sth which I totally forgot now. But if you use XCode4.3, then when you run homebrew and come to step “make install”, you will stuck there because of lots of  make, cmake, cflag errors… If you come to Google u will got many complicated explanations and solutions. But the problem is much simpler. The real problem here is the missing of command line tools. XCODE 4.3 is shipped without Command Line Tool by default. You might to manually download and install inside XCode in Downloads section. Check the box “Command Lines Tools”,  install it and you will be able to compile and install with homebrew after that.


4
May 12

Using homebrew to install anything got: “Error: Cannot write to /usr/local/Cellar”

I had a weird situation once I install anything with homebrew, I stucked at:


Error: Cannot write to /usr/local/Cellar

I do


ls -la /usr

and got this


loho:~ kureikain$ ls -la /usr
total 8
drwxr-xr-x@   13 root  wheel    442 May  4 12:42 .
drwxrwxr-t    27 root  admin    986 May  3 10:44 ..
drwxr-xr-x     8 root  wheel    272 Jul  2  2011 X11
lrwxr-xr-x     1 root  wheel      3 Dec  7 11:43 X11R6 -> X11
drwxr-xr-x  1058 root  wheel  35972 May  4 12:42 bin
drwxr-xr-x   288 root  wheel   9792 May  4 12:41 include
drwxr-xr-x   342 root  wheel  11628 May  4 12:42 lib
drwxr-xr-x   141 root  wheel   4794 May  4 12:42 libexec
drwxr-xr-x     7 root  wheel    238 Jan 27 18:32 llvm-gcc-4.2
drwxrwxr-x    10 root  admin    340 May  4 14:02 local
drwxr-xr-x   261 root  wheel   8874 May  4 12:42 sbin
drwxr-xr-x    69 root  wheel   2346 May  4 12:42 share
drwxr-xr-x     4 root  wheel    136 Jul  2  2011 standalone

For some reasons, /usr/local belongs to admin group insteads of wheel. with sudo, we need to have it in group “wheel”. I recall that this happened after I manually change the username. I had an account on Mac Mini with username “vinhnguyen”. I then decided to change it, so I manually enable root account and change the name of home folder. After I do that, /usr/local became to belong to admin group.

Futher, if I continue to check /usr/local, I got:


loho:~ kureikain$ ls -la /usr/local/
total 24
drwxrwxr-x  10 root        wheel  340 May  4 14:02 .
drwxr-xr-x@ 13 root        wheel  442 May  4 12:42 ..
-rw-r--r--   1 kureikain   admin  159 May  4 14:01 .gitignore
drwxr-xr-x   2 vinhnguyen  admin   68 May  4 11:10 Cellar
drwxrwxr-x   6 vinhnguyen  admin  204 May  2 12:06 Library
-rw-r--r--   1 kureikain   admin  789 May  4 14:02 README.md
drwxrwxr-x   3 vinhnguyen  admin  102 May  4 14:02 bin
lrwxr-xr-x   1 root        wheel   27 May  3 10:04 mysql -> mysql-5.5.23-osx10.6-x86_64
drwxr-xr-x  16 root        wheel  544 Mar 30 00:33 mysql-5.5.23-osx10.6-x86_64
drwxrwxr-x   3 vinhnguyen  admin  102 May  2 12:06 share

You may get following error:

Error: Permission denied - /usr/local/include

So, I can say permission got messing up after I manually change account name from vinhnguyen to kureikain. So we need to manually correct permission again.


sudo chgrp wheel /usr/local/

sudo chown -R $USER /usr/local/

After you do that, everything should work fine.

 


loho:~ kureikain$ brew install wget
==> Downloading http://ftpmirror.gnu.org/wget/wget-1.13.4.tar.bz2
Already downloaded: /Library/Caches/Homebrew/wget-1.13.4.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/wget/1.13.4 --sysconf
==> make install
/usr/local/Cellar/wget/1.13.4: 7 files, 552K, built in 34 seconds

 


22
Apr 12

Copy to clipboard from command line on Linux and MacOSX

Sometimes it’s really tough when dealing with clipboard to between terminal and a GUI app. For example, you may need to get the content of id_rsa.pub and paste into browser. In the beginning, I simply fire up a text editor, copy content then paste into browser. Or sometime I highlight text in terminal and use mouse’s middle button to paste text into browser. But it actually has a simpler way to achieve this purpose.

Let use utility pbcopy


pbcopy < /path/to/file/need/to/copy/its/content

After that your clipboard will be fill in with file’s content.

 

 


22
Apr 12

MacOSX: map home, end, page up/down keys

I have got a mac mini some months ago. I used it with a PC Keyboard and looks like I’m getting sth worng with home/end, page up/down keys in terminal. I found out that MAC KEYBOARD has special keys such as F15,16, F17 which is used to go to home or end. Since I don’t have those keys on my keyboard so I will need to remap it. Here is what I have done to get my home/end keys work:

  • Go to Terminal > Preference > Settings > Keyboards
  • Find the home/end key. By default, it shows action columns as: “scroll to home/end of buffer”. You need to edit and change that action to send “send string to shell”
  • Do the same for other keys. You will need to put a string which will be send to shell and shell take care the rest for you. Here is the list of strings:
    Home \033[1~
    End \033[4~
    Page Up \033[5~
    Page Down \033[6~

Hope this will help s.o who is starting to use Mac like me ;) .

 


26
Feb 12

ZooTool and Pinterest

When I heard about Pinterest, I did’t put much attention on it. Until I started to use it. I’m a big fan of ZooTool and I love it already buddy.

I use ZooTool and Pinterest quite much to make sure I understand the different between them.

For me, It was so clear that Pinterest is not as good as Zootool on technical aspect. I mean the tools around it, its features. How you reorder/rearrange data on Pinterest, moving Pin from this board to another board. Or compare the quantity of extensions, bookmartlet of ZooTool. ZooTool is absolutely a winner by this way.

But what makes Pinterest so great as it’s now? It’s about interaction imo. ZooTool looks a little silence.
Also, it’s how to show the data to end-user. Data and/or data structure may the same, but the way they are shown to end-user is totaly different. Somehow I feel my data is organized better than Pinterest compare to Zootool.

(Continue)


16
Jul 11

My development tools

Nowadays, we are no longer rely on local computer or work alone! Everything must be able to share, or in other words, be accessible universally! For example, client wants to know, or keep tracking of working progress! Or other friends want to give you a hand in project,..
In this post, I put together some useful tools I use daily

  • Code Version Control: I use github for open source project! For private project, I use bitbucket! BitBucket is really great, only drawback is its Mercurial using! Recently I found unfuddle.com. Guess what..Iit supports GIT too :mrgreen: . But the best one I love is beanstalkapp.com! Because of using free package so I’m allowed only one project! Beanstalk can auto deploy your app to s/ftp server. Easy to integrate with other services such as: Basecamp, campfire, lighthouse, fogbuzz,…!
  • Project Management: Freedcamp.com, BitBucket, Acunote! I create Project in FreedCamp (unlimited), invite client, use discussion board to chat/discuss with client about requirement instead of using traditional email ;) ! And trust me, this works great and save lots of time for you! After gather requirement, I then create task on FreedCamp and track time! For BitBucket, I create Mile Stone, create ticket as bug, enhancement, proposal,…!
  • Bug Tracking: FreedCamp, BitBucket, Acunote
  • File Sharing: I used dropbox! Besides I used Arch Linux so I also use zimagez to store/share screenshot! I just press Printscreen button! And the rest is magic!
  • Email: Of course google app ;) ! Besides I used SSMTP on local computer to route mail sending to google!
  • Support Tool: I haven’t use any support/helpdesk software but I’m in love with tenderapp, zendesk, Assistly, Uservoice! Acutally, I’m building my own support platform with Kohana!
  • Testing Tools: I used notableapp, usabilla, verifyapp, ! Imagine that you give it an URL, it captures web page, client see it then note feedback in it itself! How useful…
  • DNS: My VPS has very low RAM 256MB… At this time, I must run lots of service in it! I know I should get a more powerful VPS but my money is really thin :mrgreen: ! So, I use dnsmadeeasy to manage myDNS

3
Jul 11

Netbeans would not work anymore after the first starting

Today, I installed Netbeans 7.0! It looked great ;) ! But after the first trying, it doesn’t start again! Very weird! At the first time I opened, it was working fine! But as long as I closed it, started it again :( , It was just silent…

If I remove folder like: ~/.netbeans, ~/.nbi, then I am able to start Netbeans again! But the same, when It closed, It did’t work anymore :( !

I tried to take a look at ~/.netbeans/7.0/var/log/messages.log and tried to put some of debug option like:

[lambasino@lambasino bin]$ ./netbeans -h
Usage: ./../platform/lib/nbexec {options} arguments

General options:
  --help                show this help
  --jdkhome <path>      path to Java(TM) 2 SDK, Standard Edition
  -J<jvm_option>        pass <jvm_option> to JVM

  --cp:p <classpath>    prepend <classpath> to classpath
  --cp:a <classpath>    append <classpath> to classpath
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libsplashscreen.so: libgif.so.4: cannot open shared object file: No such file or directory
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1667)
	at java.lang.Runtime.loadLibrary0(Runtime.java:840)
	at java.lang.System.loadLibrary(System.java:1047)
	at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
	at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.SplashScreen.getSplashScreen(SplashScreen.java:111)
	at org.netbeans.core.startup.Splash.<init>(Splash.java:140)
	at org.netbeans.core.startup.Splash.getInstance(Splash.java:103)
	at org.netbeans.core.startup.Main.setStatusText(Main.java:86)
	at org.netbeans.core.startup.NbEvents.setStatusText(NbEvents.java:421)
	at org.netbeans.core.startup.NbEvents.logged(NbEvents.java:196)
	at org.netbeans.Events.log(Events.java:166)
	at org.netbeans.core.startup.ModuleList.readInitial(ModuleList.java:165)
	at org.netbeans.core.startup.ModuleSystem.readList(ModuleSystem.java:280)
	at org.netbeans.core.startup.CLICoreBridge.usage(CLICoreBridge.java:108)
	at org.netbeans.CLIHandler.showHelp(CLIHandler.java:163)
	at org.netbeans.CLIHandler.checkHelp(CLIHandler.java:217)
	at org.netbeans.CLIHandler.initialize(CLIHandler.java:568)
	at org.netbeans.CLIHandler.initialize(CLIHandler.java:384)
	at org.netbeans.MainImpl.execute(MainImpl.java:187)
	at org.netbeans.MainImpl.main(MainImpl.java:83)
	at org.netbeans.Main.main(Main.java:78)

So, the error seems cause by libsplashscreen.so of OpenJDK6! Don’t blame because I don’t have much Java debug skill so I don’t know what it means! But I tried to disable splashscreen with –nosplash, and it works like a charm!

[lambasino@lambasino bin]$ ./netbeans --nosplash

This will make Netbeans works again after the first starting ;) !

PS: I do think that reinstall OpenJDK will solve this error too but I did’t got a chance to test if it works!

Update 1:
I tried to dive deeply into the log& debug! I realized that libgif.so is missing! So I tried to install libungif (contain libgif.so)! Netbeans works fine again after this without –nosplash ;) !

In conclustion, this error is caused by the missing libgif.so! (Doesnt why at the first starting, it worked)!


10
May 11

WPixlr – WordPress Live Picture Editor

Today, I’m happy to release a new plugin which alow you edit picture right on browser!
Actually, It utilizes the power of online picture editor http://pixlr.com

This plugin bring you ability to live edit picture in media libary,picture attachement -anything
in media library, right on the browser utilizes the power of Pixlr Editor!
You can edit, add text, crop, sharpent, blend color…and many picture manipulation right on the borwser!
This way, you and users can easily made custom picture when uploading from computer without picture editting software (I believe not many end-users have it)!

Download it here, then extract and upload the WPixlr plugin to your blog, Activate it, then go to Media Library! Hover mouse on item then press “Edit with Pixlr” to start to use! That’s all! It’s simple!
If you have any issue, leave comment here :P ! Thank you!

Below lists some screenshot from this plugin


12
Mar 11

Fix IE problem: getting HTML5 content via Ajax

We know IE6,7,8 will not work with HTML5! So we must work around it with html5shiv or html5shim, or something similar
But an other problem is if we’re getting HTML5 content via XMLHTTPREQUEST, IE will not recognize it…and parses it wrong, leads to missing style, or missing element,..

My solution is we will convert code like <nav>….</nav>, <header>….</header>,..into <span tag=”nav”></span>, <span tag=”header”></span>..Then we insert into DOM, this way, the elements will be parsed correctly! After that, we do a search element which has “tag” atribute and replace it with a new node (in html5 of couse)! We also need to get all attributes of old node and assign to new node

Here is the code with jQuery! We will make an array of html5 element and an array of attributes! Depend of what u wan, u can want to add more elements or attributes

function fixHTML5(content) {
    var html5element = ['nav','section', 'header','article','footer'];
    var attributes = ['id', 'class'];

    $.each(html5element, function (index, tag) {
        var re = new RegExp('<(\/?)'+tag+'([^>]*)>', 'g');
        content = content.replace(re, '<$1span tag="'+tag+'"$2>');
    })

    $('#context-panel').html(content);

    var fixNode = function (index, tag) {
        tag = $(tag);
        var node = $('<' +tag.attr('tag') + '/>')
            $.each(attributes, function (indexAttb, attb) {
                node.attr(attb, tag.attr(attb));
            })
        node.html(tag.html());
        tag.replaceWith(node);
    }

    $('span[tag]', '#context-panel').each(function (indexSpan, tag) {
        fixNode(indexSpan, tag)
    });
    return true;
}