Archive for the ‘Programming’ Category

How to develop augmented reality apps with Vuforia for Windows 10

http://flip.it/uUlg9H

Dripcap – Caffeinated Packet Analyser and…

Probably Wireshark is too much, it can be good to try this elegant packet analyser, Dripcap. It’s made of a web app framework called Electron. It can be good to know that. Nowadays I don’t hear much about Ember and so on. Lots of Web frameworks are on people’s mouth and gone so quickly so…

 

libiconv from OS X and Mac Port, and change of Xcode behavior

I have an old project for converting wrongly encoded Korean to properly encode to properly encoded one in mp3 files.

However due to file system corruption while in upgrading to OS X 10.11.6,  I had to rebuild the project again. I found out that I had another project for the same purpose to use different ID3 library. I didn’t remember which project was correct one.

I finally identified the correct one, but had some issues. It was built previously without a problem, but it failed this time. It could be due to changes in Xcode. Yes. there is such change. I will talk about that after taking about difference of libiconv from OS X and Mac Port.

When tried to build, it complaint _iconv, _iconv_open, _iconv_close were missing.
I recalled that there was difference between libiconv from OS X and Mac Port, and there was a comment I wrote for that, but didn’t remember its detailed reasoning for that.

stackoverflow.com/questions/27392085/cant-link-to-iconv-on-os-x

So, I googled and found the stack overflow question above, and it made me recall what problem it had completely.

So,  this time I would like to record it here.

This is the result with libiconv from Mac Port.

JongAms-Mac-mini:lib jongampark$ nm -m  libiconv.2.dylib | grep iconv

0000000000002db1 (__TEXT,__text) external _libiconv
0000000000002dd3 (__TEXT,__text) external _libiconv_close
000000000000158c (__TEXT,__text) external _libiconv_open

This is the result with libiconv from OS X.

JongAms-Mac-mini:lib jongampark$ nm -m /usr/lib/libiconv.dylib | grep iconv

000000000000301c (__TEXT,__text) external _iconv
000000000000336d (__TEXT,__text) external _iconv_canonicalize
000000000000303e (__TEXT,__text) external _iconv_close
0000000000001c41 (__TEXT,__text) external _iconv_open

So, the difference is that the ones from Mac Port have _lib is prefixed while the ones from OS X don’t.

Also, the included iconv.h file should match with the library file.


Finally I would like to talk about the changes of Xcode behavior.

With a version of 7.x.x, Apple changed that default libraries and header files could be searched without specifying them. Especially, if a library, for example, /usr/lib/libiconv.dylib is linked using the build phase, Xcode didn’t require the /usr/lib is added to the library search path. It was new behavior at that time.

However, they changed it again from some version of Xcode later than the version mentioned above. So, the library path should be set to include /usr/lib.
Without that, even though the /usr/lib/libiconv.dylib is linked by build phase setting (Link Binary with libraries ), Xcode couldn’t find that it’s in /usr/lib.

Apple doesn’t document this kind of changes, and it gives headache.
I wonder why Apple keeps changing from one behavior to the other behavior from time to time. If they keep changing to a newer behavior, it could be understandable, although I don’t like it. However, they are kind of going forward and backward.

This is small difference, but can affect big way.
Apple should document this kind thing and handle this seriously.

How to use Apple’s Unicode Hex Input IME

It’s explained here, but ‘how to use’ is buried in the long text without indentation etc.

So, here.

  1. To type U+03B1, press the “Option” key.
  2. press 0, 3, B, 1 while still pressing the “Option” key.

 

When both ‘true’ and ‘false’ are right

I ran into very interesting logic issue. Probably if someone asks me what case it was, then I would not be able to recall this, because it’s subtle ( but simple ).

bool vaFacebookAPI::HandleResponse(zuint32 what, zRecord *record, zRecord *current, zRecord *previous)
{
    bool isHandled = true;

    if (record == nullptr || current == nullptr) {

        // You can think of this as 'handled' or 'not handled' depending on
        // how you think. But architecturally it should be treated as 'not handled'
        return false; // 👈🏼 This case 
    }

    ...
}

1. You can think that it can return ‘true’, because such case is considered and you decided not to do anything. So, It’s handled as such. So, it’s right to be ‘true’.

2. You can think it it can return ‘false’, because for that case nothing is processed and just returns. So, you can regard it as ‘not handled’. So, ‘false’ is correct.

Interesting, isn’t it?
One logic, depending on how you think it can be thought as ‘true’ and ‘false’

So, true is true, and false is also true. 😉

deprecation of C++ style for loop and its replacements are…

New Features in Swift 2.2

Swift… 이거 참..
Telestream에서 일을 한 이래, 제대로 Objective-C/Cocoa에서 새로 나오는 것을 시도하거나, 심지어 Swift를 공부할 짬이 없었다. C#/.NET이나 C++도 마찬가지…
이전 회사들에선 퇴근하고서도 당연히 했고, 회사 내에서도 할 일 다하고, 추가로 더 알아보곤 했는데, 도대체 이 회사에선…
Cocoa에 대해서 알고 있던 것도 까먹고. 그래서들 미국 애들이 이런 회사에 지원을 안하나보다.

아무튼 투덜대는 것은 이만하고..
난  Swift가 도대체 마음에 들지 않는다.
Swift가 후져서가 아니라, 이건 순전히 마케팅에 의한 것이란 생각이 들기 때문이다.
GNU의 Objective-C 컴파일러를 들춰본 사람들은 얼마나 간략하게 Objective-C가 만들어져 있는지 안다. C++쪽은 별 이상한 짓을 해서라도 기능을 추가하는데, 굳이 몇가지 Objective-C의 단점을 들춰서 그걸 Swift를 합리화하는 건 뭐하지 않나? 문제가 있으면 고치면 되지 않나?

더군다나 Swift는 헷갈리는 면이 많다. 새로 언어를 배우는 어린 학생들이야 모르겠지만, 내겐 이 Swift는 어떤 면에선 Pascal, 어디선 C, 어디선 Perl 같은 느낌이 든다. Python을 하는 사람들은 Python 같은 부분도 있다고 한다.
일단 모드가 Pascal 모드로 바뀌면 Pascal 다워야 하고, C로 바뀌면 C 다워야 한다. 그래야 기억하기도 좋고 그렇지. 이건 순전히 잡탕같은 느낌이어서, 간만에 Swift 문서를 읽어서 익혀 두어도 나중에 기억이 잘 안난다. 왜? 파스칼 같으면 쭉 파스칼 같아야 하는데, 어느 순간 Perl 같다거나 그런식이기 때문이다.

그리고 2.2에서 새로 나온 문법을 보자.
다음의 코드를 보자

for var i = 0; i < 10; i++ {
    print(i)
}

이걸 이제 없애고 다음과 같이 바꾼다 한다.

for i in 0 .. < 10 {
    print(i)
}

이까진 좋다. Fast Enumeration 스타일이니까.

근데, 다음을 보자.

for i in (1...10).reverse() {
    print(i)
}

for i in 0.stride(to: 10, by: 2) {
    print(i)
}

저거 그냥 (10…1)로 못 만드나? 물론 reverse()도 지원하면서?
뭐 첫번재 예는 그렇다치자.
두번재 예..

저거.. 영어가 모국어인 사람은 0.stride(to..)가 와 닿을지 몰라도, 외국인들에겐 그렇지 않다. stride의 뜻이 그다지 강하게 다가오지 않기 때문이다.
단어의 뜻을 아는 것과, 그것이 얼마나 강하게 다가오느냐는 다른 문제이다.
stride?
Apple의 사전 앱에서 뜻을 보자.
1. 성큼 성큼 걷기. 활보
2. 한걸음, 한달음.

아.. 안다가온다.
이런게 낫지 않나?

for i in 0.increment(to: 10, by: 2) {
    print(i)
}

for i in 0.increment(to: 10, by: -2) {
    print(i)
}

두번째 것은 다음과 같은 동일 표현을 가질 수 있겠다.

for i in 10.decrement(to: 0, by: 2) {
    print(i)
}

Swift는 컴퓨터 언어에서의 cultural difference와 사람이 쓰는 언어에서의 cultural difference를 고려하지 않고 디자인되는 느낌이다.
이건 문제다. 그리고 내가 Swift를 좋아하지 않는 문제 중의 하나이다.

Dialogue’s Guiding Principles, or a Healthy Hatred of OOP two chain links

Dialogue’s Guiding Principles, or a Healthy Hatred of OOP two chain links

Well, it will be interesting to read the post.
However, I found out that problems among US programmers in terms of C++ is that they follow C++ techniques or new syntax etc, which are just supplemental rather than keeping philosophy of OOP and meta-programming.
Syntax-sugar is good. But problems of C++ is that ( don’t misunderstand that. As you can see I’m a long-time C++ programmer and I liked its initial paradigm a lot. ) a lot of features have been added to C++ for the sake of convenience ( with difficulty of using it ) or more power. People, who just judge others’ knowledge on C++ just by asking terminology and features, thus missing core values, love to use any new features.
Knowing such things are good and beneficial, but not always.
I’ve worked on pSosystem at Samsung and other systems where the greatest and the latest C++ features were omitted intentionally for the purpose of the system or unintentionally (just old C++ compiler). If people just stick to the greatest and latest feature and when exposed to such system, they are embarrassed often.
So, I’m always in the attitude of choosing common ground, which maximizes compatibility of source code and your knowledge compatibility.

Anyway, folks. Knowing more terminology and new features will make look more knowledgeable person especially here in the US due to its culture, but actually it’s not. What is more important is to know why you need to use this or that, philosophy behind of a language you choose, etc.

Here I see Objective-C code which is not written by people who understand Objective-C philosophy. They argue that they know, but if you see such code, ou will be able to see that they don’t understand the philosophy.
They oppose Objective-C or any other language without understanding their philosophy. Criticism can be good only and only if people criticize after understanding philosophy or background history on why this language/system is designed as such.

So far, my experience here in the US is that when interviewers were too picky and just judges people by asking if the interviewee knows(memorizes) one thing, I usually found out that their source code were dirty and messy in every angle.
If an interviewee is not a liar or a salesperson who wants to sell himself rather than an engineer, they tend to memorize terminology etc. But if they are engineers, they know but at the moment of being asked, they may not answer the interviewers question. It’s not because they don’t know about the answer, but they can guess something else.

For example, I’ve been asked like “implement this thing using STL.”
Well, I use Win32 collection APIs, Cocoa/Core Foundation collection APIs and also STL. Also I use boost. They are similar. If you happen to use Win32 collection API for the week when you are interviewed, you can temporarily forget STL. But if you look up document, you can quickly write in STL. Then doesn’t he know the STL?

Here in the US, although they say they are Objective-C programmer, they write in C++ and STL mostly. So, they can remember STL syntax.

I’m different. When I implement Win32 code, I stick to Win32 stuffs mostly. When I implement Cocoa/Core foundation code, I stick to them.
If I need to implement something common code, which I may need to use on Window / Mac / iOS/ Unix, I write with pure C/C++/STL. Then, I can temporarily forget one syntax. But does it mean that I don’t know about it?

I’m versatile person. However, the way US people interview others are not like that and they stick to one thing and say they are “the other” programmer.

Another example is … I’m asked how to implement XOR in C++ while being asked about bit-wise operations. So, I told him it’s ^ operator.
He said “No.”
Actually in the conversation, he jumped from logical operation and bit-wise operation. So, I wonder why he said “No.”
Well, what he wanted “DeMorgan’s law” to express logical XOR.
Damn.. then he must be clear on that.
In Korea, DeMorgan’s law is taught in middle school. Everybody knows DeMorgan’s law. Well, actually what is taught here in the US are mostly taught in middle school or high school like calculus, probability etc. Well. some are taught in here too in high school. But compared to the level of things taught in Korea, well here.. I understand why Obama mentioned education in Korea, although I oppose to his intention.
Anyway, then he treated me like a person who doesn’t know C++.

What the..

LLVM based just-in-time compiler for C++

http://www.jyt.io/

Raw Key Code for Function Keys

I figure out key codes for function keys from F1 to F12 on Mac.

  • F1 : 122
  • F2 : 120
  • F3 : 99
  • F4: 118
  • F5: 96
  • F6: 97
  • F7: 98
  • F8: 100
  • F9: 101
  • F10: 109
  • F11: 103
  • F12: 111

They are not related to ASCII table at all.
Code marked as ‘solution’ or ‘answer’ here doesn’t care of them. They are all converted to a printable characters, ^P. So, a table created with the method in the StackOverflow can’t differentiate each of the function keys. So, if you want to differentiate them, customize value saved there using the table above.

It turned out that the database solution, 4D, also had such values for the function keys.
So, it says that the values above is not only specific to my keyboard, Logitech  K760.

(It’s surprising that 4D is still alive.)

parent selector in Chrome as of today

parent selector in CSS is said to be included in new CSS draft as has() class. A stack overflow comment mentions about it.

Also, on this blog, the author says a reverse selector or parent selector is available with IE and WebKit-based browsers. Chrome was a WebKit-based until Google exited from the WebKit herd. However, in many document, Chrome is mentioned as WebKit-based and there are still lots of WebKit-ness there.
However, as of today, on my Chrome browser on Windows, this parent selector, <, is not available.The version of Chrome browser on my machine is Version 47.0.2526.106 m.