Saturday, October 20

Facebook and AD Campaigns



Is it true, bots are clicking on the ads in facebook?

Yes, its True!

Limited Run Company noticed it could only verify about 20 percent of the clicks that were supposedly being converted to users showing up on its Web site.

80% of clicks it was paying for were coming from bots.

Bots are computer scripts or fake users who simply repeatedly click the ads.
  

What if you complain this to facebook?

If a complaint is send to Facebook, then it demands for the below information:
  1. Server Logs
  2. Aggregated counts of your clicks

What are these?

1. Server Logs

Raw server logs of all clicks coming to your website, or the total amount of all clicks coming from Facebook, with an explanation of how you filtered them.

These server logs must contain:
  1. Timestamp of page load
  2. User agent string
  3. User IP
  4. Exact page loaded, with the parameters passed

 2. Aggregated counts of your clicks (Optional)

If possible, please also include the following:
  1. The total number of clicks you received from Facebook split by day, for the specific time period where you have noticed the click issues.
  2. The total number of clicks you were billed for, by Facebook, also by billable day for the period in question.
  3. A screenshot of your external reporting system showing the total number of clicks received from Facebook.


How to get Server Logs?

For Tomcat Application Server, it can be achieved by setting the value of ‘Access Log Valve’ tag, in pattern attribute as ‘combined’ in server.xml.

<Valve className="org.apache.catalina.valves.AccessLogValve" pattern="combined" directory="logs" prefix="yoursitename_access" suffix=".txt" />
  

Techniques to find or block bots


1. Unique Cookie is one way to find out whether a user has registered multiple times from the campaign or not.

When a user registers from a campaign, server should store a unique cookie value to that user’s browser. So the next time a user registers from that browser, server can find out by looking at the cookie stored.


2. Create a blacklist of user agents of known bots like FeedBurner, Googlebot.

Whenever a request comes, compare their user agent string with the blacklist, to determine whether these are bots or not. Or even a prevention step can also be taken from these identified bots.

This implementation has a performance hit because we have to check each user request user agent to the blacklist.

Also some user agents are real users (hired by ad agency for cheap labour). No blacklist is going to have those real users.


3. Flag bot vs. non-bot.

Log information about browsers which cannot execute Javascript, and then built some sort of system that analyzes these browsers and their trends (like, if they originate from a certain IP range).
 Javascript is something that is on by default and for a user to turn it off is an explicit manual action. No user wants to turn off the javascript, unless for doing any suspicious activity or he is a guy who hates the word ‘java’.

But this means cannot catch the bots until after the analysis.

4.  Whenever user registers, send a verification code to the user’s email or sms to authenticate the identity.
 

5.  Captcha
captcha block bot technique

           But not good for user experience and may even prevent irritated users from registering.  


References:

Saturday, September 1

Year 2038 Bug



Year 2038 Bug


Computer programs, softwares and systems that uses 32 bit integer to represent UNIX Time will fail after 19th, Jan, 2038 at 3:14:07.

What ?

Unix Time is another way of telling time, mostly for computer’s understanding. Each instances are defined as number of seconds elapsed after 1970-01-01 00:00:00.

Eg: UNIX Time for 31st Aug 2012 18:59:09 = 1346439549


On 19th, Jan, 2038 at 3:14:07, the 32 bit signed integer will reach its limit. After that, bit will overflow the 32-bit counter and reset the time to 1st Jan, 1901.

2038 bug


Attention to Mysql Users


Mysql 5 is a 32 bit database, it has a function UNIX_TIMESTAMP() which returns seconds since 1970-01-01 00:00:00. This function will return only 0 after 19th Jan, 2038 03:14:07 GMT.


The end time would be different for each region based on their time zone.

Auckland +12:00 19-01-2038 15:14:07
Sydney +10:00 19-01-2038 13:14:07
Tokyo +9:00 19-01-2038 12:14:07
Beijing +8:00 19-01-2038 11:14:07
Mumbai +5:30 19-01-2038 08:44:07
Dubai +4:00 19-01-2038 07:14:07
Nairobi +3:00 19-01-2038 06:14:07
Cairo +2:00 19-01-2038 05:14:07
Paris +1:00 19-01-2038 04:14:07
London UTC 19-01-2038 03:14:07
Brasilia -3:00 19-01-2038 00:14:07
Atlantic Time -4:00 18-01-2038 23:14:07
Eastern Time -5:00 18-01-2038 22:14:07
Central Time -6:00 18-01-2038 21:14:07
Mountain Time -7:00 18-01-2038 20:14:07
Pacific Time -8:00 18-01-2038 19:14:07
Hawai -10:00 18-01-2038 17:14:07

References:

1. http://en.wikipedia.org/wiki/Year_2038_problem
2. http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_unix-timestamp

Friday, July 27

Google search Tips



 1.      filetype:  For searching for a specific file type only.

E.g.:  Search for ppt files           
           
computer networks filetype:ppt


2.      cache:  This is to load sites quickly.

E.g.:
           
cache:http://www.thehindu.com


3.      movie:  It shows all information regarding the movie.

E.g.:
           
movie:Dark Knight


4.      site:  To search within a site domain

E.g.:
           
entrance result site:gov.in


5.      phonebook:  To get details of a person using phone number

E.g.:
           
phonebook:28576300


6.      “ ”    For searching for an exact phrase

E.g.:
           
how to change tyre


7.        -   To exclude a particular word in the search

E.g.:  To exclude all search relating to cricket match

cricket -game -score

Thursday, July 5

Fix Memory Leak in Java


Fix Memory Leak in Java

Actions to prevent memory leak:

  1. When a reference variable is no longer in use, assign null value to it.
  2. Close DataInputStreams and JDBC Connections.
  3. Shutdown the threads after completion.
  4. Restrict using static classes and methods.
  5. Put less data on Sessions.
  6. Invalidate Sessions.
  7. Set short duration for timeout of sessions.
  8. Avoid using String for concatenation instead use StringBuffer.

How do we know memory leak is happening?

Getting OutOfMemoryError (OOM) is a sign of possible memory leak. The other way is by checking the used JVM heap size. If the heap size is rising with time then clearly you have memory leak.

memory leak java heapdump graph


Debugging memory leak

  • In Tomcat, open Catalina.bat file, set CATALINA_OPTS with XX:+HeapDumpOnOutOfMemoryError
set CATALINA_OPTS=%CATALINA_OPTS% -XX:+HeapDumpOnOutOfMemoryError


  • Now a heap dump is written on the first Out Of Memory Error into %CATALINA_HOME%\bin as java_pid<pid>.hprof
memory leak java heapdump file


  • Or for On-demand, if you are using Java6, then use jmap.exe -dump:format=b,file=HeapDump.hprof  <pid>  
memory leak java jmap




Wednesday, June 27

How to Increase your Laptop Battery Life


Batteries live longer if treated in a gentle manner. The longevity is often a direct result of the environmental stresses applied.

Following are the steps to increase your notebook’s battery life:
  1. Do not ever let your Battery Power fall below 40%.
  2. Do not ever charge at or below 0o C.
  3. Always best to work with Power supply Plugged-in.
  4. Always best to give a 30 min break after 3 hour usage. Shutdown or hibernate the notebook and plug-off the Power supply.
  5. Make sure to leave your battery power between 50% - 40%, if you are not going to use the notebook for long time (like more than 6 hours)
notebook battery power should not decrease 40%


Why not to let Battery Power fall below 40% ?
Do not discharge lithium-ion too deeply. Instead, charge it frequently. Lithium-ion does not have memory problems like nickel-cadmium batteries. No deep discharges are needed for conditioning. Deep discharges will increase the temperature and reduce battery life. If Li-ion cells are discharged below a certain voltage a chemical reaction occurs that make them dangerous if recharged, which is why probably all such batteries in consumer goods now have an "electronic fuse" that permanently disables them if the voltage falls below a set level. The electronic fuse draws a small amount of current from the battery, which means that if a notebook battery is left for a long time without charging it, and with a low initial state of charge, the battery may be permanently destroyed.

Why not charge at or below 0o C ?
Do not charge lithium-ion at or below freezing temperature. Although accepting charge, an irreversible plating of metallic lithium will occur that compromises the safety of the pack.

Why is it best to work with Power supply Plugged-in ?
Plugged-in power supply takes control of the power requirements and stress is relieved from battery. Also less battery discharges occurs.

Why to give a 30 min break after 3 hour usage ?
A continuous usage gives more stress on the battery and raises the battery temperature and thereby reducing life. A frequent break can allow to battery to cool down to a nominal temperature and prevents increase of temperature to critical levels. Degradation of battery occurs faster at higher temperatures. Degradation in lithium-ion batteries is caused by an increased internal battery resistance due to cell oxidation. This decreases the efficiency of the battery, resulting in less net current available to be drawn from the battery.

Why need to keep battery power at 50%-40% before long time non usage of notebook?
When storing, lithium batteries degrade more while fully charged than if they are only 40% charged.



References
http://batteryuniversity.com/learn/article/the_high_power_lithium_ion/

Monday, June 4

How to set Google as default search engine in Internet Explorer

Microsoft has made it really difficult for people using ie8 or ie9 in setting Google as their default search engine.
Follow these simple steps:
  1. Open your Internet Explorer.
  2. Go to this link  http://www.iegallery.com/en-US/Addons/Details/813
  3. Click on "Add to Internet Explorer".
  4. Check the ''Make this my default search provider" option.
  5. Click on "Add" button.
Now Google is set as  default search engine.


Add Google Add-on to Internet Explorer




Make this my default search provider

+ UPDATE on 30-07-2012

Some have complained that they are still not able to see Google search Addon. 

Please access this link http://www.google.com/homepage/search/ and click on "Switch Now!" .

set google as default search



 For More Add-ons in IE, please refer to this link http://www.iegallery.com/Addons .