WOW, the top answers to this question are amazingly useful

One quick example
Instead of

  if x > 10 and x < 100:
       print "Match"

You can do…..

   if 10 < x < 100:
       print "Match!"

In my opinion, that’s very snazzy.

http://stackoverflow.com/questions/101268/hidden-features-of-python

 

Keep end up going back to this answer repeatedly as I keep forgetting to snapshot a clean slate PHP5 dev. VM.

http://superuser.com/questions/55055/how-to-install-an-updated-version-of-pear-phpunit-on-ubuntu/55072#55072

 

One of my clients has a PHP5.1 environment that was originally configured by a band of rabid monkeys snorting meth. Finally got approval last week to clean slate everything. Unfortunately I’m still stuck with PHP5, but version 5.33 instead. Next hurdle was the other side of the department that is doing something completely unrelated to my side wanted to use Zend Framework. Honestly I was interested in spending some time with ZF but only as a resume bullet and thats not exactly right or fair to my client.

That said, it’s Doctrine 2 and Kohana 3, full speed ahead. In the grand scheme of things, its frustrating as hell to work with PHP5 when there is so many nice things out there like Python, C#, Ruby, and did I mention Python?

Lastly, kudo’s to Flynsarmy for doing the leg work to integrate the two major frameworks into one tidy little package.

Link to blog post ( download links is on there, should read this blog post as it explains how to install it, it’s free, and this guy or girl put in some quality work and deserves your 2-4 seconds of attention ) here

http://www.flynsarmy.com/2010/12/better-doctrine-2-module-for-kohana-3/

Doctrine 2

 Uncategorized  Comments Off
May 102011
 

I’ve been looking at upgrading one of my past clients from Doctrine 1 to Doctrine 2 and so far it’s looking from my end like a done deal.

I started here by paging through this ( http://www.slideshare.net/jwage/doctrine-2-not-the-same-old-php-orm ) slideshare on Doctrine 2 and before I got bored with paging through 94 slides I already had a warm fuzzy feeling.

My initial tests have shown that Doctrine 2 without a doubt needs support from APC or memcached, but with the exception my few and far between dumb/cheap client’s is almost guaranteed to be present. Otherwise I like the decidedly simpler syntax for defining domain models as simple classes without inheriting some super support class.

Last bit, my stackoverflow answers regarding doctrine 2 so far
http://stackoverflow.com/questions/5954618/does-doctrine-2-0-pre-generate-model-classes-like-propel-1-5-does/5955400#5955400

 

I’ve been writing class/method level documentation and ideally plan to make a step by step explanation of what the heck is going on inside the Ping toolset. Until then it’s pretty doubtful anyone will want to use it. Never mind everything is still in Alpha state and there is very little guarantees that something won’t be written.

Eh

 Uncategorized  Comments Off
Mar 062011
 

First thing I do after getting a new Ubuntu server running

#apt-get install vim -y

Not sure what its called, but the default vi install isn’t friends with putty and neither am I.

Feb 192011
 

http://github.com/devdave/DevDave-s-miscellanious-bucket

Includes: The complete mako Auto-render logic class + decorator for cherrypy and a proof of concept idea I am still working on to implement the command pattern in Python.

 

I’ve been using PHP off and on as a language since sometime in the late 90′s when it was just PHP ( and not even PHP3 ). To be fair, the language has come a long way and beaten out some well financed rivals ( ASP & Coldfusion for example ) but it has also suffered along the way in the quality of it’s source code.

For the last 5 years, I’ve occasionally stared at PHP’s C macro-soup and soon after promptly stopped. My first real programming language was C when I was eleven years old, I know C like an old friend, but PHP’s source code is not C. It’s the dark side of C, a meta-language built on top of C via a fairly deep interdependent network of macro’s, defines, typedef’s, linked structs, and shit I didn’t know you could do with C.

Oh yeah and most of that crap is extremely terse, not documented, and inconsistently arranged. If I had a client who asked me to maintain PHP, I’d probably smile and every so carefully walked backwards out of the room. Really I must say I am impressed with PHP’s dedicated staff and volunteer engineering team. I don’t know how the hell they do it.

That said, I’ve been trying out various c/c++ IDE’s for linux and continually dissappointed. Code Lite seemed nice but its unworkable workspace idealogy pissed me off, Kdevelop is good but lacking in features, and etc etc. Recently I’ve had to do some Java code ( I’ve got a borderline irrational hatred towards the language since the 90′s ) and after trying IntelliJ for a day or two, I went back to the IDE I first used to learn Java… NetBeans. I’ve got to say, Netbeans has gotten a lot better since I last used it 12 years ago. And one of the things it has gotten really good at, is being a c/c++ IDE.

The IDE’s macro resolution and code intelligence features probably helped me jump years of effort into the future for understanding PHP by providing a macro resolution feature that visually converts the PHP meta language source code back into C. Whole sections of the languages design, construction, and its philosophy all became self-evident to me in the space of three hours.

Which leads to the end of this post, information maybe power… but only if it can be recognized as information and not noise… or in the case of PHP, a code base written by an infinite number of PCP snorting monkeys.

 

Usage: $~/looper runSomePythonScript.py

#!/usr/bin/python
import subprocess
import time, sys
 
PYTHON = '/usr/bin/python'
 
def main():
    commands = [PYTHON]
    commands.extend(sys.argv[1:])
 
    print "Looping %s" % commands
    while True:
       subprocess.call(commands)
       print "4 seconds to restart"
       time.sleep(2)
 
 
if __name__ == "__main__":
    main()
Jan 182011
 

When writing maps/reduce functions for couch, its tedious to make a change, jump to the server console, push the code, then call the map/reduce via a web browser or curl. So I figured, cut at least 1 step out of the whole process and just page back and forth from the IDE to the browser while a tail of the couchdb error log spins by on a 2nd monitor.

import os
from os import path
import time
from stat import ST_MTIME
manifest = dict()
import subprocess
 
while 1:
    time.sleep(3)
    print "Scanning"
    for root , dirs, files in os.walk("./_design/"):
        for file in files:
            filepath = path.join(root,file)
            mtime = os.stat(filepath)[ST_MTIME]
            if not filepath in manifest:
                manifest[filepath] = mtime
            else:
                if mtime > manifest[filepath]:
                    print filepath, "is stale, updating."
                    subprocess.call(["/usr/bin/python", "push.py"] )
                    manifest[filepath] = mtime
© 2012 Refactored scope Suffusion theme by Sayontan Sinha