quickie: creating symfony delete button

January 15th, 2010

Many months ago I had asked for help on the symfony forums on how to create a delete button using either the link_to() or button_to() method. I had tried but was always getting validation errors. Today a person asked whether anyone had figured out a solution. It prompted me to do more research into symfony’s core code and found a solution (though the solution wasn’t in the core code).

Original delete text link code:

echo link_to(
	'Delete',
	'state/delete?id='.$form->getObject()->getId(),
	array('method' => 'delete', 'confirm' => 'Are you sure?')
);

New delete BUTTON link code:

echo link_to(
	'<button>Delete</button>',
	'state/delete?id='.$form->getObject()->getId(),
	array('method' => 'delete', 'confirm' => 'Are you sure?')
);

Till Next Time

quickie: setting symfony datetime default

January 6th, 2010

Setting the default value for a symfony form field is one of those tasks so simple that it’s impossible to find out how to do it without a good bit of trial and error.  So without further ado, here is how to set a DateTime field’s default value:

$this->widgetSchema['start_time']->setDefault(date("m/d/Y", now()));

Till Next Time

updating symfony form values after submitting

January 1st, 2010

One thing that’s made programming on symfony very aggravating has been dealing with the forms.  Some sections of the forms are not well documented.  The main issue that I have with this at work is that we deal with GPS coordinates and the users enter their coordinates in degree-minute-seconds format but the database saves them in degree-decimal format.

I had googled for a solution to this problem before, but had not found anything to guide me to the answer.  The couple answers I had found were not very clear on getting it to work.  Till I found this.  Following these guidelines I got it to work on a test deployment of symfony.  Code below:

class Blog extends BaseBlog {
 
	/**
	 * Initializes internal state of Blog object.
	 * @see        parent::__construct()
	 */
	public function __construct()
	{
		// Make sure that parent constructor is always invoked, since that
		// is where any default values for this object are set.
		parent::__construct();
	}
	/*
	 * this function overrides the BaseBlog::save function to allow
	 * changes to be made to the object before saving to the database
	 */
	public function save(PropelPDO $con = null)
	{
		$this->setCommentCount('11');
		return parent::save($con);
	}
 
}

Till Next Time

updating centOS 5 PHP install with mbstring & APC

December 22nd, 2009

The default install on A2hosting’s VPS does not have mbstring or APC installed by default.  I became aware of this as I was setting up symfony on the new server.  I googled around looking for a quick guide to install them.

mbstring is a straight-forward install:

yum install php-mbstring

Easy.

Installing APC is a pretty simple affair with one big caveat at the end.  The guide that I found for installing APC is on HowToForge. The last two steps are particular to CentOS on A2hosting’s platform.

1.  Install PEAR.

yum install php-pear

2.  Install php-dev & httpd-dev.

yum install php-devel httpd-devel

3.  Install group Development Tools

yum groupinstall 'Development Tools'

4.  Install group Development Libraries

yum groupinstall 'Development Libraries'

5.  Install APC

pecl install apc

6.  Reboot Apache

httpd -k restart

7.  Error alerts you to SSLRandomSeed error.

SSLRandomSeed Error

SSLRandomSeed Error

8.  Fix Centos Dev

Fix CentOS Dev on A2hosting

It took me an hour last night to figure out the last step.  Without the last step there is no authentication so there is no SSH access.

Till Next Time

setting up a domain-nameless domain

December 21st, 2009

My company’s website is being completely rewritten from scratch and I chose to move to A2hosting.com.  We are going with a Virtual Private Server (VPS) from them and have found a little difficulty setting up web access to it.

The main issue is that since the website is already up and running, I can’t just transfer the domain name to the new server and be done with it.  I need to be able to access the new website by just the IP address for a while, until we move the production site over to it.  This is not documented anywhere on A2hosting’s site that I could find.

The issue resides in the setup of IP address of the server through Kloxo.  I am unable to configure the domain to default to the domain of my choice.  The error checking of this function disallows the assigning of that domain name since the domain name does not currently resolve to the server’s IP address.The solution resides in the /etc/hosts file.  I had to set the IP to equate to the domain name that WILL be the correct name once the production site is moved over.

A quick little walkthrough:

Set the /etc/hosts file

IP Addresses link in Kloxo admin

IP Address table

IP Address info

Select the proper domain name for the IP Address

Hope this helps.

Till Next Time

Verizon's crusade to 'help' the poor

December 19th, 2009

Recently Verizon upped their Early Termination Fee (ETF) for ‘advanced devices’ on two year contracts.  They used to charge the industry standard  $175 pro-rated at $10 $5 a month over two years if you cut your contract early, they now charge $350 for devices that are generally considered smartphones.  This change has brought them under the scrutiny of the new commissioner of the FCC, Julius Genachowski.

The big reason for the scrutiny, I believe, lies in the fact that with the increase of the ETF, if a customer cancels their contract in the last month of their two years, they will pay a $130 cancellation fee.  Many people have been justifiably outraged at this anticompetitive behavior.  The big V also appears to be padding their coffers with a slightly unethical design to many of their phones that allows them to hit their customers with a $1.99 fee many months due to an accidental key press.  David Pogue has started a movement to question Verizon’s new choices.

Verizon has responded[pdf link] to the FCC’s query into these matters with a laughable reasoning.  Verizon believes they are following the spirit of the national broadband plan in aiding “those of more limited means” to gain “access to a range of exciting, state-of-the-art broadband services and capabilities”.  I’m sorry, but subsidizing phones like every wireless carrier  is aiding in nation wide broadband?  That’s preposterous, the only reason Verizon subsidizes the equipment is because every other wireless carrier in the US does it.   The vast majority of users who have a smartphone also have some sort of broadband access from a different source.

The reason stated by Verizon for increasing their ETF is that Verizon pays more for the advanced devices than they do for more basic feature phones.  This I can accept.  However this reasoning falls apart when the ETF is not eliminated by the last month of the contract.  Here Verizon cops to the costs associated with selling the devices.

“In addition to the difference between the purchase and selling prices of devices, Verizon Wireless incurs additional costs to sign up customers, such as advertising costs, commissions for sales personnel, and store costs.”

So are you telling me that customers that are unhappy with Verizon for any reason and decide to leave have to pay extra to help pay for the advertising, commissions and stores??  That’s absolutely ridiculous!  That would be similar to having to pay a termination fee to Comcast to cancel your service to help them cover their normal operating costs.  Why should Verizon get anything extra to cover their normal operating expenses?

For the conscientious consumer, many things go into a purchasing decision.  Even before these laughable changes took place I was very wary of Verizon.  The Big V always seemed more like Big Brother to me.  From the artificial limitations they place of the phones they allow on their network to the arbitrary pricing structures they use, I passed by them when I left AT&T to go to Sprint.  I’m very happy with my Palm Pre and Everything Data plan on Sprint.  I just hope the FCC does their job in protecting the people’s communication infrastructure from those who want to monopolize it for their gain at the expense of the people who use it.  The airwaves that Verizon are using to make money hand over fist belongs to the people,  they are not Verizon’s private frequencies.

Till Next Time

Update: In reading Verizon’s response to the FCC’s inquiry, I found that their standard device ETF is only reduced by $5 every month meaning that in the last month of a two year contract there still exists a $55 ETF.

upgrading/sidegrading internet service

December 16th, 2009

I originally signed up for Clear internet service back in March/April before they actually launched in the Atlanta area, back when they were still called Clearwire.  At the time the service at the house was not great.  I was in a slight valley and the hill was between me and both of the towers in my area.  I have since moved.  Two days ago I decided to change my service from a Home account to a Mobile account, this will allow me to get my internet any where in Atlanta, not just where I have a power outlet available.

I spoke with a woman who was obviously not tech savvy, but earnest nonetheless.  Towards the end of the call I looked at my account online and realized that she had signed me up for a 2GB capped mobile plan instead of the unlimited plan.  This was a problem because I had already used over 6.5 GB of data in 14 days and my account screen was showing that I was going to be charged for my overage.  I let her know and she tried to change my account to the unlimited plan but was blocked by a strange activation issue.  Apparently at Clear you can’t change your service plan more than once a day.

She promised to update my account the next day(yesterday) and she put in an order for my USB modem.  She also sent out an email with an authorized return label for my old modem to ship back.  The next day around noon I get an email from Fedex with my tracking number for the new modem.  I tracked the package and it had already been delivered to my house!  For some reason they had next day aired my modem to me (talk about speedy service!).  I hadn’t even received my authorized return label yet from UPS!

I checked online this morning to make sure my account was fixed, it wasn’t.  So I called to fix my account, spoke with a nice woman for about 30 minutes to get it straightened away.  In the process I learned that you cannot change your service plan until the modem that is associated with your current service plan has been activated.  Once everything was fixed and we were good I ran a little speed test to check things out.

Speed test result for Clear Mobile Internet

Speed test result for Clear Mobile Internet

This is for a 6/1 Mbps connection, so needless to say, I am happy with the performance.

Till Next Time

new facebook privacy (or lack thereof)

December 15th, 2009

With the firestorm of criticism in the tech world over the privacy changes on facebook this week I thought I would put up a quick little guide for those not aware of how to fix the privacy issue.

Listening to TWiT this week, there was a great discussion of the effect and implications of these new  privacy settings.  An example of the effects of this change is that the founder of facebook, Mark Zuckerberg, had all his personal photos on facebook shared with the public.

Last week facebook prompted everyone to update their privacy settings with their ‘handy’ little form.  The problem is, if you are one of the many people who never manually set their privacy settings then all your activity on facebook will be turned public if you just click through the form without changing anything.

Go to your privacy settings here.

Go through each section of the privacy page to check and make sure your settings are what you want them to be.

One point of emphasis is that the applications on facebook have an level of access to your information that is staggering.  The base privacy settings do not apply to your applications at all.  The scarier part of this situation is that even if you do not have any applications on your profile, companies can get your information from your friends’ applications!

I found out this information listening to TWiT yesterday when they talked about the ACLU app on facebook, ‘What Do Quizzes Really Know About You?‘.  It is a bit heavy-handed but gets the point across.

While I am not happy with the latest developments from facebook, I am somewhat stuck on facebook because all my friends/family are on there.  So I am removing all applications from my account and am blocking all my data from being shared with my friends’ applications.  I’d rather not be inundated with marketing from companies that I had no idea were getting my information.

Till Next Time

size of linux folder

December 10th, 2009

Another quick post here.  I can never remember the command for getting the size of a folder in linux.  A quick search brought me here.  Patched together a few commands and it goes like this:

~ du -sh /path/to/dir

Till Next Time

PS- isn’t it interesting that all my quick posts are about linux commands…

Adding javascript to symfony form field

November 17th, 2009

In the users table at my company’s website there are fields for company, division, region, and location. Since each level of the company organization affects all the lower categories I have to filter out the invalid choices when a higher level choice is selected.

I’ve implemented this on some forms that I’ve created manually on the site but not in any forms that I haven’t heavily modified from the stock symfony creation.  I started googling around to find a solution but could not find a simple explanation of how to do it.  I expected to find at least some information in one of symfony’s otherwise excellent tutorials, but alas, no.

I had a minor epiphany and went digging through the forms API that symfony provides and realized that I should easily be able to do this through the sfWidgetFormPropelChoice method.  The second parameter passed is the html attributes for the form field.  I thought I had seen a form post here that said that I could add javascript code to the html attributes and not have it get converted into html entities.

I tried throwing a simple alert() inside the onchange attribute for my company box and wham! it worked!  So simple.  Code below:

new sfWidgetFormPropelChoice(
	array(
		'model' => 'Company',
		'add_empty' => true
	),
	array(
		'onchange' => "filterBy('company', 'division', this.value, 'sf_guard_user_user_division_id');" .
			"filterBy('company', 'region', this.value, 'sf_guard_user_user_region_id');" .
			"filterBy('company', 'location', this.value, 'sf_guard_user_user_location_id');"
	)
)

Till Next Time