Wednesday, December 12, 2012

Stackoverflow User Details in python





Output:-


badge_counts_bronze :: 115
email_hash :: 51d623f33f8b83095db84ff35e15dbe8
badge_counts_silver :: 104
badge_counts_gold :: 34
user_mentioned_url :: /users/1/mentioned
user_type :: moderator
answer_count :: 138
creation_date :: 1217514151
user_tags_url :: /users/1/tags
user_timeline_url :: /users/1/timeline
about_me :: Stack Overflow Valued Associate #00001


Wondering how our software development process works? Take a look!


Find me on twitter, or read my blog. Don't say I didn't warn you because I totally did.


However, I no longer work at Stack Exchange, Inc. I'll miss you all. Well, some of you, anyway. :)


up_vote_count :: 2729
user_id :: 1
question_count :: 15
reputation :: 23510
view_count :: 92244
user_favorites_url :: /users/1/favorites
display_name :: Jeff Atwood
age :: 41
down_vote_count :: 543
last_access_date :: 1355227926
association_id :: febfb878-3f6f-4215-9323-46d15d62ac7d
user_questions_url :: /users/1/questions
location :: El Cerrito, CA
accept_rate :: 100
user_reputation_url :: /users/1/reputation
user_badges_url :: /users/1/badges
user_answers_url :: /users/1/answers
website_url :: http://www.codinghorror.com/blog/
user_comments_url :: /users/1/comments

Tuesday, August 7, 2012

Fetch web page in libcurl




Saturday, July 14, 2012

Pthread in c++ class

In pthread API, the pthread_create() takes function which takes a generic pointer and returns a generic pointer. Here is a sample pthread implementation in c

Output:-
In thread....
Message : Hello
Thread exiting...
The problem with pthread_create in c++ is that it can't take member function as a thread function. Because, pthread_create expects a normal function, not a c++ member function. If we pass a member function, then the implicit this pointer won't be available inside this, hence the purpose of member function won't be fulfilled. For this reason, we need to make the thread function static and pass this pointer as object. Inside the function, everything should be accessed through the this pointer. Here is a sample code of pthread_create in C++

Output:-
In Thread...
Message : Hi Hi
Thread exiting...
Here, the problem is we need to write a static member function for every class that needs to use pthread_create(). I have made a wrapper class for this. Here is the code along with how to use it.

Output
Control in Main
In Thread...
Message : Ho Ho
Thread exiting...
 

Friday, April 27, 2012

Yahoo Finance API in Python 3.2


This is a sample code to fetch market data from yahoo finance.

Output :-
Unsorted :
Ask  =>  117.25
Bid  =>  116.25
Change  =>  -3.60
Trade Date  =>  -
52-week Low  =>  111.20
Change From 52-week Low  =>  +5.05
Percebt Change From 52-week High  =>  -48.28%
Open  =>  120.65
Change in Percent  =>  "-3.00%"
Ex-Dividend Date  =>  "14-Sep-11"
Day's Low  =>  115.55
52-week High  =>  224.75
Percent Change From 52-week Low  =>  +4.54%
Last Trade Size  =>  1
Previous Close  =>  119.85
Symbol  =>  "HINDALCO.NS"
Last Trade Time  =>  "6:29am"
Last Trade Date  =>  "4/26/2012"
Day's High  =>  121.15
Change From 52-week High  =>  -108.50
Last Trade (Price Only)  =>  116.25
Volume  =>  10257747
Stock Exchange  =>  "NSE"

Sunday, April 15, 2012

Recursive Merge Sort in C++



Output :-
Unsorted :
308  259  354  738  444  7  891  756  63  56  460  961  732  38  648
Sorted :
7  38  56  63  259  308  354  444  460  648  732  738  756  891  961

Saturday, April 14, 2012

Union and Intersection of two Linked Lists in C++



Output :-
List1 : 78  19  12  30  10
List2 : 89  19  121  30
Union List : 89  121  10  30  12  19  78
Intercestion List : 30  19

Sunday, April 1, 2012

non-type template-parameter

A non-type template-parameter shall have one of the following (optionally cv-qualified) types:
  • integral or enumeration type,
  • pointer to object or pointer to function,
  • lvalue reference to object or lvalue reference to function,
  • pointer to member,
  • std::nullptr_t.