Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
Tuesday, June 15, 2010
Monday, June 14, 2010
Phase 1: bulding a Facebook app
<!-- login in facebook with extended perms -->
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream" faces="true"></fb:login-button>
This will use FB extensions to HTML, which must be activated before with an asynchronous initialization of Facebook javascript library (noticed the appId:, and xfbml:true down below
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '117083285001944', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
This function uses the FB.UI Api call to publish on your facebook account
function streamPublish(name, description, caption, hrefTitle, hrefLink, userPrompt, thumb, urlThumb){
FB.ui(
{
method: 'stream.publish',
message: '',
attachment: {
name: name,
caption: (caption),
description: (description),
href: hrefLink,
media: [{ type: 'image', src: (thumb), href: (urlThumb)}]
},
action_links: [
{ text: hrefTitle, href: hrefLink }
],
user_prompt_message: userPrompt
},
function(response) {
});
}
</script>
Sunday, June 13, 2010
Facebook infrastructure and data

Very interesting presentation about Facebook by Aditya Agarwal, Director of Engineering
- 8 billion minutes spent every day, 5 billion of contents shared per week, 3 billion photos per month
- 80,000 applications use Facebook connect
- 500,000 million user
Saturday, June 12, 2010
Efficient dictionary
What if we allow to delete k characters?
Friday, June 11, 2010
Where is the point?
Thursday, June 10, 2010
Sort an array with just 3 different types of symbols
Wednesday, June 9, 2010
Vertices of a polygon
Tuesday, June 8, 2010
Monday, June 7, 2010
Apple going OS?
Sunday, June 6, 2010
HTML5 is damn hot
HackaTon: 1 week, 1 hour, 1 social experiment with Html5, Bing Maps, Facebook, Geonames.org
- I want to make something social. And I when I say social, I mean sharing on Facebook. Social is a so catchy and meaningless word, these days;
- I want to make something with geolocatization. I heard that HTML5 made a great progress on that side and I know that Bing Maps are pretty cool;
- KISS mode must be on;
- Everything must stay on the client, keep it small keep it fast. Code is public, since is just javascript;
- I am starting an Mashup HackAthon, send me your contribution and I will post it.
During the next days I will comment the code here. If you want to test it, this is the result after 7 hours of coding. Crisscrossy.com (you must use a browser with geolocalization support)
Saturday, June 5, 2010
Mysql vs Cassandra: or SQL vs NoSQL
A new generation of low-cost, high-performance database software is rapidly emerging to challenge SQL's dominance in distributed processing and Big Data applications. Some companies have already traded SQL's rich functionality for these new options that let them create, work with, and manage large data sets.
A big reason for this movement, dubbed NoSQL, is that different implementations of Web, enterprise, and cloud computing applications have different requirements of their databases. Not every app requires rigid data consistency, for example.
Friday, June 4, 2010
Why I like the Ipad, and why i don't like the App model
Now I tell you, I love the IPad and I predict an amazing success. First at all, the battery lasts for 9-10 hours. Second, there is a pull mode that download content offline. Third, display is amazing: you can read your newspapers, watch your movies, browse the net, email, a keyboard that is working with my big fingers. Still video is not there. And is quite expensive. Anyway, this will be a blast. Apple will release new versions with little additional features just to sell more devices.
Anyone is about Apps right now. Like anyone was about corba, 15 years ago. Like Web 2.0, 5 years ago or The cloud, just yesterday.
Can I say? I don't like the app model. I know you can make a lot of money out of it. And a lot of devs are happy because they can participate to this new golden age. The claim is: "There is an app for that", anything you need to do.
Well my question: "how can i find that app?". You need to find an app for finding things. There is an additional level of indirection to go in a cage.
And it is not easy to find that app. Should we have a search engine for that?
Thursday, June 3, 2010
Unique elements
Wednesday, June 2, 2010
Top 1000 Sites on Web
Tuesday, June 1, 2010
Array Increment Problem
Increment (A,i,j,x) : This should increment elements from A to A[j] by value x .
Report(A,j) : This should report A[j]
Trivially in an array Increment takes O(j-i) time and report takes O(1) . Now we need to store in a data structure (can be augmented) such that both operations takes O (log n) time.
(Interesting data structure for this one http://en.wikipedia.org/wiki/Segment_tree)
Google goes Ad Mobile
Sunday, May 30, 2010
find the longest increasing subsequence of a given sequence
Saturday, May 29, 2010
How to find largest palindrome
Friday, May 28, 2010
Apple beats Microsoft
The maker of Mac computers, interactive phone and tablet iPhone IPAD beats Microsoft as the most valued technology firm in the world on stock market.
Thursday, May 27, 2010
Wednesday, May 26, 2010
Business Model for Facebook
In addition, running the business is not as expensive as search. They need to store user profiles and a lot of images. Video is outsourced to youtube and realtime updates are not so expensive (what is the history they maintain?).
Anyway, running a business requires to make money. So here is my call: What business model do you suggest for facebook to make money?
Content ads never worked for search. Could it work for FB? Or what else?
Tuesday, May 25, 2010
Count numbers
of 2 or more numbers?
For eg. if the number is 5 , count=3 i.e 1+1+1+1+1, 4+1, 3+2
note 2+3 is same as 3+2
Monday, May 24, 2010
Detecting the dominant (>50%) symbol in a stream.
Sunday, May 23, 2010
Count in a range in O(1)
PS: I was used to ask this question during my interviews. Now no longer ;-)
Saturday, May 22, 2010
Sort a dictionary of variable lenght words
PS: this is a tricky question, with practical implication in information retrieval.
Friday, May 21, 2010
The perfect interview: Make your own assumptions
Anyway, interviews are important and you need to find a solution. So I follow three golden rules:
1) Many judgments are better than one. The candidate should be evaluated by many independent interviewers in a loop. It would be better if the interviewers express no judgment until the loop is closed to avoid influencing each others;
2) I always ask to myself: "Can I work with this candidate? Would (s)he help me in solving the problems we face day by day?"
My interviews are around some problem solving (you read my blog so you know this), a lot of algorithmic questions ;-), a lot of C++ coding and design patterns. In addition, machine learning, retrieval, and data mining are my areas of expertise so do expect to get some questions here. I am not very much impressed if you know all the recent academic papers or the books. I am very much interested about your intuitions. In fact, my third question is the most important one:
3) "How much creative is this candidate? How much can we learn from him in the future?"
The most interesting part of the interview is when we can discuss about hard problems
applied to real life and on very large dataset (up to petabytes of data). I describe the problem with one or two sentences and then tell to the candidate
Make your own assumptions
Thursday, May 20, 2010
Increase the Page Views, Yahoo
Wednesday, May 19, 2010
Suffix Tree with Unicode Support
Tuesday, May 18, 2010
Sort again
We have N element array with k distinct keys. sort this array without using any extra memory.
Monday, May 17, 2010
BST
Sunday, May 16, 2010
Google and the WI-FI Mapping
Saturday, May 15, 2010
YourOpenBook
Friday, May 14, 2010
Why Facebook's "Like" buttom is a real game changer?
Facebook "Like" is a real game changer for two different reasons:
1) FB enlarged the base of its data sources. Every time a user push the "Like" button on a partner site, they will know.
2) FB enlarged the base of its data sources. Every time a user load an external page in a partner site including the "Like" button, they will know. Even if you do not push the button.
We both agreed that 2) is the most important information, because you know a lot about real-time traffic.
Thursday, May 13, 2010
Partition a set (a bit harder)
Wednesday, May 12, 2010
Tuesday, May 11, 2010
Common substrings
Monday, May 10, 2010
Evolution of Search
Well, I was wrong. Facebook has a lot of data to search and they are the only one who can mine it. Try to search the volcano situation. Strangely enough they are not giving too much emphasis to this feature. So far ...
Sunday, May 9, 2010
Data analysis is the language of this age
Saturday, May 8, 2010
Friday, May 7, 2010
Minimum in two lists
Thursday, May 6, 2010
Optimal merge and operator AND in search
(this is one of that questions that explains why basic algo knowledge is fundamental)
Wednesday, May 5, 2010
What direction is the stack growing?
Tuesday, May 4, 2010
Bartz in London
Monday, May 3, 2010
Facebook Searches Double – Words per Search to 3.5
Sunday, May 2, 2010
Google acquired a 3d desktop company
I wrote about my will to invest in a 3d desktop company. Google acquired one company, but they are not true 3d they simulate 3d into a 2d space.
Saturday, May 1, 2010
Oneriot is indexing public Facebook data
Friday, April 30, 2010
Mugs
Thursday, April 29, 2010
Open Graph, quite interesting API for search
Wednesday, April 28, 2010
Added a VectorSpace generator ...
People are telling me "so you work all the time". My point is that I do not consider this particular coding activity "a work". I make this just because is fun and just because I like it.
Studying, Coding is just fun. Fun like going to the gym (7.am-8am) or going to see a musical (9pm-..) don't you agree?
Tuesday, April 27, 2010
I like it a lot
The new feature allows any developer to drop a fairly simple piece of code into a site to create a two-way direct link with Facebook's network. If you have signed into Facebook, this third-party website will recognize who you are and feed anything you do there back into your Facebook profile.
Given Facebook's size and growth curve, it will be next to impossible for any major website to resist implementing the Open Graph. They simply cannot turn their back on the ability to leverage that massive an audience. All those users will be feeding their actions back to their Facebook friends, given the website's powerful viral promotion
Of course, it also means Facebook will control a treasure trove of information about you....
Monday, April 26, 2010
Finding the maximum sum in two sorted arrays
Sunday, April 25, 2010
Number 6 and 7
Saturday, April 24, 2010
Sorted linked list into a binary search tree
Friday, April 23, 2010
Find the index of three numbers whose sum is closest to zero
Thursday, April 22, 2010
One in Four Countries Block Some Google Services
Wednesday, April 21, 2010
Tuesday, April 20, 2010
Monday, April 19, 2010
62-63 = I
Sunday, April 18, 2010
Ants and a segment
Suppose that the ants move in a synchronous way. When it the end?
Saturday, April 17, 2010
Pages in a newspaper
Friday, April 16, 2010
Set of intervals
Thursday, April 15, 2010
Wednesday, April 14, 2010
Number 2
Tuesday, April 13, 2010
Server allocation for different Online providers
Monday, April 12, 2010
Find the largest element in an interval
Sunday, April 11, 2010
Apple remove Google from Iphone 4.0 OS
Saturday, April 10, 2010
Yahoo+Microsoft +0.3, Google -0.4
Microsoft's Bing scored the biggest increase, growing from 11.5 percent to 11.7 percent in March. Yahoo moved up slightly from 16.8 percent to 16.9 percent during the same period.
The Yahoo move is significant, if for no other reason than it stopped the six straight month losses in search share they experienced.
Google had the largest move, albeit downward, dropping from 65.5 percent search share to 65.1 percent.
Friday, April 9, 2010
Yahoo! to loose his CTO
Thursday, April 8, 2010
Random search in a random array, with duplicates
Suppose you have an array of random integers A[i] i = 0, ... , n-1. Suppose you adopt the following random search strategy for value x. Pick a random index i into A. If A[i] = x, then we terminate; otherwise, continue the search by picking a new random index into A. Note that we may examine a given element more than once.
Wednesday, April 7, 2010
Personal consideration about algorithms in Europe
Tuesday, April 6, 2010
Ed Roberts, the father or modern PC died on April 1st
Henry Edward "Ed" Roberts (September 13, 1941 – April 1, 2010) was an American engineer, entrepreneur and medical doctor who designed the first commercially successful personal computer in 1975.[1] He is most often known as the "the father of the personal computer".[2] He founded Micro Instrumentation and Telemetry Systems (MITS) in 1970 to sell electronics kits to model rocketry hobbyists, but the first successful product was an electronic calculator kit that was featured on the cover of the November 1971 issue of Popular Electronics.[3] The calculators were very successful and sales topped one million dollars in 1973.[4]
A brutal calculator price war left the company deeply in debt by 1974. Roberts then developed the Altair 8800 personal computer that used the new Intel 8080 microprocessor. This was featured on the cover of the January 1975 issue of Popular Electronics, and hobbyists flooded MITS with orders for this $397 computer kit.
Bill Gates and Paul Allen joined MITS to develop software and Altair BASIC was Microsoft's first product. Roberts sold MITS in 1977 and retired to Georgia where he farmed, studied medicine and eventually became a small-town doctor.
Monday, April 5, 2010
AI Application Programming (Programming Series)
Sunday, April 4, 2010
Text Mining Application Programming (Programming Series)
Saturday, April 3, 2010
Facebook and data privacy
Friday, April 2, 2010
February Search: Bing Gains at Yahoo's Expense
The major search engines continue their recent market share trend; Google capturing the lion’s share and steady, Bing continuing to gain ground while Yahoo! continues on its downward trend.
Thursday, April 1, 2010
Tuesday, March 30, 2010
Random in place
RANDOMIZE-IN-PLACE(A)
n = length[A]
for i =0 ... n-1
do swap (A[i], A[RANDOM(i, n)])
Monday, March 29, 2010
Leaving Yahoo!
Sunday, March 28, 2010
Do you run or walk when it is raining?
Saturday, March 27, 2010
Number of inversions
Friday, March 26, 2010
Approximate intersection of two lists
impossible -> 343, 5, 63459, 4, ....., 32
mission -> 3449, 558, ...., 49
Suppose the two lists are very long. For instance, the word 'impossible' can be contained in 100*10^6 documents, while the word mission can be contained in 50*10^6 documents.
1) return the documents containing the words 'impossible mission' (documents must contain both the words)
2) what is the complexity?
3) can you accellerate the computation?
4) how to compute the size of the lists intersection?
5) can you estimate this size in a fast way?
Thursday, March 25, 2010
Buying a new car
So I am evaluating this strategy. Every week I go to car dealer, I test a couple of cars and, If i find one that I like, a sell my current car c_i for amount of money m_i and a buy a new one c_i+1 for a new amount of money m_i+1. Note that going to the car dealer has a fixed cost say cd.
My strategy is to find the best car ever, but I want to estimate what is the cost for achieving this goal.
Wednesday, March 24, 2010
Generate a random permutation of an array of intergers
Tuesday, March 23, 2010
Tossing coins (ufff again?)
expect to see?
Monday, March 22, 2010
Points in a plane
Sunday, March 21, 2010
Least Square Methods: simple form of regression
Saturday, March 20, 2010
Language detection
Friday, March 19, 2010
Spam detection
Thursday, March 18, 2010
Traffic lights and probabilities
P(X>21) = 1-P(X<=21) ; 14 / 4 = 1.5 this is the standardization of the distribution , then..
Wednesday, March 17, 2010
A ticketing system
PS: if you find this very similar to the hash collision problem, well that is not by chance.
Tuesday, March 16, 2010
Document processing with score and cost function
Monday, March 15, 2010
Radomizing an array before linear search
Sunday, March 14, 2010
Random search in random array
What is the expected number of indexes analyzed?
Saturday, March 13, 2010
A compressed vector space
Friday, March 12, 2010
Sort different runs of integers
Thursday, March 11, 2010
Water jugs
It is your task to find a grouping of the jugs into pairs of red and blue jugs that hold the same amount of water. To do so, you may perform the following operation: pick a pair of jugs in which one is red and one is blue, fill the red jug with water, and then pour the water into the blue jug. This operation will tell you whether the red or the blue jug can hold more water, or if they are of the same volume. Assume that such a comparison takes one time unit. Your goal is to find an algorithm that makes a minimum number of comparisons to determine the grouping. Remember that you may not directly compare two red jugs or two blue jugsWater