Month: March 2013

formatting JSON in console


Advertisements

Installing gevent from source on Windows


only problems, no solutions

I was trying to install Gevent from source on my windows machine using virtualenv. So lets start from the beggining:


c:\Python27\python.exe virtualenv.py --distribute sandbox_gevent
sandbox_gevent\Scripts\activate
pip install gevent

Problems

 
As usual, problems are waiting to happen.

Downloading/unpacking gevent
Downloading gevent-0.13.8.tar.gz (300kB): 300kB downloaded
Running setup.py egg_info for package gevent
Please provide path to libevent source with --libevent DIR
Complete output from command python setup.py egg_info:
Please provide path to libevent source with --libevent DIR

Fix

libevent is missing so we have to install it. From source 🙂
Download https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz and unpack it. You don’t have to build this, it is only used by gevent in the build process.

Retry

 
pip install gevent --install-option="--libevent path\to\libevent\source"

Problems, again

 
Here it is again.

Downloading/unpacking gevent
Downloading gevent-0.13.8.tar.gz (300kB): 300kB downloaded
Running setup.py egg_info for package gevent
Please provide path to libevent source with --libevent DIR
Complete output from command python…

View original post 97 more words

The Triangle Project, initial and recursive


:: NickBurns

(follows from ‘Refactoring, the triangle project overview)

Through this series of blogs, I want to record my pythonic adventures and refactor my existing code to reflect my new skills. In the Triangle Project, I must develop some code to print the outline of a triangle. The triangle must be able to be printed either upright, or upside down.

Triangle v1.0:

triangle_v1

Hacking it up:   above is my first attempt to hack this up. It is quick and dirty, but does the job. Below, you will see my first attempt to refactor it using recursion.

Triangle v2.0

triangle_v2

Improvement from the initial hack (v1.0) to the recursive solution (v2.0):

To  be honest, using a recursive function does not actually make any difference to this program. It is not any more elegant or abstracted than a simple for loop could achieve. However, the script is about 20% shorter.

The real improvements in v2.0 include:

  • docstring

View original post 65 more words

Python: Dynamically Load Module and Call Functions


Architecture and Planning

I was looking through the videos for PyCon 2013 and there was a talk on Dynamic Code Patterns that caught my attention – because I don’t know what they are. I love the idea of loading plugins but have no idea how to write code that would allow for it. So, without watching the video yet, I took a shot at trying to write some code.

I started at David Janes’ Code Weblog to learn how to dynamically load code. I took his function for my code.

Then I wrote a simple python script with two functions and dropped it in a folder:

def hello(x): print “Hello, ” +x
def add(x): d=x.split(“,”) print int(d[0])+int(d[1])

My first attemt at loading a module and calling the function looked like this:

for (path, dirs, files) in os.walk(‘C:\\Documents and Settings\\user\\Desktop\\test’):
i=0
while(i<len(files)):

#print files[i]
a=load_module(‘C:\\Documents and Settings\\user\\Desktop\\test\\’+str(files[i]))
i+=1
a.hello(“Paul”)
print dir(a)

I load the…

View original post 266 more words

Extracting Data From MS-SQL TDS Streams in a libpcap File


Malware Musings

Sometimes in life you find yourself wanting to have a quiet afternoon in front of a computer, extracting login credentials and SQL commands from captured MS-SQL TCP connections. Other times you may find yourself needing to do so to analyse some MS-SQL attacks. Whatever your reason, this post explains how to use my parsetds.py script to extract such information.

View original post 1,113 more words

Product management vs. Project management


Semiconductor Product Marketing

Here is another interesting article about the difference between Product Manager and Project Manager. In some companies, Project Managers are known as Program Manager. I also know of one company that merge the two functions into the Product Manager role.

Product management vs. Project management : How To Be A Good Product Manager: Product management tips.

View original post

Implementing project work with the right contractor


kumiquarry

Introduction

: A Project work that delivers the desired result depends on the quality and efficiency of the raw materials supplied by the vendors. He cannot afford to shun away quality vendors just because they charge more than the others. This type of approach backfires most of time as the raw materials used for the project work are of inferior quality. He may be reluctant to go for the expensive vendors who would provide better quality of raw materials because it would exceed his budget. But it is advisable for the project manager to consider all factors before initiating a contract with the vendor.

Keeping all options open

Depending on a sole vendor for providing resources is not an ideal scenario for a project manager. Because a vendor may not deliver the desired results set by a project manager. So the project manager must keep all options open in…

View original post 249 more words