Good way to connect database in Phalcon php framework

Database connection settings can be done by registering services in the container.
Here is how we can connect a postgresql database

Make image to base64 dataUri in NodeJS

Images are already in server, may be uploaded by multer. now have to make dataUri for s3.

PHP Data Filtering

PHP have native extension to filter data by either validating or sanitizing it.

PostgreSQL plsql method with json argument

To get a element of json we can call with index name like this i_json::json->>’bar’
Here is a sample method with josn argument

Calling with a json will return “world” which is the value of json index bar

Interesting features of Phalcon PHP framework

First of all Phalcon is not like any other php framework because it’s a php extension written in C. Php extension are .so files like
Since it’s a php extension it’s always loaded if the extension is enabled in php.ini file, even with nothing build. And this going to make this perform fast.

The framework have no defined directory structure, so you can build your application in different pattern like multi-module, HMVC etc

to be continue…

Magento truncate a table

Truncating may needed if you want to reset all your module data, In your tables Mage_Core_Model_Resource_Db_Abstract model add a function truncate

Call the truncate when needed

Change/Override Base Url from local.xml of Magento

For ‘default’ store
Open /app/etc/local.xml
Add just before closing tag.

Magento Re-Install Extension by Script

Create a file reinstall.php in magneto’s root directory and run by url
Sometimes it helps to fix broken installation of any extension.

Quick Install Apache PHP Mysql for Magento on Ubuntu

Continue reading Quick Install Apache PHP Mysql for Magento on Ubuntu

How to add DNS record in Ubuntu/Linux

Point domain to unmanaged VPS/Dedicated server or add any DNS record in Ubuntu/CentOS

To serve DNS records we need to install DNS server package like BIND9
Update Package manager “apt-get update” or CentOS “yum update”

Install BIND9

or CentOS

Configure and Create Zone File for domains to add records
open file name.conf.local and insert zone file name for domain

save and close file.

Create Zone File for domain

To create name server and added NS and A records. replace with server IP

Now add and as child nameserver in domain register panel and also add in nameserver address in domain register.

To add another domain to same vps

Make jQuery colorbox plugin responsive

Use jQuery colorbox lightbox plugin in responsive design with some native colorbox options

Set a value as selected in select dropdown custom admin form in Magento

I found this in Varien_Data_Form_Element_Select which generates the select option html

Find: with in same form file

Add line before:

if your form have no setValues() function just add value in addField like this

option with value 2 will be selected.

Deploy Django in Heroku

Deploy Python Django app in heroku cloud

PostgreSQL needed since heroku don’t support sqlite3
install pgsql supports(not really required to install in your local but add in requirement.txt)

Somehow psycopg2 not installing in my local but I added psycopg2 in requirements.txt

Continue reading Deploy Django in Heroku

Magento Memcache Install, Magento performance optimization

Memcache really makes magento site faster
Memcache is a caching system that holds database objects and data in RAM, so system doesn’t have to make slow database calls to pull data.

it is strongly recommended for magento stores, you know magento is kinda slow thing.

Install Memcached in magento on Ubuntu is very easy.

Continue reading Magento Memcache Install, Magento performance optimization