25th October 2007, 01:34 pm
When I was hired on at my new job, I was apparently referred to internally as “the open source guy”. Now, that’s a moniker I don’t really mind because I do espouse the open source/free software philosophy and I definitely see it as being useful both from a personal standpoint and as a professional developer. Well the new gig heavily encourages knowledge-sharing and building of “intellectual capital” via presentations and such, so I thought that open source as a community, development strategy, and philosophy might be a worthwhile thing to share. So, this is my request for comments on ideas for what to present. But rather than just asking that question, here’s sort of what I had in mind.
First I’d have to do some definition/demystifying up front: answering the who/what/why’s and all that, because this is a heavy Microsoft crowd, though not so much that they are fanboys or anything like that (well, some might be but they likely won’t attend) it’s just what they know and that’s what the clients run on. I know at least a few people, including some of the partners, are genuinely interested in open source not only as a business strategy but as a community. So I think the first few big talking points in this section would be:
- What is open source? (I’d like to stick mostly with definitions here and not delve too much into history and/or the fractious issue of what constitues “free” or “open source” software)
- What open source projects they might be aware of, even if they don’t know they are open source (Linux, Mozilla, Java (yes, Java), PHP, Subversion, etc.)
- What open source projects affect them that they are likely unaware of (Apache, Python, MySQL, Mediawiki (wikipedia))
- Why open source? (Why do developers give away code? Why use it?)
And that would be the bulk of the presentation. From there I can come up with a more directed approach talking about how my company can leverage the advantages of open source to help increase productivity/add value/etc. Really I just wanted to hear what people thought about the first part and whether or not I was missing anything or perhaps should take some stuff out. Though if anyone has any feedback for what open source could mean for a small IT consulting firm, then by all means, fire away 
23rd October 2007, 11:09 am
In one forum I read, many people do not seem to know how to use the global keyword in Python. The most common misconception is that the declaration global foo will make foo global. That is wrong. global tells Python to use the global definition of foo instead of creating a local definition. Let’s see with an example.
>>> foo = "foo"
>>> def func1():
... foo = "bar"
... print "Inside func1():", foo
...
>>> def func2():
... global foo
... foo = "baz"
... print "Inside func2():", foo
...
>>> print foo
foo
>>> func1()
Inside func1(): bar
>>> print foo
foo
>>> func2()
Inside func2(): baz
>>> print foo
baz
>>>
In func1(), when I assigned the string bar to foo, Python created a new foo, local to func1() which shadowed the original foo. Which is why before and after the function call, the value of foo (the global one) was “foo”.
Inside func2(), I specifically told Python that I wanted to use the global value of foo, not create a new local one like I did in func1(). This is why the value of foo (the global one) is changed when we do print foo after the function call.
16th October 2007, 05:44 am
Attention fellow Grasshoppers, I need your input on a C function I wrote. As you may know, I’ve recently decided to give C a serious look. The first project I decided to write is a simple RPN calculator. Last night, I wrote a function to verify if a string is a valid number representation; I wrote a few test cases using assert() and it seems to work pretty well (speaking of testing, do you have any recommendations for testing frameworks/libraries for C?) I do find the code long however, and the last loop seems complicated. Here it is (let’s hope Wordpress doesn’t mess up the formatting):
int isnumber(char *s)
{
size_t i;
size_t len;
int period = 0;
/* Skip over white spaces. */
while (isspace(*s))
++s;
if (*s == '+' || *s == '-')
s++;
i = 0;
len = strlen(s);
if (len == 0)
return 0;
for (i = 0; i < len; ++i) {
/* Only one period is allowed. */
if (!period && s[i] == '.') {
period++;
}
else if (period && s[i] == '.') {
return 0;
}
/* Ignore everything after a space. */
else if (isspace(s[i])) {
return 1;
}
else if (!isdigit(s[i])) {
return 0;
}
}
return 1;
}
Let me know what you think and what could be improved. I’ll appreciate any input, whether it’s stylistic, functional, security-related, performance-related, etc.
15th October 2007, 12:17 pm
As you may know, I’m not that much of a fan of Microsoft technology, but understand that it’s somewhat unavoidable and allowing for the use of MS products greatly opens the prospects of employment/work. So, at my new gig I’m aware that a healthy chunk of time spent doing development will be using Microsoft tools and all the quirks that go along with them. Sometimes I’m pleasantly surprised, sometimes I’m reminded of why I dislike Microsoft products in general. Lately it’s been more of the latter.
On the current client I’m designing stuff for, we’re using MS SQL Server 2005’s SSIS toolchain, which is a great idea with mediocre execution. For those who are unfamiliar with SSIS, it’s basically the evolution of their DTS package that came with SQL Server 2000, which is designed to simplify the ETL process of getting data from a source (or various sources) into the destination database after all sorts of cleansing and transformation. The DTS package that shipped with SQL Server 2000 was apparently pretty warty, a trait that is common amongst first-gen Microsoft products, and so SSIS is apparently notably cleaner and nicer. But, as most of us are aware, that doesn’t mean it’s wart-free, and I’ve found a nasty wart or two.
Continue reading ‘Not a WTF, but certainly a wart’ »
3rd October 2007, 10:52 am
In Asterisk’s current state, it supports one RTP pool from which it selects a random pair of ports (RTP and RTCP) for each leg of a call. As part of a project at work, we need Asterisk to support multiple pools of RTP ports — specifically one pool for local calls and one pool for calls which have a leg on an external network. The reasoning behind this being that local calls only funnel their RTP traffic through Asterisk for a short amount of time and then the phones re-INVITE each other, cutting Asterisk out of the picture. Since there’s so little involvement with Asterisk for local calls, we’re ok with having a fairly large pool of RTP ports available (and therefore calls that can be initiated) without worrying about stressing our Asterisk system.
This isn’t the case when we have a call involving a remote leg, where all RTP traffic is running through the Asterisk system. Since we want to have a large RTP pool for local calls and RTP pairs are chosen randomly, we’re unable to simply use a firewall to limit how many connections can be made to the system. Doing so would risk having the external phone instructed to use a firewalled port and therefore lose half of the audio stream.
To address this, I submitted a patch for Asterisk to have a concept of two RTP pools. I left the current pool and its configuration alone and added the ability to optionally specify a “remote” pool. The patch comes in two parts. The first enables configuring the remote RTP pool (specified by the remotertpstart and remotertpend config vars in rtp.conf) as well as providing new functions to create an ast_rtp struct using the remote pool. By default, everything acts as before — the remote pool is the same as the local pool. The second part changes chan_sip to make use of the new remote RTP pool if it detects a remote leg and localnet/externip are set in sip.conf.
Since I think this functionality could be useful outside of my work environment and I’m fairly new to fiddling with Asterisk’s internals, I’d appreciate any feedback on the patch itself and/or actual usage of the feature. As implied above, my patches will only affect SIP calls. Support for other channels would have to be added (if it makes sense).
1st October 2007, 03:10 pm
To sort of go along with the fantasy football related programming post from earlier, I also like to do a set of “power rankings” for the NFL using a fairly simple but data-heavy formula that I derived via a bit of trial and error and really just some thought exercises. For the past season or so I just maintained it using a simple spreadsheet (at first Excel, then Gnumeric once I converted my laptop to Linux after getting the new job), but even when I was doing it I noticed data inconsistency which almost definitely resulted from data entry errors on my part. For example, part of the formula involves a teams “points for” (points they score against other teams) and “points against” (points other teams score against them). Well, when you sum up the “points for” for all the teams, and when you sum up the “points against” for all of the teams, you should get the same number. But sometimes I wouldn’t. Those errors weren’t quite as nefarious to track down as other things like in my strength of schedule calculations the total W-L record of one component should be the mirror opposite of another, but it would be missing some wins somewhere.
Continue reading ‘Back into the Django fray for a bit’ »