Ctrl+Alt+Life: Hacking life, tech, and beyond.
-
DIY Automatic Irrigation using an aquarium air pump
Creating an automated irrigation system using an aquarium air pump. When we embarked on our last 10-day vacation, we faced the challenge of keeping our plants adequately watered. To our delight, we devised a simple yet effective solution using a fish tank air pump and a large water bucket. The process was straightforward: we passed…
-
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 use Phalcon\DI; use Phalcon\Db\Adapter\Pdo\Postgresql as DbAdapter; /** * We can move this config is a separate config file */ $config = new \Phalcon\Config(array( ‘database’ => array( ‘adapter’ => ‘Postgresql’, ‘host’ => “localhost”, ‘username’ =>…
-
Make image to base64 dataUri in NodeJS
Images are already in server, may be uploaded by multer. now have to make dataUri for s3. var fs = require(‘fs’); var uploadPath = ‘upload/’; var image = ‘blahblah.jpg’; fs.readFile(uploadPath+image, ‘base64’, function(err, data){ if (err) throw err; var type = image.split(‘.’)[1]; //here is the dataUri var dataUri = ‘data:image/’+type+’;base64,’+data; console.log(dataUri); });
-
PHP Data Filtering
PHP have native extension to filter data by either validating or sanitizing it. if (!filter_var($ip, FILTER_VALIDATE_IP) === false) { echo(“$ip is a valid IP address”); } else { echo(“$ip is not a valid IP address”); } if (filter_var($uuid, FILTER_VALIDATE_REGEXP, array(“options” => array(“regexp” => “/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/”))) === false) { echo ‘Invalid UUID’; }
-
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 CREATE OR REPLACE FUNCTION my_sp_method(i_json JSON) RETURNS TEXT AS $$ BEGIN RETURN i_json::json->>’bar’; END; $$ LANGUAGE plpgsql; 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 extension=phalcon.so 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…
-
Change/Override Base Url from local.xml of Magento
For ‘default’ store Open /app/etc/local.xml Add just before closing tag. https://www.ashrafulabedein.com/ https://www.ashrafulabedein.com/ https://www.ashrafulabedein.com/ https://www.ashrafulabedein.com/
-
Install Nginx, MySQL, PHP (LEMP)
Nginx !! it is fast… I need a fast server to host Magento and wordpress OS: Ubuntu 14.04 Installing nginx is easy as apache
-
Quick Install Apache PHP Mysql for Magento on Ubuntu
sudo apt-get update sudo apt-get install apache2 sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql sudo mysql_install_db sudo /usr/bin/mysql_secure_installation sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-gd
-
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 apt-get install bind9 or CentOS yum install bind9 Configure and Create Zone File for domains to add records…
Need tech consultancy?