OAuth 2 using curl

Trying out OAuth2 via CURL from h[y]tech blog.

It’s good to know that. As a long time user and developer for Unix, I have know cURL. It’s high-level program/library for various protocols and it’s sort of known that it can do everything.
However, buying tech book…? I don’t remember when is my last time such books. Nowadays I rely on Web. (although pedagogy style or explanation styles are not good especially blogs and web site created here in USA. usually Japanese ( of course ) or Korean ( if any ) writing style/books/posts on web are better for more concise and better explanation.

But.. anyway… Today I found very useful blog post on “How to do OAuth 2 with cURL”
Step by step and easy to understand one. It’s good because I don’t need to read MAN pages or documents on Web thoroughly. At least it can be good starting point to get some idea etc. Only when more information is needed, those more official document can be looked up.

More background information is located here : OAuth2: The Resource Owner Password Flow
Official document on OAuth is here : The OAuth 2.0 Authorization Framework

draft-ietf-oauth-v2-31


Of course, these SNS requires OAuth. (1.1 or 2.0+)

 

It’s better than Apple’s approach to block using old Xcode on newer OS X, at least

At home, I have Visual Studio 2010 Premium(?) and 2013 Express.
If I bring project file created and built using VS 2012 to home and tries to build with VS 2010 ( of course, I change settings in a project file to use 2010 toolset. ), it still fails and some error messages are not quite clear.
For example, __report_rangecheckfailure error is specific to VS 2012 and later project files.

http://social.msdn.microsoft.com/Forums/vstudio/en-US/7abc7f63-c3a6-4a55-babc-6914870d4959/unresolved-external-symbol-reportrangecheckfailure?forum=vcgeneral

It’s odd. But you can set it even for VS 2010.

Well, there are people who hate VS. But I like VS more overall ( especially Xcode 4 and later.. )
Apple prevents from using older Xcode on newer OS X.

commenting or documenting…

When I got interviewed, people tended to ask me, “Can you use Doxygen?”, “Can you use ‘some other document generator’?”.
Usually, when I am asked like that, it turned out that their documentation or whatever stuff they asked was not good in the company.

Commenting, or documenting in source files should be part of architecture, design or planning.
It’s not something you are to write after you implement something. It should be written before you start implementing something and while implementing.

What I mean is this. Commenting/Documenting is for maintainability or help for easier understanding of code.
If people make fun of you when you say “How bad it is! There is no comment!!”, then it’s Ok to treat them as non-professional people.
They will say “Real S/W engineers should be able to figure out without comment.”

Well.. they are only half-right. Sure. If you are a person who can think. Sure.. you can figure it out. However, just to use something and maintain, if you need to spend too much time, it’s not good. Commenting is to help that case. If it gives you an idea what the code part is for, you can get a pre-image to the code block. Then you can figure out things even quicker. Also, you can understand the original authors’ intention, suffering or odd situation they were in.

However, another very important reason for commenting is this.
It helps you to plan things better.
For example, even before writing, you can use your IDE/source code editor as a scratch paper like this.

void MyClass::doSomethingGreat( void )
{
// 1. Retrieve data from twitter

// 2. Check if there is user object in the response data

// 3. ...
}

Then, those commenting can plays very important role to aid you to organize your idea and split big task into small chunks.
You can get more rigid idea on what you are going to do. Sometimes by writing as such, something ambiguous can be clearer.
Also, after you write code, it can help you to locate interested portion of code quickly.
Then, it becomes great comment and documentation for itself. You don’t waste your time in writing comment/document. Your design time becomes your documenting time naturally.

Another very important point i would like to address is… Please use and pick terms others can use. Don’t use your own abbreviation and explain things really.

Here is a good example from twitcurl project.

/*++
* @method: twitCurl::mentionsGet
*
* @description: method to get mentions
*
* @input: sinceId - String specifying since id parameter

Especially take a lookat @input: sinceId line.
What is ‘sinceId’? that will be the question when you first confront the line.
Does “String specifying since id parameter”  really explain what sinceId is?
How about this?

/*++
* @method: twitCurl::timelineHomeGet
*
* @description: method to get home timeline
*
* @input: sinceId - the post ID for the last retrieved post.
*                                  Post with IDs after sinceID will to be retrieed

Isn’t that better? Anyway you should refer Twitter’s API documentation, but even without it, you can figure out what the sinceId means in that context.

I don’t count comment like the one in the mentionGet method.
You should not say you write comment if you write as shown in the mentionGet method.

C++ man pages from cplusplus.com

Although I don’t like their articulation /pedagogy style…

I found an open source project here at GitHub. It is said to generate MAN page from cplusplus.com contents.

https://github.com/Aitjcize/cppman

If you use Mac, probably this program uses the cppman internally..
https://itunes.apple.com/us/app/dash-docs-snippets/id458034879?mt=12

Additionally, there are some C++ reference MAN pages…

http://stackoverflow.com/questions/2887498/c-man-pages-in-ubuntu
http://stackoverflow.com/questions/5293737/where-are-the-man-pages-for-c

Well.. I don’t like general articulation style of MAN pages.
If Koreans write those, they should be like :

Class/Function name

What it is for

Parameter 1: 어쩌고 저쩌고 (간략한 것, 첫 문장. 자세한 거 한줄 띄고 그 후에)
Parameter 2 : 어쩌고 저쩌고

Return : 어쩌고 저쩌고 (간략한 것, 첫 문장. 자세한 거 한줄 띄고 그 후에)

Xcode에서 C++11 지원은 참 좋은데.. 정작 Xcode 에디터는..

신기하지..

Xcode에서 C++11 지원은 참 좋은데, 정작 Xcode 에디터는 Visual Studio의 그것만큼 잘 지원하지 못한다. 이를테면 Xcode에서 C++ 클래스 파일 만들기를 봐도, 그냥 텅 비게 해 놓고…
선언한 member function에 대한 구현을 하려하면 일일히 수동으로 써 넣어야 한다.

한편으론 좋다. 왜냐 하면 Visual Studio에 익숙해지면 인터뷰 등에서 불리해지니까.. 자동에 익숙해지다보면, 논리에 집중하게 되는 면은 좋은데, 정확한 신택스가 잘 생각이 안나 경력이 많음에도 불구하고 C++을 모르는 사람으로 치부된다는..

아무튼.. 디지털 시대, 디지털 치매(Digital Dementia)에 걸리지 않게 노력도 해야겠지만.. 아.. 귀찮아.
Xcode에서 자동으로 기본 생성자/파괴자 등 만들어 주는 템플릿.. New C++ class 하면..
요새도 되나 몰라..

http://www.jalone.net/articles/coding/xcode-template-for-new-cpp-file-class.html

True face of Swift?

요새 바쁜 와중에도 짬을 내서 스위프트를 공부하려는데, 영 진도가 잘 안나간다. 이제 나이가 슬슬 얼굴을 들이미는건가? 대학생 때만해도 이런 정도 양은, 한 2~3시간에 쓱싹했는데..
근데, 그다지 재미난 언어 같지도 않다. 더군다나 시간이 지날 수록 이런 글들이 나오니.. Java가 C/C++에 필적하다란 것과 비슷한 마케팅 같다. 물론 최적의 상태에선 좋은 성능이 나오는 것은 사실이지만, 항상 그럴 수 없다라는게 문제다.

Performance of Swift

People started to raise questions on Apple’s Swift language.

Performance of Swift vs. Objective-C

Some nice sorting tester written in Swift.

Apple’s Swift is not swift after all.

Among those, the last article caught my eyes. ( the 1st one is also good starting point. )
As far as I know, the inventor of the Swift actually is the core person in LLVM/Clang.
I’ve heard that he wrote Swift while making LLVM/Clang. So, if it is right, Swift language would be architected to get most performance out of clang/LLVM.

However, it was very questionable to Apple’s claim that Swift is x-times faster than Objective-C at WWDC.
Probably there can be such case. Sure! Java is also faster than C/C++ in certain case. ( Especially when they don’t count the time to load a program at first or whenever page-in happens. ) However, Swift is native and Obj-C is native. Obj-C has its root in C.
So, there is no reason that Objective-C is refined and modernized inside to achieve the performance of the Swift if they want.
Objective-C implementation has legacy model or old idea and tied with old GCC architecture. When Apple adopted clang/LLVM, the front-end of the compiler (GCC at that time) was redesigned until backend was ready. So, Now, on the both frontend and backend, Obj-C is written for clang/LLVM. I don’t mean that they refined all every part of Obj-C for clang/LLVM. It’s not realistic to wish that they did it perfectly for all aspect of the language. I expect Objective-C can be refined more. Yeah.. they got rid of the garbage collector, they changed here and there for properties. ( There are more versions in terms of properties than it is documented. Believe me. i tested 32bit, 64bit, Mac OS X, iOS, PowerPC, Intel, and ARM targets as well as modern and legacy Objetive-C. )

So, one of the thing I was really frustrated was that they touted Swift as better performing language than Objective-C. It gave an impression like “Objective-C is the language of yesterday. Now folks, jump on a new language, Swift!”
No.. it depends on how they think.
You know.. things human makes are always like that. Bill Gates said, PC era was ended when he put MS tablet machine on his hands. At that time, Steve Jobs said NO. And he proved that how cool PCs still can be by pushing out new MacBooks (Pros) and new Macs.
But suddenly, Apple announced iOS and kind of declared, PC era is ended. Do you really think so?
Trend-wise, yes. But it’s manipulated reality. It’s because Apple put more energy on iOS not on Mac.

It looks to me that people get tired of iPad, for example, nowadays. Why? iPad growth is slowed down, while PC form factor gained some popularity for recent months. Google’s Chromebooks are said to be sold very well. Actually it was the best selling ‘notebook’ computers in the US in the last December. Why? Yeah.. one of the reason is that it’s cheap. ( Well.. without many features.. the absolute price is cheap. But considering its missing capabilities compared to normal notebooks, it’s kind of expensive. )
Another reason is that people look to be tired with one-app-at-once style OS.
Also, if you decide to write a lot, then you need a keyboard for your iPad. Then.. isn’t it better to buy a notebook computer?

Look at Apple fanatics. They just buy everything. iPhone, iPad, MacBook/Pro, iMac or any other desktop Mac.
Why? I know that sometimes using iPad is more convenient than using MacBook Air or MacBook Pro 13″, especially in crammed place like on a bus or in an airplane. Then folding out LCD screen and sparing keyboard area is kind of pain.. and it’s hard to type or do anything. However, do we really need to spend our money for that very occasional moment?
I would rather have one smartphone and one notebook. That’s it. When you need mobility and are shopping or waiting for bus, etc, smartphones are good enough and more handy. iPad? Any tablet? They can easily slip out from your hand.
Holding a tablet while stepping on a bus.. it’s dangerous. You can drop your expensive tablet.
On a bus.. if there is really important information you need to know, smartphones are good enough.
If you are at some place where you can do more serious things, notebooks are better than tablets.
Between those transition times from mobile phones to notebooks? Just daydream! Just close your eyes and give your eyes chance to take rest! Look at what others are doing. Do eye-greeting to other people! That’s better.
Actually recent research revealed that daydreaming is good for recovering your memory, etc.

So, tablets killed/are killing PCs? Maybe.. or can eventually. But.. it all depends on what plan the manufacturers of PCs/tablets think about. Cool features of iTunes U program on your iPad? Wouldn’t it be better if Apple make one for Mac and PC?
Yeah.. They introduced discussion feature in the latest version. I believe it would be more convenient to use if the iTunes U is available on PC/Mac! Or any killer mobile apps? Evernote is more comfortable when used on PCs/Macs than Android/iOS mobile devices.
Should you divide when you produce and when you consume information? And should you spend your money for more “information consuming-oriented” device? They are not cheap.

That is the point I like about MS surface. People around me don’t look to like Surface, but I like it. Windows 8.1 looks better and more refined OS than 7 and 8.0. Especially on ‘Desktop’ mode of 8.0 and 8.1, 8.0 looked like half-baked environment. 8.1 looks completed one. Resolution-semi independence or high DPI mode is better with 8.1.
Just like the failure of old Mac didn’t mean that the technology was inferior ( the cooperative multitasking was inferior, but before that time, Mac was more advanced than PC. ), the failure of Windows 8.x nowadays doesn’t necessarily mean that its technology is bad.
Social atmosphere, trend, etc controls whether a platform gains popularity or not as well as technology itself.

(Mac fanatics are just like Windows fanatics.)

Anyway.. for that, I like MS’s approach more than Apple’s approach.
Ah.. let’s go back to the original topic.
So.. everything depends on what they want to sell and market. It’s not that PC era is ended. It means that it became hard for PC manufacturers persuade people to open their pocket, because nowadays even old PCs are faster for most of jobs. Should we buy a new PC? Game worked on that before. Still it does. But.. not for most of people.
Then they have to make people to open their purse. So, it’s the reason they declare PC era ended!.

Language is the same.. is Objective-C old language? Yes. But it doesn’t mean that it can’t be modernized or rewritten for clang/LLVM to juice out every small sacks of orange. I like the clean syntax of Objective-C as much as C++. C++ is known to be bloated. I agree with that view. But still.. C++ language designers can make it slim if they want.

I don’t understand if there is any strategic decision on why they pushed so hard the Swift at WWDC.
To make people apart from other platform and stick to iOS, just like MS tried and did with their Windows?

Usually such effort eventually turned out to fail.

 

Follow

Get every new post delivered to your Inbox.

Join 50 other followers

%d bloggers like this: