Monday, October 28, 2013

Wednesday, October 23, 2013

CSqlDataProvider Using Special Data Attribute - Yii

Just posted this on the Yii forum after I found out that using the special data attribute in a column requires a syntax like 'value'=>'$data["issueCount"]' when you're using CSqlDataProvider:
http://www.yiiframework.com/forum/index.php/topic/48219-special-data-attribute-syntax-in-cactivedataprovider-vs-csqldataprovider/


Thursday, October 17, 2013

Enabling SSL On Apache


This is a quick overview of the process of adding an SSL certificate to apache (for next time...):
  1. Generate your private key and CSR with:
    openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
  2. Request your certificate
  3. Save requested certificate onto server in a .crt file
  4. Download the intermediary/root cert from http://www.symantec.com/page.jsp?id=roots
  5. Make your site file in /etc/apache2/sites-enabled/ look like this:
<VirtualHost *:443>


        SSLEngine On
         SSLCertificateFile /home/youruser/yourdomain.crt
         SSLCertificateKeyFile /home/youruser/yourdomain.key
         SSLCACertificateFile /var/www/verisign.crt

        ServerName www.yourdomain.com

        DocumentRoot /var/www/yourdomain


An explanation of each of those certificates:
SSLCertificateFile - This is the certificate you received after your request.
SSLCertificateKeyFile - This is the private key you generated in step 1.
SSLCACertificateFile - This is the intermediary cert you downloaded from verisign.

Wednesday, October 16, 2013

Friday, October 11, 2013

Yii quickdlgs Without UrlManager Enabled

EQuickDlgs::iframeButton(
array(
'controllerRoute' => 'controller/create',
'dialogTitle' => 'Create New Record',
'dialogWidth' => 800,
'dialogHeight' => 600,
'openButtonText' => 'Add Record',
'closeButtonText' => 'Close',
//'openButtonHtmlOptions' => array(...),
)
);


With the code above, I was getting the following error:
The system is unable to find the requested action "create?qdsClass=EFrameJuiDlg".

I had to change line 79 in EFrameJuiDlg.php inside the quickdlgs extension from:
            $url .= '?' . http_build_query($this->urlParams);
to:
            $url .= '&' . http_build_query($this->urlParams);

Tuesday, October 8, 2013

htmlspecialchars() expects parameter 1 - Yii (echmultiselect)

htmlspecialchars() expects parameter 1 to be string, array given C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(98) 
The error only occurred when trying to apply the echmultiselect filter to the filter above the gridview.

Here's what I did to fix:
1. Went to the Yii framework folder and found the following file: yii\framework\web\helpers\CHtml.php

2. Modifed line 98 from "return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset);" to:
"return htmlspecialchars(print_r($text, true),ENT_QUOTES,Yii::app()->charset);"

Then you need to implement the echmultiselect extension in the view (my example shows adding it for site_status):

3. Added this php code to the view: $data= CHtml::listData(Nvdaily::model()->findAll(), 'blahblahblah', 'blahblahblah');
(but it should probably be in the model)

4. Made my 'columns' array look like this:
'columns'=>array(
'id',
'blah',
'blahblah',
array (
            'name'=>'blahblahblah',
            'filter'=> $this->widget('ext.EchMultiselect.EchMultiselect',
array(
                'model' => $model,
                'dropDownAttribute' => 'blahblahblah',
                'data' => $data,
                'options' => array('buttonWidth' => 80, 'ajaxRefresh' => true),
            ),
            true // capture output; needed so the widget displays inside the grid
),
),
array(
'class'=>'bootstrap.widgets.TbButtonColumn',
),
),

Sunday, October 6, 2013

SQL Formatter

I had no idea this existed until now: http://www.dpriver.com/pp/sqlformat.htm

It makes your SQL queries more readable.

I learned about it from this thread: http://www.reddit.com/r/PHP/comments/1n8kgz/how_do_you_write_readable_sql_queries/

Error Handling In mysqldb - Python

I've had issues with queries failing and leaving connections open (enough to stall a server...). I know python's oursql library supports using the WITH keyword, and I think it will close the connection when there is an unexpected error. However, I'm not sure if I'm ready to move to a different library for MySQL (it's working well).

Here's what I'm currently doing to close the cursor and connection, then re-raise the error:

import MySQLdb

conn = MySQLdb.connect(user="username", passwd="secret", db="database", charset='utf8')
cur = conn.cursor()

try:
cur.execute("INSERT INTO testTable (userid) VALUES(%s);" % id)
conn.commit()
except:
cur.close()
conn.close()
raise
finally:
print "Insert Successful"

Friday, October 4, 2013

haufe.sharepoint Python Library - URLs With %20

I changed line 25 of the haufe.sharepoint library to fix an issue I was having with URLs which had %20 (the url encoded space character):

New Code:
location = urllib.quote(self.location(), safe=":/")

Old Code:
location = self.location()

Just try using a URL with %20 with haufe.sharepoint to see what I'm talking about.

Thursday, October 3, 2013

urllib2.URLError Python SUDS library

To figure this out, you're going to need logging. Turn on logging with the following:


import logging logging.basicConfig(level=logging.INFO) logging.getLogger('suds.client').setLevel(logging.DEBUG) logging.getLogger('suds.transport').setLevel(logging.DEBUG) logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)

pip 1.3 Not Working Behind Proxy

http://pythontesting.net/python/pip/

Like this article says, it's fixed in the dev version of pip.

Bootstrap Starter Templates

http://startbootstrap.com/all-templates

Wednesday, October 2, 2013

Tuesday, October 1, 2013

MySQL Not Starting On Reboot

http://stackoverflow.com/questions/9859381/how-make-mysql-start-automatically-linux-cli-only

I was able to to the following, based on the post above:

  1. sudo apt-get install sysv-rc-conf
  2. sudo sysv-rc-conf
  3. mark the 6 column for mysqld or mysql.server (6 = reboot)

Note: I tried sudo update-rc.d mysql.server defaults and it didn't work. It gave me the following error: System start/stop links for /etc/init.d/mysql.server already exist.