klenwell information services : SpecialCocktailNapkin

Revision [2718]

This is an old revision of SpecialCocktailNapkin made by KlenwellAdmin on 2014-03-13 08:19:44.
 

online cocktail napkin

links and notes for later organization

Wikka Handler Refactor

    public function process_request($request) {
        $route = $this->route_request($request);
        $response = $this->run_wikka_handler($route['page'], $route['handler']);
       
        $response->set_header('Cache-Control', 'no-cache');
        $response->set_header('ETag', md5($content));
        $response->set_header('Content-Length:', strlen($content));
       
        return $response;
    }
   
    private function run_wikka_handler($page_name, $handler_name) {
        $wikka = new WikkaBlob($this->config);
        $wikka->connect_to_db();
        $wikka->save_session_to_db();
        $wikka->validate_handler_name($handler_name);
       
        if ( $wikka->is_new_style_handler($handler_name) ) {
            $handler = $wikka->load_handler_class($handler_name);
            $response = $handler->handle();
            return $response;
        }
        else {
            return $this->run_old_style_handler($page_name, $handler_name);
        }
    }
   
    private function run_old_style_handler($page_name, $handler_name) {
        $wikka = new WikkaBlob($this->config);
        $wikka->globalize_this_as_wakka_var();
        $wikka->open_buffer();        
        $wikka->Run($page_name, $handler_name);
        $content = $wikka->close_buffer();
       
        # create response object
        $response = new WikkaResponse($content, 200);
        $response->set_header('Content-Type', 'text/html; charset=utf-8');
       
        # Set header for response object from headers list
        $headers = headers_sent();        
        foreach ($headers as $header) {
            list($key, $value) = explode(':', $header, 1);
            $response->set_header($key, $value);
        }

        return $response;
    }


Wikka Install Exception

try {
    $request = $webservice->prepare_request();
    $webservice->start_session();
    $webservice->set_csrf_token();
    $webservice->raise_exception_if_install_required();
    $response = $webservice->process_request($request);
}
catch (WikkaInstallException $e) {
    $response = $webservice->process_installer($request);
}
catch (Exception $e) {
    $response = $webservice->process_error($e);
}


Unpublished Comment

In response to https://news.ycombinator.com/item?id=7341400:

I get this impression with a lot of libertarian social ideas, e.g. socialized health coverage or newfangled food supplements.

It seems to be one area where recapitulation theory[1] applies. Only by seeing ontogeny recapitulate phylogeny for themselves will some people -- strike that, most people -- appreciate the hoary inefficient logic behind long-established conventions and institution.

[1] http://en.wikipedia.org/wiki/Recapitulation_theory


Test Local Site on Android Chrome Attached by USB

Full instructions here:
https://developers.google.com/chrome-developer-tools/docs/remote-debugging

DESKTOP: local machine where you doing your development
PHONE: Android device connection to DESKTOP by USB

1. On DESKTOP: Get network IP address
- Open terminal
- Run: ifconfig
- Copy inet addr for eth0 (e.g., inet addr:192.168.1.101)

2. On DESKTOP: Set up port forwarding for Chrome
- In address bar, enter: about:inspect
- Check checkbox for Discover USB devices
- Click Port Forwarding button
- In pop-up for Port Forwarding Settings, enter:
8080 <IP ADDRESS>:80

For example:
8080 192.168.1.101:80

3. On PHONE: Go to website
- In address bar, enter: 192.168.1.101:80*

* Note: This can also be done in the inspect tab by using Open tab with url
field. Just enter same value there and if Chrome is open on your phone, it
will automatically load that page.


2014 Cocktail Napkin

Happy New Year!



CategorySpecial