Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 179 lines (148 sloc) 4.521 kb
use strict;
use warnings;
use utf8;
use Encode qw( is_utf8 _utf8_on from_to encode decode :fallbacks );
binmode STDOUT, ":utf8";
use File::Copy;
my %count = ();
my %full = ();
my %dup = ();
while (my $line = <IN>) {
my @line = split(/\t/,$line);
my $id = $line[0];
next if exists $dup{$id};
$dup{id} = undef;
my $username = $line[1];
my $tweet = $line[2];
$tweet =~ s/\#replaceawordinafamousquotewithduck\s*//i;
my $tweet2 = $tweet;
$tweet2 =~ s/\#[^\s]+\s*//;
$tweet2 =~ s/\&quot\;/\"/og;
$tweet2 =~ s/\&amp\;/\&/g;
$tweet2 =~ s/\-\-.*//;
$tweet2 =~ s/^\s*\"//;
$tweet2 =~ s/\s*\"\s*$//;
# FOr debugging.
# print qq($tweet\n);
$tweet2 = lc $tweet2;
$tweet2 =~ s/[^a-z]+//g;
next if !$tweet2;
if ($count{$tweet2}>1) {
$full{$tweet2} = qq($tweet\t$username\t$id);
my $lines = '';
foreach my $tweet2 (sort {$count{$b}<=>$count{$a}} keys %count) {
my $count = $count{$tweet2};
last if $count<5;
# For debugging.
# print $count, "\n";
# print qq($count\t) . length($tweet2), qq(\t$tweet2\n);
my ($tweet,$username,$id) = split(/\t/,$full{$tweet2});
# For debugging.
# print qq($tweet\t$username\t$id\n);
$lines .= qq(<div class="tweet">$tweet</div><div class="username">$count tweets; this latest one by <a href="$username">\@$username</a></div>);
open OUT, ">:encoding(UTF-8)", Encode::decode_utf8("/usr/local/ddg/www-static/");
print OUT <<EOH
<link title="DuckDuckGo" type="application/opensearchdescription+xml" rel="search" href="ddg/opensearch.xml">
<link rel="stylesheet" href="ddg/s99.css" type="text/css">
<meta http-equiv="refresh" content="180;url=/" />
<style type="text/css">
.tweet {
font-style: italic;
font-size: 20px;
padding-bottom: 5px;
.username {
font-size: 12px;
padding-bottom: 20px;
DuckDuckGo, a search engine that <a href="">doesn't track</a> or <a href="">bubble</a> you:
<iframe src="" style="overflow:hidden;margin:0;padding:0;width:473px;height:60px;" frameborder="0"></iframe>
<td width="260" valign="top" style="padding-right: 50px;">
<script src=""></script>
new TWTR.Widget({
version: 2,
type: 'search',
search: '#replaceawordinafamousquotewithduck',
interval: 6000,
title: '#replaceawordinafamousquotewithduck',
subject: '',
width: 250,
height: 300,
theme: {
shell: {
background: '#d54249',
color: '#ffffff'
tweets: {
background: '#ffffff',
color: '#444444',
links: '#1986b5'
features: {
scrollbar: false,
loop: true,
live: true,
hashtags: true,
timestamp: true,
avatars: true,
toptweets: true,
behavior: 'default'
<a href=""><img src="wall-e.jpg"></a>
<a href=""><img src="inception.jpg"></a>
<a href=""><img src="jurassic-park.jpg"></a>
<a href=""><img src="twilight.jpg"></a>
<a href=""><img src="star-wars.jpg"></a>
<a href=""><img src="step-up-4.jpg"></a>
<a href=""><img src="spiderman-3.jpg"></a>
<td width="450" valign="top">
Top \#ReplaceAWordInAFamousQuoteWithDuck tweets,
updated every 5min, by <a href="">DuckDuckGo</a> (a search engine).
Jump to Line
Something went wrong with that request. Please try again.