Skip to content

Instantly share code, notes, and snippets.

View tanmay27vats's full-sized avatar

Tanmay Vats tanmay27vats

View GitHub Profile
@tanmay27vats
tanmay27vats / install.sh
Last active May 28, 2018 04:39
Install pthreads (Multithreading) on Amazon AWS EC2 server having PHP version 5.6.x
#Install pthreads on AWS-EC2 with php5.6
#!/usr/bin/env bash
sudo yum update -y
sudo yum install httpd
cd
wget https://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum install latest.rpm -y
sudo yum-config-manager --enable webtatic
sudo yum clean all
sudo yum install --enablerepo=webtatic php56w php56w-bcmath php56w-gd php56w-imap php56w-mbstring php56w-mcrypt php56w-mysqlnd php56w-pear php56w-xml php56w-soap php56w-devel -y
@tanmay27vats
tanmay27vats / replace_french_chars.php
Created February 28, 2017 10:04
Replace French orthography to Normal English. I used this to rename folder-name/file-names/slugs
function frenchChars($string)
{
$normalizeChars = array(
'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A',
'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I',
'Ï'=>'I', 'Ñ'=>'N', 'Ń'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U',
'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a',
'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i',
'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ń'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u',
@tanmay27vats
tanmay27vats / bash.sh
Created April 24, 2017 08:36
change editor for git
git config --global core.editor "vim"
#Run above command in Terminal / git-bash to change git editor from default to "vim" editor
@tanmay27vats
tanmay27vats / ios_push_notification.php
Last active May 28, 2018 04:41
Apple Push Notification service (APNs) - iOS Push Notification in PHP
<?php
// Provide the Host Information.
$vHost = 'gateway.sandbox.push.apple.com';
//$vHost = 'gateway.push.apple.com';
$vPort = 2195;
// Provide the Certificate and Key Data.
$vCert = 'Certificates.pem';
@tanmay27vats
tanmay27vats / PushNotifications.php
Created March 6, 2018 08:23
Apple Push Notifications Service (APNS) in PHP
//$vHost = 'gateway.sandbox.push.apple.com';
$vHost = 'gateway.push.apple.com';
$vPort = 2195;
$vCert = APPPATH.'../assets/certificates/Certificates-Production.pem';
$vPassphrase = 'password to your pem file';
$vToken = $data['token'];
$vAlert = array(
@tanmay27vats
tanmay27vats / wizard.php
Created January 21, 2018 15:20
Change collation to utf8 of all tables of database
$dbname=’db’; //your database name
$username=’userrname’; // your database user name
$password=’password’; //your database user password
$db = mysql_connect($dbname,$username,$password);
if (!$db) {
echo "Cannot connect to the database – incorrect details";
} else {
mysql_select_db(‘pm’);
$result = mysql_query(‘show tables’);
@tanmay27vats
tanmay27vats / function.php
Created January 7, 2018 17:43
Woocommerce: Remove Cross Sell From Cart Page
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' );
@tanmay27vats
tanmay27vats / .htaccess
Created January 3, 2018 08:01
Wordpress: How to use live images on localhost?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# custom rules for loading server images or any other uploaded media files locally.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule ^.*/uploads/(.*)$ http://livesiteurl.com/wp-content/uploads/$1 [L,R=301,NC]
# default WordPress rules
@tanmay27vats
tanmay27vats / function.php
Created December 28, 2017 13:32
WordPress: Rename the default label “Posts” to “News” OR something else...
function tv_change_post_label()
{
global $menu;
global $submenu;
$menu[5][0] = 'News';
$submenu['edit.php'][5][0] = 'News';
$submenu['edit.php'][10][0] = 'Add News';
$submenu['edit.php'][16][0] = 'News Tags';
}
function tv_change_post_object()
@tanmay27vats
tanmay27vats / function.php
Created July 4, 2017 06:00
Enable SVG support in Wordpress. How to upload/enable SVG images on wordpress.
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
function fix_svg_thumb_display() {
echo '<style type="text/css">
td.media-icon img[src$=".svg"], img[src$=".svg"].attachment-post-thumbnail {
width: 100% !important;