Sunday, September 11, 2011

Python - Count Feedburner's Subscriber

Summary: Python script to count subsriber from Feedburner. Before run this script, Feedburner awareness API must be activated. This is script is inspired by Eric Wendelin.
#!/usr/bin/env python

# kuntoaji.blogspot.com

# IMPORTANT: Feedburner awareness API must be activated

# Replace with your own name
feedburner_name = "railsmine"

import urllib
from xml.dom import minidom

try:
  dom = minidom.parse(urllib.urlopen('https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='+feedburner_name))
  entry = dom.getElementsByTagName('entry')[0]
  count = entry.getAttribute('circulation')
  print "total subscriber:",count
except:
  print "Oops! Something went wrong. Check your feedburner's name or your internet connection."

PHP - Redirect Malicious IP Address

<?php 
/**
http://kuntoaji.blogspot.com
*/

/* Replace this with your IP address.. */
$malicious_ip = '127.0.0.1'

if ($_SERVER['REMOTE_ADDR'] == $malicious_ip) {
header("Location: http://www.example.com/");
}
?>

Click Counter with jQuery

Summary: Count every user click "click me!" link

<html>
  <head>
    <title>Click Counter</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    <script type="text/javascript">
      // http://kuntoaji.blogspot.com
      $(function(){
          var total_click = 0;
          $("#clickMe").click(function(){
            total_click = total_click + 1;
            $("#counter").text("Total Click: " + total_click);
return false;
          });
        });
    </script>
  </head>
  <body>
    <div id="counter">Total Click: 0</div><br />
    <a id="clickMe" href="#">click me!</a>
  </body>
</html>

Popular Posts