Skip to content

Instantly share code, notes, and snippets.

View evgv's full-sized avatar
🏠
Working from home

Eugene Zubkov evgv

🏠
Working from home
View GitHub Profile
@evgv
evgv / php_resize_image.md
Created September 23, 2016 08:32
PHP. Resize image.

Resize image

Sometimes client can upload a large image and you might want to resize it. Below PHP snippet would enable you to do that.

function resize_image($filename, $tmpname, $xmax, $ymax)  
{  
    $ext = explode(".", $filename);  
    $ext = $ext[count($ext)-1];  
  
 if($ext == "jpg" || $ext == "jpeg") 
@evgv
evgv / php_email_using_mail.md
Last active September 23, 2016 08:35
PHP. Send email using Mail()

#Send email using Mail()

Above we have discussed how you can send email using Mandrill, but in case you do not want to use a third party service, you can use the below snippet.

function send_mail($to,$subject,$body) {
  $headers = "From: KOONK\r\n";
  $headers .= "Reply-To: [email protected]\r\n";
  $headers .= "Return-Path: [email protected]\r\n";
 $headers .= "X-Mailer: PHP5\n";
@evgv
evgv / php_database_connection.md
Created September 23, 2016 08:38
PHP. Database connection

Database connection

To store data, you would need a database. In this case we would be using MySQL database.

 <?php
    $DBNAME = 'dbname';
    $HOST   = 'localhost';
    $DBUSER = 'dbuser';
 $DBPASS = 'dbpass';
@evgv
evgv / php_url_shortener_using_tinyurl.md
Created September 24, 2016 09:24
PHP. Url shortener using tinyurl

Youtube download link generator

  function get_tiny_url($url)  
  {  
  	$ch      = curl_init();  
  	$timeout = 5;  
  	
  	curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);  
 curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
@evgv
evgv / php_generate_qr_code.md
Last active September 24, 2016 09:32
PHP. Generate QR code

Generate QR code

function qr_code($data, $type = "TXT", $size ='150', $ec='L', $margin='0')  
{
    $types = array(
        "URL"   => "http://", 
        "TEL"   => "TEL:", 
        "TXT"   => "", 
@evgv
evgv / Mage_Core_Model_Layout.php
Last active September 24, 2016 09:49
Fix "Array to string conversion in Mage/Core/Model/Layout.php on line 555" Magento install error for PHP7
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@evgv
evgv / README.md
Created September 24, 2016 09:47
PHP script for delete BOM symbols from files

PHP script for delete BOM symbols from files

The script search and deletes BOM(Byte-order mark) characters such as &#65279 the Unicode Character 'ZERO WIDTH NO-BREAK SPACE' (U+FEFF) from files in the specified categories.

For example you need to place the file in the root of the site and execute it, example.com/bom.php and you will see list of all files in which were found and deleted BOM characters.

######Set dir:

 /* for root site dir */
@evgv
evgv / README.md
Last active September 24, 2016 09:59
Clear custom vaiables from url

Clear custom vaiables from url

The function takes a URL and then walked on given array elements as variable what will be cleared from the URL, the function returns prepared URL.

@evgv
evgv / README.md
Created September 24, 2016 10:01
JS. Clear custom vaiables from url

Clear custom vaiables from url

The function takes a URL and then walked on given array elements as variable what will be cleared from the URL, the function returns prepared URL.

######How to use it, add this script on your site and call clearv.clear(YOU_URL):

  clearv.clear('http://example.com?utm_source=transactional&utm_medium=email&utm_campaign=digest-comments')

will return

@evgv
evgv / README.md
Created September 24, 2016 10:02
JS. Retrieve variable value from url by name

Retrieve variable value from url by name using JS

The function takes variable name and search it value in URL search string, the function return value or ''.

######How to use it, add this script on your site and call turl.getParametrByName(YOU_VARIABLE_NAME):

  /* for example you URL is */
  url = 'http://example.com?utm_source=transactionaal&utm_medium=email&utm_campaign=digest-comments';