Archive for March, 2009

Mac OS X Finder SUCKS – could someone PLEASE make a tile utility?

Want to know the single thing I hate most about the Mac (besides the unexpected “spinning beach ball of death” that shows up every now and then)? It’s Finder. After using a Mac for almost a year and a half I still see Finder as terribly frustrating to use, and feel that it sucks the productivity right out of everything you do that involves file viewing and manipulation.

Basically, you can operate Finder in one of two modes.  The default is that when you click on a directory, the current Finder window opens the new directory.  So by default, you only have one Finder window open at a time.  You can specifically open more Finder windows but then you run into the same problem as I am about to describe.

The other mode is, when you click on a directory it opens a new Finder window.  You have to enable this mode in Finder’s preferences.

Either way, sooner or later you get multiple Finder windows on the screen (unless you close them after use, but what if you might want to go back to that window?).  And herein lies the problem:  After you have more than two or three Finder windows, they start to overlap. Pretty soon Finder windows get hidden behind other Finder windows and then you can’t find the window you want, or you click on the viewable portion of one window and suddenly it partially hides another you also need to see, etc. Then you start re-opening the same directory because you can no longer find the first Finder window you opened of that directory, which further compounds the problem.

So here is the utility I SO want, but have been unable to find anywhere:  It places a button in every Finder window’s top bar.  If you click on it, it tiles all open Finder windows so they fill the screen, but (optionally) closes duplicate Finder windows first (that is, if two or more windows are open on the same directory, it only leaves one of them open and closes all the others).  If you have two finder windows, they each take up half the screen.  If you have four, they each occupy one quarter of the screen.  It intelligently decides how large each Finder window should be, and places it on the screen so that it does not overlap any other Finder windows, but occupies the maximum space. Of course, if you have a ridiculous number open, such that each window would be microscopically small (even after closing all the duplicates), it should probably pop up a box that says that and gives you the option to close them all with one click.

The idea is, you click the button, and can immediately see that Finder window you know you opened 20 minutes ago.  You can also see all the other Finder windows you’ve opened, and close all those you know you are through with.  Then click the button again and the remaining Finder windows will fill the screen.

For bonus points: A closed Finder window history dropdown.  Keep track of recently closed Finder windows and (probably via a drop-down menu or a right-click menu) let you select one to re-open.

Has this just never occurred to anyone before, or is it that there’s something about Finder or the Mac that makes it impossible to create such a utility, or what?

EDIT: I usually welcome comments on posts. However, this post in particular seems to have attracted the attention of Mac fanboys who obviously neither understand what I am asking for, nor can be bothered to read all the previous comments before rushing to post their bit of idiocy.  So let me save you some time — if you are going to suggest anything related to Exposè or Spaces, neither of those will do what I’m asking here.  If you don’t understand why, feel free to read my responses to all the other commenters that have suggested the same thing. And if you insist on posting a suggestion to use Exposè or Spaces anyway, don’t be surprised if I call you an illiterate or a moron, or something equally unflattering. Unless you have a suggestion that does not involve using Exposè or Spaces, or want to make a comment that does not mention either of those pieces of software, please just mosey along — your comment is not welcome in this thread, because frankly I’m sick of responding to self-absorbed people who can’t even be bothered to read the other comments before posting theirs.

Comments (38)

Just something I wanted to pass along…

I read some consumer-oriented sites and blogs fairly regularly (if for no other reason than that telecommunications companies have been known to do decidedly consumer-unfriendly things at times, and those sites help me keep track of such abuses), but every now and then they take me down a path that leads to some real pearl of wisdom. And thus it was when I followed a link to a post entitled, The Consumer Overdraft Protection Fair Practices Act Needs Your Support – which is a site that encourages you to “Write your representative today to support Rep. Carolyn Maloney’s bill which will clean up this predatory lending practice that fleeces consumers of billions every year.”  And while that’s certainly a noble cause, and one I hope many folks will get behind, it’s not the thing that caused me to write this post.

Rather, it was a comment (or “signature”) on that page, from one Ani L. Schwartz of Arroyo Seco, NM, which said (in part):

If Consumers are not helped, the whole system will crash harder and faster. It is indeed what Jim Hightower calls “TERMINAL STUPIDITY” for Corporate Powers to kill their markets.Please work to END CORPORATE PERSONHOOD and the “legal person” status of Corporations which allows them to get away with Murder, literally and figuratively.

That was enough to cause me to click on the link associated with Ms. Schwartz’s name, where I found this posted on her “Comment Wall”:

I pledge to speak out to End Corporate Personhood as often as I have the ability & opportunity to do so.  The “legal person” status of Corporate “entities” must be revoked before WE (LIFE) can gain any ground towards HEALING.

In my own view, THIS is “the most pressing issue facing the country today” that I “would make the centerpiece of the address if [I] were President” NOW:

END CORPORATE PERSONHOOD

Ultimately pols & govs must join the People in efforts to free ourselves and our planet from the Chains, Catastrophes & Anti-Life IM-Balances of Corporatism, which are systematically destroying all life, liberty, & PURSUITS OF happiness, health, peace, education, wisdom, creativity, love, spirit, & all the things that really count in life to all living beings.   In order for vital changes to be possible,  the “legal person” status of Corporate “personhoods” must be revoked.   Until this is accomplished, Corporate “entities” will thwart all vital changes because these changes require that these “entities” GIVE BACK to the Universe upon which they depend for their inedible Profits.  

One need not agree with me about what is “the most important issue” in order to sign this pledge.

I’m not entirely sure whether Ms. Schwartz came up with this on her own, or if this is a new Internet meme, or what, but it makes me wonder what is taking so long for people to realize this simple truth:

Back in olden times, following the “great flood” and for at least a few thousand years thereafter, royalty held most of the power. And therefore, most of the oppression of the common folk came at the hands of the Kings and Queens, or whatever the ruling monarchs were called.

Then, for a time, religion held more power than royalty.  The Pope was more powerful than the Prince, and most of the oppression of the common folks came at the hands of religious leaders.

Neither of the previous two forms of oppression have totally gone away, but they are now being overshadowed by a third form of oppression – that is, oppression by large corporations, which operate largely above the law.

The problem is that we give corporations most of the rights and the legal status of an individual.  But when a corporation commits a criminal act, they can’t be punished in the way an individual can.  You can’t jail a corporation.  You can fine a corporation, but because large corporations have so much more in the way of resources than any individual, fines are largely ineffective (and are often thought of as a cost of doing business). Part of the very purpose for the existence of a corporation is to shield any individual from personal liability for the corporation’s actions. So if a corporation does something that causes real people to be injured or killed, it’s extremely rare for any individual to go to jail (and when it does happen, it’s often whichever poor patsy the corporate masters decided to throw under the bus, rather than take any responsibility for their own actions).

I’ve heard it said that the sort of people who would have set up an organized crime syndicate back in Al Capone’s day find it much more convenient today to set up a corporation, and run their scams from underneath a corporate shield.  It’s much more lucrative, and a lot safer for the people involved.  Instead of mobsters with tommy-guns doing the enforcement, now they hire high-priced lawyers.  Corporations sue each other (the upper-crust equivalent of mob warfare) but they also go after common people who don’t bend to their will.  Indeed, certain four-letter organizations that end in “AA” have been compared with organized crime in the way they bring lawsuits against the most defenseless (they seem to pick their victims carefully, although occasionally they do screw up and pick on the wrong person) and then demand the equivalent of “protection money” to stop bothering the party sued.  Since most of the accused don’t have the funds to mount a real legal challenge (they really DO seem to pick their victims carefully), it’s basically a choice between paying the “protection” or losing their financial life.

And I don’t want to pick on just one industry – the problem cuts across many industries. People die because pharmaceutical reps try to get (and too often, succeed in getting) doctors to prescribe the newest and most expensive durgs, rather than the old, tried-and-true drugs that work just as well (if not better), and have fewer toxic side effects.  People can’t afford the more expensive drugs, so they skip doses, or they have life-threatening problems with some side-effect of the newer drug. Now many physicians are forming “professional corporations” to try and limit their personal responsibility to they patients, and of course, virtually all hospitals are incorporated and many are now a part of some large corporate chain of medical facilities. Nowadays almost all hospital bills contain errors (often very significant errors), and they are nearly always in the hospital’s favor, so at a time when you should be worried about getting better you are burdened with the stress of dealing with an uncaring corporate hospital billing department (or worse yet, the collection agency that gets your bill when you can’t pay, which is also a corporation).

I could go on and on, but the point is, today virtually every oppression of ordinary citizens comes either at the hands of some large corporation directly, or because government is acting to protect some large corporate interest(s). Think about it – is there some law that you really hate, that you think should never have been passed? Assuming it wasn’t passed to bring more revenue into, or accrue more power for the government itself, the next most common reason a law is passed is to protect some large industry or corporation. Our governments often act as lackeys for the corporations.

Which brings me back to Ms. Schwartz’s “Comment Wall” – she has the right idea, although that’s only one of many reforms that should be passed – not just as laws, but as constitutional amendments.  I can think of three amendments that would go a long way toward ending most, if not all of the abuses of corporations:

1) All human beings are entitled to the rights accorded by this Constitution to persons, but such rights shall not be extended to non-humans.  The government shall not grant the rights of a person, or convey the legal rights of a person to any corporation or similar entity, or to any entity other than an actual human being.

2) No entity other than a human being, or a group of one or more specific human beings which are individually named, shall be granted ownership of any patent, copyright, or any other form of “intellectual property”, with the sole exception of a trademark.  A corporation or similar entity may own a trademark, but shall not be granted ownership of any other form of intellectual property. Nothing in this amendment shall prohibit the inclusion of intellectual property rights in the estate of a deceased person, provided that such rights may only be passed to other named individuals, and the inclusion of such rights in an estate shall not extend the term of the patent, copyright, or similar form of intellectual property.

3) In any case where a corporation or similar legal entity brings a lawsuit against one or more individual human beings, and does not obtain a judgment against that individual or individuals, the corporation must pay double the attorney fees incurred by the defendant to the attorneys that represented the defendant, and in addition must reimburse the defendant for any costs and lost income incurred by the defendant while defending the case.  If the individual’s life has been significantly altered as a result of the lawsuit, the defendant may petition the court for an additional award to compensate the defendant for any losses incurred. This amendment shall not be applicable in a case where a corporation or similar legal entity has brought a lawsuit against another corporation or similar legal entity.

I’m not a constitutional expert, so my wording might need to be polished a little.  I’d also like to see included prohibitions against undue influence by corporate lobbyists, and the use of “sock puppets” (individuals or non-profit organizations that are compensated in some way to represent the views of a corporation as if they were their own, usually without disclosing the Quid pro Quo), but have no idea how to word that sort of amendment in such a manner that it would not trample individual rights.

I seriously doubt there is any chance I will see any of these amendments passed in my lifetime, but who knows – if enough of these corporate abuses keep occurring, maybe one of these days we will see an anti-corporate backlash turn into a strong enough movement to get some very strong protections against corporate abuses passed into law.

In closing, I want you to think about this:

When our country was founded, we knew about the abuses of kings, and our constitution contains protections against giving any one individual too much power.

When our country was founded, we knew about the abuses of religious leaders, and our constitution contains protections against government unduly influenced by religion.

Neither of the above work perfectly, and they are sometimes ignored by Congress and the courts (to our detriment), but at least they are there.

As time went by, we’ve added other amendments to protect people (most notably forbidding slavery, and enacting civil rights, and giving the vote to all adults regardless of race, gender, etc.).  What we did not seem to realize, when our country was founded, was how powerful large corporations could become, nor how devoid of empathy and human compassion they could be. It is now time to reign in their power and to protect people from the abuses of large corporations, but they (the corporations) will not give it up easily.

Please don’t give the me the old bromide about how corporations are just individuals joined together for a specific purpose – in the first place, there are all sorts of studies that show that people behave much differently in large groups (particularly when they do not feel any individual responsibility for the actions of the group).  Think about suicide jumpers that are sometimes encouraged to jump by onlookers – chances are that if any of those onlookers was the only person there they would not open their mouth, but once one person yells “Jump!”, the crowd takes up the chant. Large groups of people are often devoid of the compassion that individuals would exhibit when alone, and this seems just as true (if not more true) when people think they are simply following the directives of their corporate employer.  And also, don’t forget that the specific purpose for which these individuals join together is to make a profit – in large corporations, everything else is secondary to that, specifically including the health and happiness of the people they deal with, or who deal with them.

I hope you will remember this article the next time you are feeling truly oppressed by forces outside your control – very often, there’s a large corporation (perhaps more than one) somewhere in the background, trying to advance their own financial interests. Even in cases where government is the oppressor, if you dig a bit deeper you’ll find corporations pulling the strings.

Take our drug laws as an example.  The alcohol, tobacco, and pharmaceutical industries all have a vested interest in keeping marijuana illegal – they fear the competition from another drug that’s probably every bit as safe as at least some of the substances they sell. And just so you know, I’ve never smoked pot in my life, not even once – but I still think the current laws against it are ridiculous and protectionist. There is no valid reason anyone should serve a long jail sentence over marijuana usage or possession for personal use – especially when our jails are so overcrowded that truly violent criminals are being released early. I don’t want anyone to use marijuana or tobacco, and I don’t want anyone to drink alcoholic beverages and drive (or drink to excess), and I’d rather not see anyone take dangerous but legal pharmaceuticals just because some corporation managed to get them approved (perhaps by withholding negative tests, and only showing the FDA the ones that didn’t indicate a problem). But only ONE of those substances is illegal, and classed as a felony to even possess – and it’s not the one that makes money for the large corporations!

I won’t even get into the corporate influence on organized religion – but think about what houses of worship were like a century or two ago, and what they are like today (especially the big super-mega-churches that have sprung up in the suburbs). There are large corporations that make huge sums selling goods both to the houses of worship themselves, and directly to the “sheep” – and a lot of that is the books and other literature (and in the modern age, DVD’s and other forms of media) that help shape people’s religious views, starting with Sunday School. I’m just waiting for one of them to start teaching that Jesus drove the moneychangers out of the temple because that space was better suited for a big box store – we’re not quite to that point yet, but I can pretty much guarantee you that the big corporations that publish church literature are not going to say anything negative about large corporations, so if you are involved in an organized religion you might want to give some thought about who is shaping your family’s views on modern life.

If you think there’s any truth in this article, please feel free to link to it. And, of course, you should feel free to comment (even if you disagree with me), as long as you don’t include any links that might make me think you are a spammer (if in doubt – leave the link out).

Comments (1)

Is this a case of thinly-veiled racism in Muskegon County?

To those of you outside of Michigan, please bear with me while I post about a Western Michigan issue.  Go read this story in the Muskegon Chronicle – it’s short (only four paragraphs) and to the point.

Muskegon County is a funny place.  There are places that are racially mixed, and people of different races seem to get along just fine.  But there are also places that are not so diverse.  It’s not exactly overt discrimination, it’s just that in certain neighborhoods you get the strong impression that if you are of the “wrong” race you might not get along so well with your neighbors. If you look at the county as a whole, I think that race relations are probably better than in some other Michigan counties, and if you don’t like diversity you probably shouldn’t be living there.  But that said, there are the neighborhoods that are mostly black or mostly white.  The Oakridge School District probably tends to fall into the latter category. Some of its neighboring districts have a much higher percentage of black students.

What bothers me about the article is that the Oakridge School District says that the policy (of not accepting students from other districts) is one of their “six points of pride.”  Which raises the question – why should any district be proud of any form of non-acceptance?  That ought to be a point of shame.  If the reason you can’t accept other students is that your schools are overcrowded, or that you can’t afford enough quality teachers, or any other valid reason I can think of, that’s no reason to be proud.  If, on the other hand, you are offering a quality education but you are afraid that a student from an adjacent district might want to take advantage of it, well, that sure sounds like it might be a case of thinly-veiled racism from where I sit, and that’s certainly nothing to be proud of.

As it happens, I’m white, but I see that there are good (and bad) people of all races. When I was younger, I had hoped that my generation would be the one that would eradicate the scourge of racism from our nation.  Well, we’ve certainly come a long way, but then you see things like this which in my opinion are a step backward. It seems to me that the Oakridge School District has some explaining to do, and if they don’t want to explain, then they should understand that some people will perceive them as racist bigots trying to keep their schools as white as possible. And even if it turns out that they have a valid reason for not accepting “schools of choice” students, they probably ought to re-think calling it a point of pride.

Comments (1)

PHP-CLI vs PHP-CGI (from Packt Publishing)

The following article was provided by Packt Publishing, and is an excerpt from their book “Asterisk Gateway Interface 1.4 and 1.6 Programming” (you will note a couple of embedded ads in the article). I don’t plan on publishing something like this very often, because usually when someone else provides HTML code it doesn’t always translate well to WordPress format (and you will doubtless notice some glitches in the formatting here), but also because it’s not my intent to make this a commercial blog. I will disclose up front that they’re sending me a complementary copy of the book (I haven’t received it yet, but assume it’s in the mail), but there was no “quid pro quo” involved – they simply provided the article and said that if I thought it might be of interest to my readers, I was free to publish it.

I’m NOT currently a PHP coder, but I suspect that many of the readers of this blog do code in PHP, and therefore could benefit from this article. And even I learned something – I’ve written a couple of rather insignificant Perl AGI scripts in the past, but had no idea how to do AGI debugging from the Asterisk CLI, and that’s explained at the end of this article. If an article like this is not your cup of tea, feel free to skip it, but if you ever write AGI scripts in Asterisk (or have wanted to) I think you will find this interesting.

PHP-CLI vs PHP-CGI

Most Linux distributions include both versions of PHP when installed, especially if you are using a modern distribution such as CentOS or Mandriva. When writing AGI scripts with PHP, it is imperative that you use PHP-CLI, and not PHP-CGI.

Why is this so important? The main issue is that PHP-CLI and PHP-CGI handle their STDIN (standard input) slightly differently, which makes the reading of channel variables via PHP-CGI slightly more problematic.

The php.ini configuration file

The PHP interpreter includes a configuration file that defines a set of defaults for the interpreter. For your scripts to work in an efficient manner, the following must be set-either via the php.ini file, or by your PHP script:

ob_implicit_flush(false);
set_time_limit(5);
error_log = filename;
error_reporting(0);

The above code snippet performs the following:

Directive

Description

ob_implicit_flush(false);

Sets your PHP output buffering to false, in order to make sure that output from your AGI script to Asterisk is not buffered, and takes longer to execute

· set_time_limit(5);

Sets a time limit on your AGI scripts to verify that they don’t extend beyond a reasonable time of execution; there is no rule of thumb relating to the actual value; it is highly dependant on your implementation

Depending on your system and applications, your maximum time limit may be set to any value; however, we suggest that you verify your scripts, and are able to work with a maximum limit of 30 seconds.

· error_log = filename;

Excellent for debugging purposes; always creates a log file

· error_reporting(E_NONE);

Does not report errors to the error_log; changes the value to enable different logging parameters; check the PHP website for additional information about this

AGI script permissions

All AGI scripts must be located in the directory /var/lib/asterisk/agi-bin, which is Asterisk’s default directory for AGI scripts. All AGI scripts should have the execute permission, and should be owned by the user running Asterisk. If you are unfamiliar with these, consult with your system administrator for additional information.

The structure of a PHP based AGI script

Every PHP based AGI script takes the following form:

#!/usr/bin/php -q
<?
 $stdin = fopen(‘php://stdin’, ‘r’);
 $stdout = fopen(‘php://stdout’, ‘w’);
 $stdlog = fopen(‘my_agi.log’, ‘w’);

 /* Operational Code starts here */
 ..
 ..
 ..
?>

Upon execution, Asterisk transmits a set of information to our AGI script via STDIN. Handling of that input is best performed in the following manner:

#!/usr/bin/php -q
<?
 $stdin = fopen(‘php://stdin’, ‘r’);
 $stdout = fopen(‘php://stdout’, ‘w’);
 $stdlog = fopen(‘my_agi.log’, ‘w’);

 /* Handling execution input from Asterisk */

 while (!feof($stdin))
 {
 $temp = fgets($stdin);
 $temp = str_replace("n","",$temp);
 $s = explode(":",$temp);
 $agivar[$s[0]] = trim($s[1]);
 if $temp == "")
 {
 break;
 }
 }

 /* Operational Code starts here */
 ..
 ..
 ..
?>

Once we have handled our inbound information from the Asterisk server, we can start our actual operational flow.

Communication between Asterisk and AGI

The communication between Asterisk and an AGI script is performed via STDIN and STDOUT (standard output). Let’s examine the following diagram:

In the above diagram, ASC refers to our AGI script, while AST refers to Asterisk itself.

As you can see from the diagram above, the entire flow is fairly simple. It is just a set of simple I/O queries and responses that are carried through the STDIN/STDOUT data streams.

Let’s now examine a slightly more complicated example:

The above figure shows an example that includes two new elements in our AGI logic—access to a database, and to information provided via a web service. For example, the above image illustrates something that may be used as a connection between the telephony world and a dating service. This leads to an immediate conclusion that just as AGI is capable of connecting to almost any type of information source, depending solely on the implementation of the AGI script and not on Asterisk, Asterisk is capable of interfacing with almost any type of information source via out-of-band facilities.

Enough of talking! Let’s write our first AGI script.


Asterisk Gateway Interface 1.4 and 1.6 Programming
Asterisk Gateway Interface 1.4 and 1.6 Programming Design and develop Asterisk-based VoIP telephony platforms and services using PHP and PHPAGI

  • Develop voice-enabled applications utilizing the collective power of Asterisk, PHP, and the PHPAGI class library
  • Learn basic elements of a FastAGI server utilizing PHP and PHPAGI
  • Develop new Voice 2.0 mesh-ups using the Asterisk Manager
  • Add Asterisk application development skills to your development arsenal, enriching your market offering and experience
  • Up to date for Asterisk version 1.6 and covers all previous versions

http://www.packtpub.com/asterisk-gateway-interface-programming/book


The AGI Hello-World program

Just as with any other programming language, we shall begin our journey with a simple “Hello-World” AGI script.

In order to make our life easier, we shall use an astRead function and an astWrite function that will help us read and write information, to and from Asterisk in a more efficient manner.

function astRead()
{
 global $stdin, $debug, $stdlog;
 $input = str_replace("n", "", fgets($stdin, 4096));
 if ($debug) fputs($stdlog, "read: $inputn");
 return $input;
} 

function astWrite($agiCommand)
{
 global $debug, $stdlog;
 if ($debug) fputs($stdlog, "write: $agiCommandn");
 echo $agiCommand."n";
}

The astRead function reads information from a global variable, indicated by the $in variable. The $in variable will simply indicate our STDIN stream. The astWrite function writes its $agiCommand directly to STDOUT, simply passing the AGI command directly to Asterisk.

Let’s combine everything together:

#!/usr/bin/php -q
<?
 ob_implicit_flush(false);
 set_time_limit(6);

 $stdin = fopen(‘php://stdin’, ‘r’);
 $stdlog = fopen(‘my_agi.log’, ‘w’);

 $debug = false;

 /* Read input from Asterisk and output via $astOutput */
 function astRead()
 {
 global $stdin, $debug, $stdlog;
 $astOutput = str_replace("n", "", fgets($stdin, 4096));
 if ($debug) fputs($stdlog, "read: $inputn");
 return $astOutput ;
 } 

 /* Write AGI command to Asterisk */
 function astWrite($agiCommand)
 {
 global $debug, $stdlog;
 if ($debug) fputs($stdlog, "write: $agiCommandn");
 echo $agiCommand."n";
 }

 /* Handling execution input from Asterisk */

 while (!feof($stdin))
 {
 $temp = fgets($stdin);
 $temp = str_replace("n","",$temp);
 $s = explode(":",$temp);
 $agivar[$s[0]] = trim($s[1]);
 if ($temp == "")
 {
 break;
 }
 }

 /* Operational Code starts here */

 ..
 ..
 ..

 /* Finalization of AGI script and clean-ups */

 fclose ($stdin);
 fclose ($stdlog);
 exit(0);

?>

In order to execute our AGI script, we are required to define an extension in our extensions.conf configuration file, and indicate the execution of our script from there. The following is an extract from the”default” context of my Asterisk server. You may insert these into any other context or extension, depending on your Asterisk server configuration:

exten => 999,1,Answer
exten => 999,n,Wait(0.5)
exten => 999,n,AGI(helloworld.php)
exten => 999,n,Hangup()

This code snippet will add a new extension named 999 to your dialplan. When this extension is dialed, your AGI script will be invoked. As your script is executed, the following can be observed on the Asterisk CLI console:

Note that as your AGI script is being executed, the only thing you will see on the CLI is the result of the AGI command, and not the actual execution of the AGI script. Also note that CLI output may vary, depending on your configuration.

AGI debugging

Asterisk provides a means of debugging AGI Scripts as these are executed. In order to use the AGI debugger, you need to have access to Asterisk’s CLI interface, and issue the following command:

agi debug

As your script is executed with debug mode enabled, your CLI output would look like this:

As you can see, the example in the preceding screenshot shows the full execution of the AGI script, including the initial information sent from Asterisk to the AGI script. Information traversing from Asterisk to our AGI script is prefixed with the AGI Tx >> marking, while information from our AGI script to Asterisk is prefixed with the AGI Rx >> marking. Although this may look weird, it is perfectly logical when examined from Asterisk’s point-of-view.

Disabling AGI debug mode is done using the command:

agi debug off

If you have enabled AGI debugging, it is imperative that you turn it off once you have completed your debug session. Debug mode outputs much information to the Asterisk console and log files, causing your Asterisk performance to be degraded.

Summary

Congratulations! You have just written your first Asterisk AGI script. While the example that we saw previously was shown using the PHP scripting language, I am confident that you will be able to translate these examples into the programming language of your choice.

If you are an experienced programmer, then I urge you to implement something different with AGI. If you are familiar with the activation of web services via CURL, try to write an AGI script to read information(like the weather) from a website and to read it out. Another option is to interface your AGI script with a database, create a username/password IVR script, and let your imagination go wild!


Asterisk Gateway Interface 1.4 and 1.6 Programming
Asterisk Gateway Interface 1.4 and 1.6 Programming Design and develop Asterisk-based VoIP telephony platforms and services using PHP and PHPAGI

  • Develop voice-enabled applications utilizing the collective power of Asterisk, PHP, and the PHPAGI class library
  • Learn basic elements of a FastAGI server utilizing PHP and PHPAGI
  • Develop new Voice 2.0 mesh-ups using the Asterisk Manager
  • Add Asterisk application development skills to your development arsenal, enriching your market offering and experience
  • Up to date for Asterisk version 1.6 and covers all previous versions

http://www.packtpub.com/asterisk-gateway-interface-programming/book


Comments (1)

Two reasons I won’t follow you on Twitter

This morning, some cnet news writer who obviously has way too much time on his hands published an article suggesting that you should follow everyone on Twitter that follows you. He even suggested it might be a breach of etiquette not to follow your followers. My response: That’s crazy talk. And if it really is Twitter etiquette, then f*ck etiquette, because I’m not going to do it. Never have, never will, and if you don’t like it you can damn well unfollow me and I don’t give a crap.

There are two main reasons I won’t follow someone on Twitter:

First, they got sucked in by the question “What are you doing” and think that anyone really cares (outside of, perhaps, their immediate circle of family and friends). I suggest that if you really have a compulsion to Twitter every insignificant detail of your pathetic life, that you set up two Twitter accounts. Use the first to get the tweeting out of your system – maybe you can get your mom and your siblings to subscribe, but unless you are some kind of celebrity I doubt many others will. There are exceptions to this – people who understand that you have to tweet about things that are interesting to others to build a following – but a lot of twits think that if they just had a good cup of coffee or are riding in an elevator or taking a dump on the commode, that’s worth tweeting about. I don’t care, and I won’t follow you if you do that. So put that stuff in your “close friends and family account” (though you may want to omit the bathroom details in any case) and save the interesting stuff for your general Twitter account.

The second is that, when someone starts following me I go to their Twitter page to see if I want to follow them, and the entire page is @replies. I don’t want to read your private conversations, and I surely don’t want to read half conversations. If you are using Twitter as though it were an IRC channel (that’s “Internet Relay Chat” for you young’uns) then it’s highly unlikely I will follow you. Most of those conversations should be sent as DM’s (direct messages).

Why WOULD I follow you? If you do what I do, and post a lot of interesting links to subjects that I’m interested in. Look, I don’t have the time or interest to use one of those social link services, but every so often I come across someone who seems to have fairly mutual interests, and who doesn’t tweet about the insignificant details of their daily life. In other words, I tend to follow news sources, though not all of it is mainstream news (this doesn’t mean I necessarily believe everything I see on the “offbeat” feeds either – I read some things for sheer entertainment value).

I think that at first, Twitter had a “cool” factor that was last seen when Instant Messaging services first appeared. I can remember when ICQ was the cool new thing – in many ways it was the Twitter of a decade ago. At first it was great to be able to hear from your friends in real-time, especially in the days when most of us were still paying by the minute for long distance calls, and relatively few of us had broadband connections, and cell phones, for those who could afford them, were only phones (used for voice communications). But as we found out back then, ICQ could become intrusive – many of us didn’t want to drop what we were doing whenever someone on our Buddy List felt like chatting. I think that with Twitter, what many are finding is that it’s a time sink, and one way to cut the time wasted is not to follow people who waste your time by Tweeting about things you don’t care about.

One thing that appalls me, as a Mac user, is that there are no great tools for dealing with the Twitter flood. I’ve tried several Twitter clients for the Mac and don’t really like any of them, though I keep coming back to Twhirl (which isn’t really a Mac-specific program since it runs under Adobe Air). What I really WANT is a Twitter client with great filtering capabilities, so that (for example) I can look at Tweets that contain links separately from those that don’t, or separate out Tweets from close friends and associates so I can read those without having to wade through everything. My ideal Twitter client would have tabs across the screen and give me the ability to sort which tweets go into which tabs (think e-mail filtering, but for Twitter). If I had that I might follow a few more people (those who occasionally post great links, but also post a lot of stuff I don’t care to see).

I know people who won’t touch Twitter with the proverbial ten-foot pole, and I was like that until I discovered that Twitter can be an interesting news and information source if you are VERY selective about who you follow. I don’t use Twitter for social networking – if you want to use it that way, that’s fine but don’t be offended if I don’t follow you. Or be offended, I really don’t care, but I still won’t follow you. And I’m not begging anyone to follow me either – why on earth would you want to follow me if I’m tweeting about things that don’t interest you?

So if someone ever writes a book on Twitter etiquette and suggests that you should follow everyone who follows you, I suggest that you don’t buy that book, because the author doesn’t know what the hell they are talking about. I don’t want to spend my entire life gazing at a computer screen – I spend too much time there already and don’t need to be reading all the crap in the Twitter stream. That’s just my opinion on the subject, but I’ll bet a lot of Twitter users would agree with me on this.

Comments (2)

The true beginning of wideband telephony adoption?

Those of us who are old enough to remember Sprint’s “pin drop” commercials are painfully aware that although telephone connections are, for the most part, clearer than in the old days of analog microwave and vacuum tube repeaters (the exception being cell phone connections, which still sound like crap to me), the bandwidth allotted to voice communications is still restricted to somewhere in the 3-4 kHz range… barely adequate to pass speech, which is why you often have to ask people to use phonetic spellings when spelling out a word (“is that F as in Frank, or S as in Sam?”) and why music-on-hold sounds pretty terrible.

Recently there have been efforts made to promote wideband telephony, but the big problem is that in VoIP, we are still at the stage where the people doing most of the work are generally underpaid, and the economy in general is in the tank, and for that reason most people aren’t going to shell out real money to pay for codecs.  If you doubt this, look at the low adoption rate for G729 – Digium licenses it on a per-channel basis and a lot of users say “why bother?” and just use the free codecs (and many who do use G729 do so only because they found a site in a former Soviet-bloc country where the copyright on G729 apparently either doesn’t apply, or isn’t enforced… but I suppose we should not talk about that).  And G729 has been around through relatively good times, unlike the times we are in now.

While there are G722 wideband codecs available, there are several different “flavors”, and none of them have been truly well received (though I suppose that’s a matter of opinion).  Now Skype has come along and made an announcement that might change everything – Jonathan Christensen, Skype’s General Manager for Audio and Video, has posted the following:

Today marks a significant moment in the journey of Skype. Some of you may be aware of the SILK speech codec which is included as part of Skype 4.0 for Windows – it’s what enables super-wideband audio and optimizes call quality, even in low network bandwidth environments. It transforms sound quality for Skype calls, and if you haven’t already tried 4.0, believe me: you should.

I’m speaking at eComm today, and have some very special news to bring our developer community – we’re making the SILK speech codec available for a royalty free license by third-party software and hardware developers soon.

What does this mean for the future of audio on the web?

SILK is Skype’s signature super wideband audio codec which achieves super wideband audio quality using 50% less network bandwidth than previously required. It is the outcome of a three year long development process in the Skype labs, which focused on four things:

  • improving audio bandwidth going from 8 kHz to 12 kHz, meaning that a SILK conversation sounds like you are in the same room as the person you are speaking with
  • providing real-time bandwidth scalability to deal with degraded network conditions
  • balancing codec optimization between voice, music and background noise, each of which can have an impact on the overall user experience
  • delivering a robust solution that delivers a more consistent audio experience, regardless of network conditions and an individual user’s voice signature

Making SILK available opens the door to its adoption as the standard across a huge range of platforms, applications and devices by web developers and chip manufacturers, as well as consumer electronics and mobile device manufacturers. By offering it for free, we are removing one of the biggest hurdles to adoption of wideband audio: cost. By doing so, I hope we’ll establish a new industry-wide standard in speech processing: clearer, richer, and warmer audio.

When can I get my hands on the code?

We are still working on the details but for more information about SILK, please visit our SILK website.

Not being a developer myself, it’s sometimes hard to predict what will inflame the passion of developers, but with the wide installed base of Skype users out there, plus the recent introduction of the SipToSis software that allows one to make an Asterisk/Skpe gateway (and information on how to set up a Skype gateway for FreePBX users) it’s possible this just might catch on, particularly if a SILK codec is developed that installs and is usable in current versions of Asterisk. And if it does, I give it maybe a decade or so (hopefully a lot less!) before wideband telephony is ubiquitous (except maybe for cell phone calls – I sometimes think the cell companies want users to have to repeat things often, so they use up more minutes!).

We’ll see if this is the start of something big or another flash in the pan, but my hope would be that once this codec is available, companies that make IP phones and VoIP adapters would release updated firmware that includes this codec (many phones already include codecs that hardly anyone uses, perhaps they could dump one or two of those to make room for SILK if they are short on memory space) so that existing equipment could also use it. It will be interesting to see how the VoIP software makers and equipment providers react to this announcement.

Comments (2)

Another Mac Annoyance Solved: Right Zoom 1.0

Right ZoomOne thing that I found frustrating as a Windows user switching to a Mac was that the green button on an Application’s titlebar didn’t work as I would expect – that is, it didn’t make the app expand to fill the full screen.  I don’t know about anyone else, but I find multiple open windows to be very distracting.  I see some guys with five or ten open windows on their desktops and think that would drive me crazy – it’s just way too much clutter.

So I was more than just a little happy to come across this new free app on the MacUpdate site: Right Zoom 1.0 – Created for people who don’t like default behaviour of green Zoom button. It’s described this way:

Right Zoom utility is created for people who don’t like a default behaviour of the green Zoom button in Mac OS X programs. This small program changes its behaviour, so a green button will always maximize your windows to all available screen space instead of inconvenient resizing.

The program changes a behaviour of Finder and Safari – these two applications are most annoying examples of inconvenient zoom button behaviour. You can easily extend this list with your own applications.

To extend the list you have to open the /Applications/RightZoom.app/Contents/Resources/Applications.xml file and then add the apps you want, save the file, go to a terminal window and type killall RightZoom to stop any currently running instance of the program, then restart it.  I hope in the future they might consider something that makes it a bit easier to add applications (or, alternately, a way to specify that you want to apply this behavior to all of your applications except those on an exclusion list), but this is only version 1.0 so I’ll hope for future improvements. Edit: As of version 1.61, you now can apply this behavior to all of your applications except those on an exclusion list. This program has come a long way since version 1.0.

Now if only someone would come up with an application that would resize and tile all your open Finder windows with one click (so that no Finder window overlaps another) – it might actually change might opinion of Finder from hate and loathing to mere tolerance.  :-) (Edit: See my related post: Mac OS X Finder SUCKS – could someone PLEASE make a tile utility?)

Leave a Comment