Skip to content

Instantly share code, notes, and snippets.

View beppu's full-sized avatar

John Beppu beppu

View GitHub Profile
package Squatting::Controller;
sub new{bless{name=>$_[1],urls=>$_[2],@_[3..$#_]}=>$_[0]}
sub clone{bless{%{$_[0]},@_[1..$#_]}=> ref($_[0])}
for my$m qw(name urls cr env input cookies state v status headers log view app){
*{$m}=sub:lvalue{$_[0]->{$m}}}
for my$m qw(get post head put delete options trace connect){
*{$m}=sub{$_[0]->{$m}->(@_)}}sub param{my($self,$k,@v)=@_;
if(defined $k){if(@v){$self->input->{$k}=((@v>1)?\@v:$v[0]);
}else{$self->input->{$k}}
}else{keys%{$self->input}}}
@beppu
beppu / Chat.pm
Created November 20, 2008 02:02
Eventually, this will be an embeddable chat widget.
package Chat;
use base 'Squatting';
use AnyEvent;
use Coro;
use Coro::AnyEvent;
use Coro::Signal;
# a slot-based object WITHOUT prototype-based inheritance
package UTF8;
use base 'Squatting';
# == How to Run This App ==
#
# squatting UTF8
# squatting UTF8 -c view=raw
# squatting UTF8 -c view=as_subs
#
@beppu
beppu / App.pm
Created September 30, 2008 04:22
package App;
use base 'Squatting';
use Coro::AnyEvent; ### <<< --- very important XXX XXX XXX
our %CONFIG = (
host => 'http://localhost:5984/',
db => 'app',
);
package App::Controllers;
use Squatting ':controllers';
package CouchWiki;
use strict;
use warnings;
use base 'Squatting';
use Coro::AnyEvent;
our %CONFIG = (
db => 'couchwiki'
);
function (doc) {
// subset that doesn't contain current
var others = function(tags, current, length) {
var notCurrent = function(x) { return x != current; };
if (length == 2) {
return tags.filter(notCurrent).map(function(n){ return [n] });
} else {
var _others = [];
var list = tags.filter(notCurrent);
var size = length - 1;
package JGirl; # jgirl.com (after being liberated from domain squatters)
#
use strict; # Oh, the irony!
use warnings; #'
use base 'Squatting'; # <-----------------------------------'
use Encode;
our %CONFIG = (
dbconnect => 'dbi:SQLite:dbname=jgirl.db',
package WhatIf;
use base 'Squatting';
# Data in %state persists between requests.
our %state;
sub service {
my ($app, $c, @args) = @_;
my $cr = $c->cr;
my $sid = $cr->{session_id};
if (defined $sid) {