Skip to content

Instantly share code, notes, and snippets.

View motsmanish's full-sized avatar
🎯
Focusing

Manish Motwani motsmanish

🎯
Focusing
View GitHub Profile
@motsmanish
motsmanish / imagick-3.7.0-PHP-7.4
Last active January 19, 2023 07:10 — forked from danielstgt/imagick3.4.4-PHP7.4-forge.sh
Install imagick 3.7.0 on PHP 7.4 server
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.7.0.tgz
tar xvzf imagick-3.7.0.tgz
@motsmanish
motsmanish / pagination.php
Created October 5, 2020 09:38
Pagination code for Cakephp 4 + Bootstrap 4
<?php
$this->Paginator->setTemplates([
'first' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'prevActive' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'prevDisabled' => '<li class="page-item disabled"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'current' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'number' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'nextActive' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'nextDisabled' => '<li class="page-item disabled"><a class="page-link" href="{{url}}">{{text}}</a></li>',
'last' => '<li class="page-item"><a class="page-link" href="{{url}}">{{text}}</a></li>'
@motsmanish
motsmanish / crontab
Created December 29, 2017 10:17
Set Environment variables for Production and Staging server (NGINX, SHELL, CRON, CRONTAB, ENV, CAKEPHP)
######################################## SITUATION #########################################
# Had to set environment variable somewhere in server block or crontab
# so different databases are used by the cron function for staging and production environment
# and operations are performed based on environment
# Tried setting variable in /etc/php/7.0/fpm/pool.d/www.conf, but didnt worked for crons/shells
# Also tried setting variable in /etc/environment but no luck for above purpose
# I might have missed something in above 2 methods, but below one worked for me.
##############################################################################################
SHELL=/bin/sh
@motsmanish
motsmanish / README.md
Last active March 14, 2018 13:17 — forked from Oxicode/README.md
Install wkhtmltopdf on Ubuntu 14.04 64-bit

Install wkhtmltopdf on Ubuntu

This was tested on:

  • Ubuntu 14.04 x64
  • Ubuntu 16.04 x64

Step 1

Install the xvfb server by running

@motsmanish
motsmanish / password-protect-pdf-php.php
Last active October 12, 2017 10:58
PHP plugin / library / repository for Password Protecting PDF files
/*
Installation:
composer require madnh/fpdi-protection
composer require setasign/fpdf:1.8
composer require setasign/fpdi:1.6.2
*/
//PHP function to implement the basic password protection, code is self explanatory
```php
public function pdfEncrypt($origFile, $destFile, $password_user, $password_owner)
@motsmanish
motsmanish / install-phpsec.sh
Created September 30, 2017 09:19
Commands to install PHPSEC library
sudo apt-get install php7.0-pgsql
sudo apt-get install php-pear
sudo pear channel-discover phpseclib.sourceforge.net
sudo pear remote-list -c phpseclib
sudo pear install phpseclib/Net_SSH2
sudo service nginx restart
@motsmanish
motsmanish / info.txt
Created January 6, 2017 05:16
SSH homestead using WinSCP
In your WinSCP tool:
# Under the session section:
Host name: 127.0.0.1
Port: 2222
Username: vagrant (or the username you have used to create the box)
password: (leave it blank)
# Under Advanced section:
Under SSH -> Key Exchange
@motsmanish
motsmanish / dump.sh
Last active August 23, 2019 13:29 — forked from andsens/dump.sh
Backup all MySQL databases into separate files
#!/bin/sh
## backup each mysql db into a different file, rather than one big file
## as with --all-databases. This will make restores easier.
## To backup a single database simply add the db name as a parameter (or multiple dbs)
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is
## Create the user and directories
# mkdir -p /var/backups/mysql/databases
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup
## Remember to make the script executable, and unreadable by others
@motsmanish
motsmanish / cakephp-3-render-in-php.php
Last active July 18, 2018 21:16
Render email template in library for passing email body as a paramenter in CakePHP 3. (needed this for SendGrid)
$template = 'dump';
$layout = false;
$view = new View(new \Cake\Network\Request, new \Cake\Network\Response);
foreach ($vars as $key => $value) {
$view->set($key, $value);
}
$view->viewPath = 'Email\html'; \\src\Template\Email\html
$view_output = $view->render($template, $layout);
Apparel & Accessories
Baby products
Computers
Books
Electronics
Health & Beauty
Groceries
Kitchen & Housewares