Skip to content

Instantly share code, notes, and snippets.

View beppu's full-sized avatar

John Beppu beppu

View GitHub Profile
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) {
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',
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 CouchWiki;
use strict;
use warnings;
use base 'Squatting';
use Coro::AnyEvent;
our %CONFIG = (
db => 'couchwiki'
);
@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 UTF8;
use base 'Squatting';
# == How to Run This App ==
#
# squatting UTF8
# squatting UTF8 -c view=raw
# squatting UTF8 -c view=as_subs
#
@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 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}}}
diff -rN -u old-Continuity/lib/Continuity/Adapt/HttpDaemon.pm new-Continuity/lib/Continuity/Adapt/HttpDaemon.pm
--- old-Continuity/lib/Continuity/Adapt/HttpDaemon.pm 2008-12-10 15:20:22.000000000 -0800
+++ new-Continuity/lib/Continuity/Adapt/HttpDaemon.pm 2008-12-10 15:20:22.000000000 -0800
@@ -215,6 +215,8 @@
sub debug_level { exists $_[1] ? $_[0]->{debug_level} = $_[1] : $_[0]->{debug_level} }
+sub debug_callback { exists $_[1] ? $_[0]->{debug_callback} = $_[1] : $_[0]->{debug_callback} }
+
=for comment
@beppu
beppu / 00-request-without-memcached.txt
Created February 4, 2009 08:36
what a difference memcached makes...
090204 0:32:28 11 Connect kohaadmin@localhost on koha
11 Query set autocommit=1
11 Query set NAMES 'utf8'
11 Query SELECT value
FROM systempreferences
WHERE variable='LibraryName'
LIMIT 1
090204 0:32:29 11 Query select * from auth_types order by authtypetext
11 Query SELECT value
FROM systempreferences