Skip to content

Instantly share code, notes, and snippets.

View dev-jaydeep's full-sized avatar
🎯
Focusing

Jaydeep Chauhan dev-jaydeep

🎯
Focusing
View GitHub Profile
@dev-jaydeep
dev-jaydeep / email.php
Created September 29, 2023 06:55
Send email with attachments using amazon ses
<?php
//required `phpmailer/phpmailer` and `aws/aws-sdk-php` PHP library
use Aws\Ses\Exception\SesException;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
$AWS_ACCESS_KEY_ID = 'xxxxxxxxxxxxx';
$AWS_SECRET_ACCESS_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
@dev-jaydeep
dev-jaydeep / PdfReader.js
Created August 25, 2023 12:28
PDF Reader react native [rn-pdf-reader-js]
import * as React from 'react';
import { View, ActivityIndicator, Platform, StyleSheet } from 'react-native';
import { WebView } from 'react-native-webview';
import * as FileSystem from 'expo-file-system';
const { cacheDirectory, writeAsStringAsync, deleteAsync, getInfoAsync, EncodingType, } = FileSystem;
function viewerHtml(base64, customStyle, withScroll = false, withPinchZoom = false, maximumPinchZoomScale = 5) {
return `
<!DOCTYPE html>
<html>
<head>
@dev-jaydeep
dev-jaydeep / index.php
Created March 24, 2023 10:46
Find all words in double curly braces from given string using php
<?php
$string = 'This is a {{ sample }} string with {{ curly }} brace';
preg_match_all('/\{{([^}]*)\}}/', $string, $matches);
print_r($matches[0]);
@dev-jaydeep
dev-jaydeep / functions.php
Created February 21, 2023 17:57
Hide shipping rates when free shipping is available.
<?php
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
@dev-jaydeep
dev-jaydeep / functions.php
Created February 21, 2023 16:05
Free Shipping Woocommerce
<?php
function wcs_my_free_shipping( $is_available ) {
global $woocommerce;
// set the product ids that are eligible
$eligible = array( '360' );
// get cart contents
$cart_items = $woocommerce->cart->get_cart();
@dev-jaydeep
dev-jaydeep / index.php
Last active January 23, 2023 08:17
PHP - Remove junk character from string
<?php
$str = 'Awesome line äåòñêèå ïåñíè';
echo filter_var($str,FILTER_SANITIZE_STRING,FILTER_FLAG_STRIP_HIGH);
@dev-jaydeep
dev-jaydeep / index.php
Created October 11, 2022 11:37
Send FCM Push notification using PHP
<?php
/**
* Send FCM Push notification using PHP
*/
$serverKey = '';
$deviceToken = '';
$notificationBody = array(
'body' => 'here is a message. message',
'title' => 'This is title #2',
'sound' => "default",
@dev-jaydeep
dev-jaydeep / mailgun.php
Last active December 7, 2021 09:53
send an email with attachment using mailgun api
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/{{DOMAIN}}');
define('MAILGUN_KEY', '{{APIKEY}');
/**
* @param $to - a@xyz.com or a@xyz.com, b@xyz.com
* @param $from - doe <doe@xyz.com>
* @param $subject - subject
* @param $html - rich body
* @param $text - text body
@dev-jaydeep
dev-jaydeep / helper.php
Last active December 7, 2021 09:54
create a slug from text using php
<?php
/**
* _slug
*
* @param mixed $str
* @param mixed $delimiter
* @return void
*/
function _slug($str, $delimiter = '-') {
@dev-jaydeep
dev-jaydeep / helper.php
Created November 24, 2020 08:14
Ellipsize String
/**
* Ellipsize String
*
* This function will strip tags from a string, split it at its max_length and ellipsize
*
* @param string string to ellipsize
* @param int max length of string
* @param mixed int (1|0) or float, .5, .2, etc for position to split
* @param string ellipsis ; Default '...'
* @return string ellipsized string