klenwell information services : SpecialCocktailNapkin

Revision [1036]

This is an old revision of SpecialCocktailNapkin made by KlenwellAdmin on 2009-03-14 10:16:35.
 

online cocktail napkin

links and notes for later organization
CocktailNapkin2008 2008 Napkin
CocktailNapkin2007 2007 Napkin
WordsIReallyLike
ThumbDrive

Array
(
	[op] => max supported int: 2^52 or 4503599627370496

	[bc] => max supported int >= 2^999 or 5357543035931336604742125245300009052807024058527668037218751941851755255624680612465991894078479290637973364587765734125935726428461570217992288787349287401967283887412115492710537302531185570938977091076523237491790970633699383779582771973038531457285598238843271083830214915826312193418602834034688

)




formencode state: http://wiki.pylonshq.com/display/pylonscookbook/The+other+FormEncode+manual+(UNFINISHED) (see bottom)
# in controller
class FormencodeState(object):
    """
    State class for formencode
    Although NOT well documented, to use the state argument in the to_python
    method in the context of schema that does complex, multistep validation,
    the state argument must be an object that formencode can hang additional
    attributes from, else you get errors like:
    Module formencode.schema:114 in _to_python        
    >>  state.full_dict = value_dict
    <type 'exceptions.AttributeError'>: 'dict' object has no attribute 'full_dict'
    "
""
    pass

...
Validator = SourceDataPreValidator()
ControllerState = FormencodeState()
ControllerState.source = 'csv'
Validator.to_python(DataValue, ControllerState)

# in validator
class SourceDataPreValidator(formencode.validators.FormValidator):
    """normalize data from either a form submission or a csv file upload and validate"""
    validate_partial_form = True
    def _to_python(self, value, state):
        """normalize csv input"""
        if state.source == 'csv':
            value['normal_data'] = self._normalize_csv_data(value.get('csv_import_file'), state)
        elif state.source == 'form':
            pass
        return value

    def _normalize_import_data(self, csv_file_string, state):
        NormalDataList = []
        ImportedLines = csv_file_string.split('\n')
        for i in range(len(ImportedLines)):
            ColValues = ImportedLines[i].split(',')
            fpre = 'csv_import-' + str(i)
            NormalDataList.append((fpre + '.id', str(ColValues[1])))
            NormalDataList.append((fpre + '.amount', str(ColValues[2])))
            NormalDataList.append((fpre + '.date',
                self._importdate_to_python_date(ColValues[4])))
        return NormalDataList

    def _importdate_to_python_date(self, datestr):
        """some code to convert a date string to object"""
        pass


http://www.phpied.com/3-ways-to-define-a-javascript-class/ / http://www.prototypejs.org/learn/class-inheritance
json class:
<script type="text/javascript">
function Speaker () {
    this.type = name;
    this.speak = function(message) {
        alert(message);
    };
}

function Machine(type) {
    this.type = type;
    this.Speaker = new Speaker();
    this.speak = function(message) {
        this.Speaker.speak(this.type + ' : ' + message);
    };
}
var iPod = {
    Speaker: new Speaker(),
    speak: function (message) {
        this.Speaker.speak(message);
    }
}

var iPhone = new Machine('iPhone');
iPhone.speak('support iTunes');

iPod.speak('hey, it worked!');
</script>

tax calculator calculations: http://www.sacbee.com/1098/story/1627728.html
# A couple calculations
# Income $30k / Car $10k
Not Married: $192 -> monthly increase: $16 (2 Trips to McDonalds)
Married: $192 
2 Kids: $612

# Income $100k / Car $25k
Not Married: $488 -> monthly: $40.67 (1 Video Game)
Married: $534
2 Kids: $954

# My actual numbers are somewhere in between

windansea 02.18 pm
/* background: color image repeat attachment position */
background: #FFCC66 url("file or url name") no-repeat fixed right bottom;

Plato's Symposium
mysqldump dbname | ssh user@remoteserver "cat - > dbname.db"
pastebin: Paste20090117 CakePhp Custom Pagination Methods
in case you missed 1978
perfect weather/dead oceancurrent
pastebin: Paste20090110 Klenwell CakePhp Form Helper
python regex (I could have sworn I pasted this here before):
import re

# compile
html = "'<html>\n<head>\n<title>Title</title>\n</head>\n</html>"
regex = re.compile('<.*?>',)
result = regex.search(html)
print result.group()

# ungreedy
html = "'<html><head><title>Title</title>"
print re.search('<.*?>', html).group()

# substitution
dirty = "some alphanum and some other ^$#%&*%!"
rgx = r'[^a-zA-Z0-9]'     # alphanum only!
clean = re.sub(rgx, '',  dirty)




CategorySpecial