{"revision": {"id": "f2e77b1a-2f95-11f1-9aa2-e86a64d24d78", "node_id": "f295ca8d-2f95-11f1-8107-e86a64d24d78", "user_id": "edc3f576-2f95-11f1-900f-e86a64d24d78", "author": "foxhop", "data": "This is another sandbox for new users to test functionality\r\n======================================================================\r\n\r\nMako template for city index\r\n\r\n.. code-block:: mako\r\n\r\n <%inherit file=\"base.mako\" />\r\n\r\n <div class=\"grid=\"15\">\r\n\r\n <em> There are ${count} cities in ${state['name'].title()} to browse:</em>\r\n\r\n <br />\r\n\r\n <% letters = 'abcdefghijklmnopqrstuvwxyz'%>\r\n\r\n <div id=\"index\">\r\n % for letter in letters:\r\n    % if cities[letter]:\r\n        <a href=\"#${letter}\">${letter.upper()}</a>\r\n    % else:\r\n        ${letter.upper()}\r\n    % endif\r\n % endfor\r\n </div>\r\n\r\n % for letter in letters:\r\n    % if cities[letter]: \r\n        <a href=\"#index\" id=\"${letter}\" class=\"letter-link\">${letter.upper()}</a>\r\n        <ul>\r\n        % for city in cities[letter]: \r\n            <% city = city.lower() %>\r\n           <li><a href=\"/${state['short'].lower()}/${city.replace(' ','-')}\">${city.title()}</a></li>\r\n        % endfor\r\n        </ul>\r\n    % endif\r\n % endfor\r\n\r\n </div>\r\n\r\n\r\n\r\n\r\n\r\nbreadcrumb algorithm\r\n==========================================\r\n\r\n.. code-block:: python\r\n\r\n class Bread( object ):\r\n    \"\"\"\r\n    Create a list of URL parts or crumbs\r\n    ----------------------------------------\r\n    >>> from bread import Bread\r\n    >>> bread = Bread(\"http://www.foxhop.net/samsung/HL-T5087SA/red-LED-failure\")\r\n    >>> print bread.crumbs\r\n    >>> print bread.links\r\n    \r\n    \"\"\"\r\n    def __init__( self, url=None ):\r\n        if url: self.url = url # invoke url.setter\r\n        else: self._url = url  # set _url to none\r\n\r\n    @property\r\n    def url( self ):\r\n        return self._url\r\n\r\n    @url.setter\r\n    def url( self, url ):\r\n        if url.startswith( 'http://' ): url = url[ 7: ] # remove http:// if exists\r\n        if url.startswith( 'https://' ): url = url[ 8: ] # remove https:// if exists\r\n\r\n        self._url = url.rstrip('/')\r\n        self.crumbs = self._url.split('/')\r\n        \r\n    @property\r\n    def links( self ):\r\n        links = []\r\n        count = 0\r\n        for crumb in self.crumbs:\r\n            string = \"\"\r\n            for c in range( count + 1 ):\r\n                string = string + self.crumbs[c] + '/'\r\n            count += 1\r\n            string = string.rstrip('/')\r\n            links.append('<a href=\"http://' + string + '\">' + crumb + '</a>')\r\n            \r\n        return links\r\n\r\n**EXAMPLE OUTPUT**\r\n\r\n.. code-block:: python\r\n\r\n ['foxhop.net', 'os', 'linux', 'ubuntu']\r\n ['<a href=\"http://foxhop.net/\">foxhop.net</a>', '<a href=\"http://foxhop.net/os/\">os</a>', '<a href=\"http://foxhop.net/os/linux/\">linux</a>', '<a href=\"http://foxhop.net/os/linux/ubuntu/\">ubuntu</a>']\r\n\r\n \r\n\r\nGame DB Schema\r\n================\r\n\r\n.. code-block:: sql\r\n\r\n CREATE TABLE game (\r\n\tid VARCHAR(16) NOT NULL, \r\n\tuser1_id VARCHAR(16), \r\n\tuser2_id VARCHAR(16), \r\n\ttoken CHAR(1), \r\n\tturn_id VARCHAR(16), \r\n\twinner_id VARCHAR(16), \r\n\tcreatedate DATETIME, \r\n\tmodifydate DATETIME, \r\n\tboard BLOB NOT NULL, \r\n\tPRIMARY KEY (id), \r\n\tFOREIGN KEY(user1_id) REFERENCES user (id), \r\n\tFOREIGN KEY(user2_id) REFERENCES user (id), \r\n\tFOREIGN KEY(turn_id) REFERENCES user (id), \r\n\tFOREIGN KEY(winner_id) REFERENCES user (id)\r\n )\r\n\r\n CREATE TABLE user (\r\n\tid VARCHAR(16) NOT NULL, \r\n\tname VARCHAR(32), \r\n\temail VARCHAR(32), \r\n\tPRIMARY KEY (id)\r\n )\r\n\r\n\r\n\r\nGame DB Schema2\r\n================\r\n\r\n.. code-block:: sql\r\n\r\n CREATE TABLE game (\r\n\tid VARCHAR(16) NOT NULL, \r\n\ttoken CHAR(1), \r\n\tturn_id VARCHAR(16), \r\n\twinner_id VARCHAR(16), \r\n\tcreatedate DATETIME, \r\n\tmodifydate DATETIME, \r\n\tboard BLOB NOT NULL, \r\n\tPRIMARY KEY (id), \r\n\tFOREIGN KEY(turn_id) REFERENCES user (id), \r\n\tFOREIGN KEY(winner_id) REFERENCES user (id)\r\n )\r\n\r\n CREATE TABLE user (\r\n\tid VARCHAR(16) NOT NULL, \r\n\tname VARCHAR(32), \r\n\temail VARCHAR(32), \r\n\tPRIMARY KEY (id)\r\n )\r\n\r\n CREATE TABLE usergame(\r\n\tid VARCHAR(16) NOT NULL, \r\n\tuser_id VARCHAR(16), \r\n\tgame_id VARCHAR(16), \r\n\tPRIMARY KEY (id)\r\n\tFOREIGN KEY(user_id) REFERENCES user (id), \r\n\tFOREIGN KEY(game_id) REFERENCES game (id), \r\n )\r\n\r\n\r\n\r\nSome linux commands for server monitoring\r\n================================================\r\n\r\nhttp://www.shanghaiwebhosting.com/web-hosting-tips/a-few-useful-linux-ssh-commands-to-show-and-monitor-server-resources-memory-disk-usage\r\n\r\nuptime\r\n\r\ndf\r\n\r\nfree or free -m\r\n\r\nps -ef\r\n\r\nw\r\n\r\ntload\r\n\r\nlike it ?", "source_format": "rst", "revision_number": 28, "created": 1309297712000}}