sandbox-2

sandbox-2

This is another sandbox for new users to test functionality

Mako template for city index

.. code-block:: mako

<%inherit file=“base.mako” />

<div class=“grid=”15”>

There are ${count} cities in ${state[‘name’].title()} to browse:


<% letters = ‘abcdefghijklmnopqrstuvwxyz’%>

% for letter in letters: % if cities[letter]: ${letter.upper()} % else: ${letter.upper()} % endif % endfor
% for letter in letters: % if cities[letter]: letter.upper() < /a >  < ul>{state[‘short’].lower()}/${city.replace(' ','-')}">${city.title()}
    % endfor
    </ul>
% endif

% endfor

breadcrumb algorithm

.. code-block:: python

class Bread( object ): ““” Create a list of URL parts or crumbs —————————————- >>> from bread import Bread >>> bread = Bread(“http://www.foxhop.net/samsung/HL-T5087SA/red-LED-failure”) >>> print bread.crumbs >>> print bread.links

"""
def __init__( self, url=None ):
    if url: self.url = url # invoke url.setter
    else: self._url = url  # set _url to none

@property
def url( self ):
    return self._url

@url.setter
def url( self, url ):
    if url.startswith( 'http://' ): url = url[ 7: ] # remove http:// if exists
    if url.startswith( 'https://' ): url = url[ 8: ] # remove https:// if exists

    self._url = url.rstrip('/')
    self.crumbs = self._url.split('/')
    
@property
def links( self ):
    links = []
    count = 0
    for crumb in self.crumbs:
        string = ""
        for c in range( count + 1 ):
            string = string + self.crumbs[c] + '/'
        count += 1
        string = string.rstrip('/')
        links.append('<a href="http://' + string + '">' + crumb + '</a>')
        
    return links

EXAMPLE OUTPUT

.. code-block:: python

[‘foxhop.net’, ‘os’, ‘linux’, ‘ubuntu’]

[‘foxhop.net’, ‘os’, ‘linux’, ‘ubuntu’]

Game DB Schema

.. code-block:: sql

CREATE TABLE game ( id VARCHAR(16) NOT NULL, user1_id VARCHAR(16), user2_id VARCHAR(16), token CHAR(1), turn_id VARCHAR(16), winner_id VARCHAR(16), createdate DATETIME, modifydate DATETIME, board BLOB NOT NULL, PRIMARY KEY (id), FOREIGN KEY(user1_id) REFERENCES user (id), FOREIGN KEY(user2_id) REFERENCES user (id), FOREIGN KEY(turn_id) REFERENCES user (id), FOREIGN KEY(winner_id) REFERENCES user (id) )

CREATE TABLE user ( id VARCHAR(16) NOT NULL, name VARCHAR(32), email VARCHAR(32), PRIMARY KEY (id) )

Game DB Schema2

.. code-block:: sql

CREATE TABLE game ( id VARCHAR(16) NOT NULL, token CHAR(1), turn_id VARCHAR(16), winner_id VARCHAR(16), createdate DATETIME, modifydate DATETIME, board BLOB NOT NULL, PRIMARY KEY (id), FOREIGN KEY(turn_id) REFERENCES user (id), FOREIGN KEY(winner_id) REFERENCES user (id) )

CREATE TABLE user ( id VARCHAR(16) NOT NULL, name VARCHAR(32), email VARCHAR(32), PRIMARY KEY (id) )

CREATE TABLE usergame( id VARCHAR(16) NOT NULL, user_id VARCHAR(16), game_id VARCHAR(16), PRIMARY KEY (id) FOREIGN KEY(user_id) REFERENCES user (id), FOREIGN KEY(game_id) REFERENCES game (id), )

Some linux commands for server monitoring

http://www.shanghaiwebhosting.com/web-hosting-tips/a-few-useful-linux-ssh-commands-to-show-and-monitor-server-resources-memory-disk-usage

uptime

df

free or free -m

ps -ef

w

tload

like it ?

test

.. code-block:: bash

(env)$ pserve development.ini

foxhop — Oct 08, 2010 04:58 pm

test

foxhop — Oct 08, 2010 05:23 pm

Another test

foxhop — Jun 02, 2011 01:59 pm

This is pretty sweet I think, and yes, I like it.

foxhop — Jul 08, 2011 07:29 pm

Thanks for that chooper <http://www.foxhop.net/account/chooper>_! I’m sure this will come in handy for somebody.