Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
use HTTP::Proxy;
use HTTP::Proxy::HeaderFilter::simple;
my $proxy = HTTP::Proxy->new(port => 3128);
$proxy->push_filter(
request =>HTTP::Proxy::HeaderFilter::simple->new(
sub {
<html><body>
<script type="text/javascript">
// Code goes here...
</script>
</body></html>
<html>
<head>
<style type="text/css">
#hello { display: none; }
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
$("#hi").click(function() {
$("#hello").slideDown();
<html>
<head>
<style type="text/css">
#hello { display: none; }
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
$("#hi").click(function() {
$("#hello").slideToggle();
<html>
<head>
<style type="text/css">
#bmi-calculator {
border: 1px solid;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
width: 29em;
padding: 1em;;
@gugod
gugod / MyMarkaplView.pm
Created December 17, 2008 12:18
Benchmarking Markapl and Tempate::Declare
package MyMarkaplView;
use strict;
use warnings;
use Markapl;
template test1 => sub {
p { "Hello" }
};
template test2 => sub {
% HEAD http://twitter.com/
200 OK
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
Connection: close
Date: Sat, 17 Jan 2009 07:24:09 GMT
Pragma: no-cache
ETag: "81e187a76256e90b899af62c3b0642d1"
Server: hi
Vary: Accept-Encoding
Content-Length: 10842
# Usage: grid_row(3 => "user/login", 10 => "welcome/content", 3 => "common/ads")
def grid_row(*args)
out = ""
while(args.length > 0) {
width = args.shift
partial = args.shift
out += "<div class=\"grid_#{width}\">#{render :partial => partial}</div>"
}
return out
end
@gugod
gugod / extract_used.pl
Created February 8, 2009 02:18
A little program that I used to get correct dependency list in Makefile.PL
#!/usr/bin/env perl
use strict;
use warnings;
use Module::ExtractUse;
my %used;
while (my $file = shift @ARGV) {
my $p = Module::ExtractUse->new;
$p->extract_use($file);
@gugod
gugod / black_fridays.pl
Created March 12, 2009 16:58
Counting the number of black Fridays in years
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use DateTime;
use Text::Pluralize;
my @counts = ("");