tag:blogger.com,1999:blog-34156320096207570462024-03-13T19:28:36.003-07:00InstructionsJennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-3415632009620757046.post-23024966888212841262020-03-10T02:09:00.001-07:002020-03-10T02:09:29.346-07:00Set documentation hercule and apiary<div dir="ltr" style="text-align: left;" trbidi="on">
To merge apib files in one you can use Hercule.<br />
It can found <a href="https://github.com/jamesramsay/hercule">https://github.com/jamesramsay/hercule</a>, for the rest you need apiary cli <a href="https://help.apiary.io/tools/apiary-cli/">https://help.apiary.io/tools/apiary-cli/</a></div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-63248722394027068692017-01-31T05:32:00.001-08:002017-01-31T05:32:15.831-08:00Error: can not find module ‘underscore’<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Error: can not find module ‘underscore’
<br /><br />Windows</b><br />
<pre style="background: center top repeat rgb(251, 251, 251); border: 1px solid rgb(221, 221, 221); color: #3b3b3b; font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 18px; font-stretch: inherit; font-variant-numeric: inherit; line-height: 1.6em; margin-bottom: 30px; margin-top: 30px; overflow-x: auto; overflow-y: hidden; padding: 10px 20px; vertical-align: baseline; white-space: pre-wrap; word-wrap: break-word;"><code style="background: none; border: 0px; font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace; font-size: 1em; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px 3px; vertical-align: baseline;">npm install rimraf -g
rimraf node_modules
sudo npm install </code></pre>
</div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-24263209929297596872015-05-08T05:56:00.001-07:002015-05-08T05:56:08.335-07:00Conflict with stitch and sass newer releases<div dir="ltr" style="text-align: left;" trbidi="on">
Lately we are having issue with compass, exactly with sass > 3.2.9 compatibility with stitch, so one of solution is to install olders versions that work. This iis what I needed:<br />
<br />
<pre class="lang-rb prettyprint prettyprinted" style="border: 0px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><span class="pln" style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;"><pre class="lang-rb prettyprint prettyprinted" style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code><span style="background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;">> </span><span style="background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif;">gem install sass --version 3.2.9</span></code></pre>
<code><pre class="lang-rb prettyprint prettyprinted" style="background-color: #eeeeee; border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;">> </span><span style="font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif;">g</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;">em install compass --version 0.12.0</span></pre>
</code></span></pre>
<pre class="lang-rb prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;"><span class="pln" style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;"><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;">> </span><span style="font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif;">gem install stitch --version 0.1.6</span></span></code></pre>
<pre class="lang-rb prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><code style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;"><span class="pln" style="border-image-outset: initial; border-image-repeat: initial; border-image-slice: initial; border-image-source: initial; border-image-width: initial; border: 0px; margin: 0px; padding: 0px;"><span style="font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, sans-serif;">>gem install bootstrap-sass --version 3.3.1.0</span></span></code></pre>
</div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-25660381316068520672014-09-08T04:35:00.001-07:002015-03-01T04:07:14.157-08:00First steps for already exisitngs projects in Laravel<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
I often have problems to remember what to do when I get to work on existing Laravel project.<br />
<br />
<br />
Frist error I get is:<br />
<br />
"../vendor/autoload.php): failed to open stream: No such file or directory in .."<br />
<br />
To fix this, just run in Terminal<br />
<pre class="prettyprint prettyprinted" style="background: padding-box padding-box rgb(51, 51, 51); border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; border: 1px solid rgb(136, 136, 136); font-family: Monaco, Consolas, 'Lucida Console', monospace; font-size: 8px; line-height: 1.9em; margin: 20px inherit; overflow: hidden; padding: 2px; word-wrap: break-word;"><code style="background-attachment: initial !important; background-clip: initial !important; background-color: initial !important; background-image: initial !important; background-origin: initial !important; background-position: 0px 0px !important; background-repeat: initial !important; background-size: initial !important; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; font-family: Monaco, Consolas, 'Lucida Console', monospace; font-size: 11px; padding: 0px;"><span class="pln" style="color: #e9e4e5;">composer </span><span class="pln"><span style="color: #4bb1b1;">install</span></span></code></pre>
</div>
Then setup .htaccess.<br />
<br />
Next thing, in config folder to setup local configuration (database and other settings), I usually do like here: http://laravel.com/docs/configuration#environment-configuration.<br />
<br />
After setting up the conf next id database. Create database and then run<br />
<pre class="prettyprint prettyprinted" style="background: padding-box padding-box rgb(51, 51, 51); border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; border: 1px solid rgb(136, 136, 136); font-family: Monaco, Consolas, 'Lucida Console', monospace; line-height: 1.9em; margin: 20px inherit; overflow: hidden; padding: 2px; word-wrap: break-word;"><span style="color: #e9e4e5;"><span style="font-size: 11px;">php artisan migrate</span></span></pre>
to create tables in your database.<br />
<br />
And<br />
<br />
<pre class="prettyprint prettyprinted" style="background: padding-box padding-box rgb(51, 51, 51); border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; border: 1px solid rgb(136, 136, 136); font-family: Monaco, Consolas, 'Lucida Console', monospace; line-height: 1.9em; margin: 20px inherit; overflow: hidden; padding: 2px; word-wrap: break-word;"><span style="color: #e9e4e5;"><span style="font-size: 11px;">php artisan db:seed</span></span></pre>
<br />
to seed data.<br />
<br />
And now should be all running.<br />
<br />
To set up mail work on localhost and not to send real mails ...app\config\local\mail.php<br />
<br />
<br />
<pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: 'Courier New'; font-size: 12pt;">
<span style="color: #cc7832; font-weight: bold;">return array</span>(
<span style="color: #6a8759;">'driver' </span>=> <span style="color: #6a8759;">'mail'</span><span style="color: #cc7832;">,</span>)<span style="color: #cc7832;">;</span></pre>
<br /></div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-2234878434075661552013-01-25T04:33:00.000-08:002013-02-07T05:54:03.634-08:00Create task using symfony and run it form action<div dir="ltr" style="text-align: left;" trbidi="on">
Create MyTask.class.php in /lib/Task folder. It should look like this:
<pre>
/**
* MyTask class.
*
* @author ...
*/
class MyTask extends sfPropelBaseTask
{
/**
* Execute configure method.
*
*/
protected function configure()
{
$this->addOptions(array(
new sfCommandOption('application', NULL, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', 'front'),
new sfCommandOption('env', NULL, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
new sfCommandOption('connection', NULL, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
));
$this->namespace = 'namespace';
$this->name = 'myTask';
$this->briefDescription = 'Do Task';
$this->detailedDescription = 'Do Task desc';
}
/**
* Execute execute method.
*
* @param array $arguments
* @param array $options
*
*/
protected function execute($arguments = array(), $options = array())
{
sfContext::createInstance($this->configuration);
//Do Task
}
}
</pre></div>
And now, run it from action that you need:
<pre>
$dispatcher = sfContext::getInstance()->getEventDispatcher();
$formatter = new sfFormatter();
$task = new ReminderToWriteReviewTask($dispatcher, $formatter);
chdir(sfConfig::get('sf_root_dir'));
$task->run(array(), array('connection' => sfConfig::get('connection')));
</pre>
You can also call the task, as it should be called, from command line
<pre>
php symfony namespace:myTask
</pre>Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-88018455332574829372012-11-09T12:03:00.002-08:002012-11-09T12:03:56.165-08:00symfony guard group permissions from database<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Sometimes we need to have permission from database.<br />
Suppose that uor tables look like this:<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>guard_permission:
_attributes: { phpName: GuardPermission }
code: { type: char, size: 150, required: true, primaryKey: true }
name: { type: varchar, size: 100, required: true }
guard_group:
_attributes: { phpName: GuardGroup }
code: { type: char, size: 150, required: true, primaryKey: true }
name: { type: varchar, size: 100, required: true }
description: { type: longvarchar, required: false }
is_default: { type: boolean, required: true, default: false }
guard_group_permission:
_attributes: { phpName: GuardGroupPermission }
id: ~
group_code: { type: char, size: 150, required: true, foreignTable: guard_group, foreignReference: code, onDelete: cascade }
permission_code: { type: char, size: 150, required: true, foreignTable: guard_permission, foreignReference: code, onDelete: cascade }
guard_user:
_attributes: { phpName: GuardUser }
id: ~
is_email_verified: { type: boolean, required: true, default: false }
guard_user_group:
_attributes: { phpName: GuardUserGroup }
id: ~
user_id: { type: integer, required: true, foreignTable: guard_user, foreignReference: id, onDelete: cascade }
group_code: { type: char, size: 150, required: true, foreignTable: guard_group, foreignReference: code, onDelete: cascade }
</code></pre>
<br />
To check permissions from database, we just need to override hasCredential method in apps/app_name/lib/MyUser.php. My data in database were 'module_name-action_name' e.g (permisssion_code: home-index), so i have overwritten parmission name to look like data from database.<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
/**
* Overridden method to use data from DB
*
* @param string permission name
*
* @return boolean true if the user has credential
*/
public function hasCredential($permission_name)
{
if(!$this->isAuthenticated())
{
return false;
}
$GuardUser = $this->getGuardUser();
$c = new Criteria();
$c->add(GuardUserGroupPeer::USER_ID, $GuardUser->getId());
$UserGroup = GuardUserGroupPeer::doSelectOne($c);
$Group = $UserGroup->getGuardGroup();
$permissions = $Group->getGuardGroupPermissions();
$permission_names = array();
foreach($permissions as $permission)
{
$permission_names[] = $permission->getPermissionCode();
}
$moduleName = sfContext::getInstance()->getModuleName();
$actionName = sfContext::getInstance()->getActionName();
$permission_name = $moduleName . '-' . $actionName;
return (in_array($permission_name, $permission_names)) ? true : false;
}
</code></pre>
<br />
Now all we need is to fill out the data in database, and this should work.</div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-51618368166842880042012-11-07T02:39:00.002-08:002012-11-09T12:05:27.894-08:00Create ssl certificate for site<div dir="ltr" style="text-align: left;" trbidi="on">
If You allready have configured your apache server for ssl, type in these command lines for new cert for site<br />
<br />
<pre class="literal-block" style="background-color: #f8f8f8; border: 1px solid rgb(204, 204, 204); font-size: 13px; line-height: 15px; overflow: auto; padding: 15px;">openssl req -new -days 365 -nodes -out www.mydomain.com.csr`</pre>
<pre class="literal-block" style="background-color: #f8f8f8; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 15px;"><span style="line-height: 15px;">openssl x509 -in www.</span><span style="font-size: 13px; line-height: 15px;">mydomain.com</span><span style="line-height: 15px;">.csr -out www.</span><span style="font-size: 13px; line-height: 15px;">mydomain.com</span><span style="line-height: 15px;">.cert -req -signkey www.</span><span style="font-size: 13px; line-height: 15px;">mydomain.com</span><span style="line-height: 15px;">.key -days 365</span></pre>
<br />
<br />
And add your configuration to thhpd-ssl.conf<br />
<br />
<br />
<pre class="literal-block" style="background-color: #f8f8f8; border: 1px solid rgb(204, 204, 204); font-size: 13px; line-height: 15px; overflow: auto; padding: 15px;"><VirtualHost _default_:443>
ServerAdmin admin@admin.com
DocumentRoot "YOUR_PRROJECT_PATH"
ServerName YOUR_PRROJECT_HOST:443
ServerAlias YOUR_PRROJECT_ALIAS:443
SSLEngine on
SSLCertificateFile "C:/wamp/bin/apache/Apache2.2.21/conf/www.mydomain.com.cert"
SSLCertificateKeyFile "C:/wamp/bin/apache/Apache2.2.21/conf/www.mydomain.com.key"
</VirtualHost> </pre>
</div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-65179436467899471502012-11-06T00:43:00.004-08:002012-11-09T12:10:21.825-08:00Symfony propel file form widget editable<div dir="ltr" style="text-align: left;" trbidi="on">
This is a simple editable file form widget:<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
If we have file_path field type varchar(255) in database, our widget will look like:<br />
<br /></div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>'file_path' => new sfWidgetFormInputFileEditable(array('template' => '<div class="row file-editable-input">%input%</div><div class="row file-editable-remove"><ul class="inputs-list"><li><label>%delete%%delete_label%</label></li></ul></div><div class="row file-editable-img">%file%</div>',
'file_src' => UPLOADS_DIR . $this->getObject()->getFilePath(),
'is_image' => FALSE,
'edit_mode' => TRUE,
'delete_label' => __('Check this box if you want to remove current file'),
'with_delete' => TRUE), array()),
</code></pre>
</div>
And validator should look like:
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
'<span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;">file_path</span><span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;">' => new sfValidatorFile(array(</span>
'max_size' => Utils::getMaxUploadSize() * 1024 * 1024,
'mime_types' => 'all_documents',
'path' => <span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;">UPLOADS_DIR</span><span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;">,</span>
'required' => FALSE)),
</code></pre>
And that's it. 'all_documents' is array of file extensions i creted in the validator file, along wit web_images and other. And off course your uploads dir must exist.</div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-6832291712205066762012-11-05T05:31:00.003-08:002012-11-09T12:12:46.295-08:00symfony admin generator examples from config:<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b>I always loose much time looking for these simple generator.yml config settings:</b><br />
<b><br /></b>
<b>With edit and new actions:</b><br />
<div>
<b><br /></b>
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code> config:
actions: ~
fields:
id: { label: "ID" }
created_at: { label: "Created At", date_format: "MM/dd/yyyy HH:mm:ss" }
list:
title: Title
display: [id, word, created_at]
max_per_page: 50
sort: [id, asc]
filter: ~
form: ~
edit:
title: Edit
new:
title: New
</code></pre>
</div>
<b><br /></b>
<b>Without new action, batch actions...:</b><br />
<b><br /></b></div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code> config:
actions: ~
fields:
id: { label: "ID" }
<span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;"> created_at: { label: "Created At", date_format: "MM/dd/yyyy HH:mm:ss" }</span>
list:
title: Title
display: [id, subject, description]
max_per_page: 50
sort: [id, asc]
actions: []
batch_actions: []
object_actions:
_edit: ~
filter: ~
form: ~
edit:
title: Edit
actions:
_list: ~
_save: ~
_save_and_add: ~
new:
title: New
</code></pre>
</div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-24837272159975643032012-11-05T03:08:00.000-08:002012-11-09T12:17:24.570-08:00Symfony admin generator add custom criteria to filter<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div>
If you have in list field that doesn't exist as a database feild to the formFilter class you need to add your custom criteria for that field.</div>
<div>
Note: function needs to be called addYourFieldNameColumnCriteria</div>
<div>
<br /></div>
<div>
Example: /lib/filter/User/UserFormFilterClass</div>
<div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>public function addYourFilterColumnCriteria(Criteria $criteria, $field, $values)
{
$values = trim($values);
if (!empty($values))
{
$criteria->add(YourPeer::FIELD_NAME, $values);
}
}
</code></pre>
</div>
<div>
<br /></div>
<div>
But sometimes $values returns an ampty array (I am not sure when), then you need to register you type of field and then to access it ina a different way:<br />
<br /></div>
</div>
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>public function addYOUR_FIELDColumnCriteria(Criteria $c, $field, $values)
{
$value = trim($values['text']);
if (!empty($value))
{
// Your ciriteria
}
}
public function getFields()
{
$fields = parent::getFields();
$fields['<span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;">YOUR_FIELD</span><span style="font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace;">'] = 'Text';</span>
return $fields;
}
</code></pre>
Off course <span style="background-color: #eeeeee; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 12px; line-height: 14px;">YourFilter,</span> <span style="background-color: #eeeeee; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 12px; line-height: 14px;">YourPeer, </span><span style="background-color: #eeeeee; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 12px; line-height: 14px;">FIELD_NAME,</span><span style="background-color: #eeeeee; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 12px; line-height: 14px;">YOUR_FIELD and field type you need to adjust to your needs.</span></div>
Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-41217940487060388962011-08-28T05:23:00.000-07:002011-08-28T05:23:35.744-07:00Apache xampp virtual hosts configuration on mac<div dir="ltr" style="text-align: left;" trbidi="on">After installing xampp on mac you need to change permission for <code>/xamppfiles/etc/httpd.conf</code> file. There is simple program for that, called BatChmod.<br />
<br />
Next you need to enable it for user thsty you want:<br />
<br />
Find<code>:</code><br />
<code>User nobody<br />
Group nogroup</code> <br />
Change it to:<br />
<code>User YOURUSERNAME<br />
Group admin</code><br />
<code><br />
</code><br />
<code>If you projects are in another location you will need to change DocumentRoot in httpd.conf to you path, and also need to change line</code><br />
<code><Directory "/Applications/XAMPP/xamppfiles/htdocs"></code><br />
<code>to you path, and "Deny from all" to "Allow from all" to this directory</code><br />
<code><br />
</code><br />
<code>After that uncomment</code><br />
<code>Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf</code><br />
<br />
<code>Here is where you put your virtual hosts. </code><br />
<br />
<code>It should look like :</code><br />
<br />
<code><b>NameVirtualHost 127.0.0.1<br />
<br />
<VirtualHost 127.0.0.1><br />
ServerName yourdomain.dev<br />
DocumentRoot "/Users/</b></code><code><b>username</b></code><code><b>/projects/your_project"<br />
DirectoryIndex index.php<br />
<Directory "/Users/</b></code><code><b>username</b></code><code><b>/projects/</b></code><code><b>your_project</b></code><code><b>"><br />
Options +Indexes FollowSymLinks +ExecCGI<br />
AllowOverride AuthConfig FileInfo<br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
</VirtualHost><br />
<br />
<VirtualHost 127.0.0.1><br />
ServerName localhost<br />
DocumentRoot "/Users/username/projects/"<br />
DirectoryIndex index.php<br />
<Directory "/Users/</b></code><code><b>username</b></code><code><b>/</b>projects<b>/"><br />
Options +Indexes FollowSymLinks +ExecCGI<br />
AllowOverride AuthConfig FileInfo<br />
Order allow,deny<br />
Allow from all<br />
</Directory><br />
</VirtualHost></b></code><code> </code><br />
Last thing, add yourdomain to hosts<br />
<br />
Open the Terminal and type:<br />
<code>sudo pico /etc/hosts</code><br />
<br />
Now enter your admin password. You'll get a little text editor in the console. Go to the last line and add this line:<br />
<code>127.0.0.1 <strong></strong></code><code><b>yourdomain.dev</b></code> with the correct name for every virtual host you would like to set up. When you're done, type control-o, then enter and then control-x in order to save and close.<br />
<br />
</div>Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-52110672437279920932011-08-05T03:12:00.000-07:002011-08-05T03:30:23.856-07:00simple ajax call<div dir="ltr" style="text-align: left;" trbidi="on">This is part for the view script:<br />
<br />
<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>function addAdditional(lnk) {
jQuery.ajax({
type: "POST",
url: "<?php echo $this->url(array('controller' => 'content', 'action' => 'vote'), 'default', true); ?>",
data: jQuery('#star-form').serialize()+'&content_id=' + <?php echo $this->content_id ?>,
success: function(res)
{
r = jQuery.parseJSON(res);
if(r.status == 'success')
{
if(r.saved == 'success') {
$("#vote-button").next().html('Uspesno ste glasali!');
} else {
$("#vote-button").next().html('Niste glasali. Pokusajte ponovo!');
}
}
else
{
$("#vote-button").next().html('Niste glasali. Pokusajte ponovo!');
}
}
});
return false;
}
</code></pre></div><br />
Here is the controller action<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>public function voteAction() {
$result = array(
"status" => "",
"saved" => "",
);
if ($ok) {
//do code
$result = array(
"status" => "success",
"saved" => "success",
);
} else {
$result = array(
"status" => "success",
"saved" => "error",
);
}
die(json_encode($result));
}
</code></pre></div></div>Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-27691557694830513592011-08-04T01:09:00.001-07:002011-08-04T01:09:17.541-07:00Using selenium server with netbeansFisst of all you need to have php unit installed. <font class="Apple-style-span" style="font-family: Verdana; line-height: 24px; ">PHPUnit should be installed using the PEAR INSTALLER. I didnt have go-pear.bat in my wamp 2.1, so i copied it from xamp server and ran "php -d phar.require_hash=0 PEAR/go-pear.phar" command, then you nedeed to upgrade pear using "</font><span class="Apple-style-span" style="font-family: monospace; font-size: 13px; line-height: 13px; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">pear install PEAR-1.9.3</span><font class="Apple-style-span" style="font-family: Verdana; line-height: 24px; ">" command. Now install php Unit </font><a href="http://www.phpunit.de/manual/current/en/installation.html">http://www.phpunit.de/manual/current/en/installation.html</a>. <div>Now you can continue with <a href="http://netbeans.org/kb/docs/php/phpunit.html#installing-phpunit">http://netbeans.org/kb/docs/php/phpunit.html#installing-phpunit</a><br />
<div><font class="Apple-style-span" face="Verdana"><font class="Apple-style-span" style="line-height: 24px;"><br />
</font></font><div><font class="Apple-style-span" color="#008800" face="Arial, sans-serif" size="2"><font class="Apple-style-span" style="white-space: nowrap;"><br />
</font></font><div><br />
</div></div></div></div>Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-36429697407960809422011-08-04T01:08:00.000-07:002011-08-04T01:08:01.033-07:00Zend send variable to a formWe create variable that we need in controller:<br />
<br />
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>$this->view->random = date('YmdHis').rand(10000, 9999).rand(10000, 9999);
</code></pre><br />
<br />
Then we pass it to a form call in controller:<br />
<br />
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>$this->view->form = new Application_Form_ContentGame(array('random'=>$this->view->random));
</code></pre><br />
<br />
And in a form, we get it with:<br />
<br />
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>$random = $this->getAttrib('random');
</code></pre>Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0tag:blogger.com,1999:blog-3415632009620757046.post-43499139761309238552011-07-29T03:49:00.000-07:002011-07-29T04:01:08.461-07:00Jquery add another form fieldFirst we need div to clone with remove link:<br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code><div id="floorForClone" style="display: none;"><br /><div id="floor-plan"><br /> <input type="hidden" name="floor_plan_id[]" value="{$id}" /><br /> <div id="floor-plan-info" class="fleft" style="width: 140px;"><br /> <div class="fleft mt5 w100p "><br /> <label for="floor_plan_name">Name</label><br /> <div class="fleft pfid373"><br /> <input id="floor_plan_name" name="floor_plan_name[]" value='{$floor_plan.floor_plan_name}' class="category-profile-form-textbox text" type="text" /><br /> </div><br /> </div><br /> </div><br /> <div id="floor-plan-info" class="fleft" style="width: 110px;"><br /> <div class="fleft mt5 w100p "><br /> <label for="floor_bedrooms">Bedrooms</label><br /><br /> <div class="fleft pfid374"><br /> <select name="floor_bedrooms[]"><br /> <option label="1" value="179">Select</option><br /> <option label="1" value="273">1</option><br /> <option label="2" value="274">2</option><br /> </select><br /><br /> </div><br /> </div><br /> </div><br /> <a onclick="removeAdditionalFloor(jQuery(this)); return false;" href="" class="add">Remove</a><br /></div><br /></code></pre><br /><br />Then there are script functions to add remove fields:<br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>function addAdditionalFloor(lnk) {<br /> lnk.before('<div id="floor-plan">' + jQuery('#floorForClone').html() + '</div>');<br /> return false;<br /> }<br /> function removeAdditionalFloor(lnk) {<br /> lnk.closest("#floor-plan").remove();;<br /> return false;<br /> }<br /></code></pre><br /><br />And last add the add another link where do we need it:<br /><br /><pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code><a onclick="addAdditionalFloor(jQuery(this)); return false;" href="" class="add">Add floor plan</a><br /></code></pre>Jennyhttp://www.blogger.com/profile/03488723414742344521noreply@blogger.com0