Sugree

skip to navigation

Python

Tweet to Text 3

It seems Python on non-linux platform, e.g., Mac and Windows, doesn't support Unicode so well. I added another option to specify target encoding if necessary and the default encoding is 'utf-8'. This patch is against Tweet to Text 2.

diff --git a/track.py b/track.py
index e651f51..1842e61 100644
--- a/track.py
+++ b/track.py
@@ -52,6 +52,9 @@ class App:
         parser.add_option('-p', '--pages',
                           default=4, type='int', dest='pages',
                           help='max pages')
+        parser.add_option('--encoding',
+                          default='utf-8', dest='encoding',
+                          help='output encoding')
 
         self.options, self.args = parser.parse_args()
 
@@ -81,7 +84,8 @@ class App:
 
         history.reverse()
         for i in history:
-            print format_tweet(i)
+            tweet = format_tweet(i)
+            print tweet.encode(self.options.encoding, 'replace')
 
         if verbose:
Submitted by sugree on Thu, 09/04/2008 - 12:39.

Tweet to Text 2

Because of my debate, I found a duplication bug in Tweet to Text that led me to post the fix here.

diff --git a/track.py b/track.py
index ea27c2f..e651f51 100644
--- a/track.py
+++ b/track.py
@@ -65,7 +65,9 @@ class App:
         query = ' '.join(self.args)
         results = search(query)
         for i in results['results']:
-            history.append(i)
+            if i['id'] not in keys:
+                history.append(i)
+                keys[i['id']] = 1
 
         for p in range(self.options.pages-1):
             if 'next_page' not in results:
@@ -73,7 +75,9 @@ class App:
             next_page = results['next_page']
             results = search(query, next_page[1:])
             for i in results['results']:
-                history.append(i)
+                if i['id'] not in keys:
+                    history.append(i)
+                    keys[i['id']] = 1
Submitted by sugree on Wed, 09/03/2008 - 13:35.

Tweet to Text

Sometimes you might want to keep your old tweet in your blog forever. Publish the fruitful conversation or debate in your blog everlasting long. There is no easy way yet as far as I know. But it is possible to use Twitter Search. @markpeak asked me for help. Below script is my help.

Submitted by sugree on Tue, 09/02/2008 - 10:42.

Mitter 0.3.2.2 for Debian-based distributions

After spending a few days with GetDeb, I has successfully compiled Mitter on GetDeb and uploaded to the front page. The main page is available at below url.

http://www.getdeb.net/app/Mitter

Bookmark it! The current stable is 0.3.2.2. It is available in both 32 bit and 64 bit.

Submitted by sugree on Sat, 08/02/2008 - 08:55.
123next ›last »

Main menu

Popular Tags

debian
apache
drupal
drupal.in.th
feedburner