Skip to content

Instantly share code, notes, and snippets.

View surferxo3's full-sized avatar

Mohammad Sharaf Ali surferxo3

View GitHub Profile
@surferxo3
surferxo3 / map_search.js
Last active July 26, 2020 13:13
Perform search on highlighted area by drawing Polygon on Google Maps. Supports actions such as Undo, Redo, and Clear and with Ray Castle Algorithm implementation.
/* global declerations */
var poly, map, path, path_backup, markersArray = [];
/* undo all point(s) */
function undo_point() {
//enable search button if 3 points on the map
if(path.length < 4) {
$("#ss").css('visibility', 'hidden');
}
@surferxo3
surferxo3 / audio.php
Created July 26, 2020 12:02
Audio Upload based on Bitrate comparison in Kbps or Mbps
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Sr. SE
* Version: 1.0
*/#############################
#function to calculate .wav audio bitrate
function calcBitRate($filename) {
$check = false;
@surferxo3
surferxo3 / datatables.js
Last active May 13, 2020 13:05
Perform global search on DataTables either via enter keypress or button click
// reset search on input clear / special 'x' click
$('.dataTables_filter input')
.unbind()
.bind('keyup input', function (e) { // works both for keyboard input and for special 'x' click mouse input
var searchTerm = $(this).val().trim();
if (searchTerm === '' || e.keyCode === 13) {
prodFilesTable.search(searchTerm).draw();
}
});
@surferxo3
surferxo3 / Utils.Extended.js
Last active May 7, 2020 11:26
AMD Web Storage Utils for Underscore.js
// @module Utils.Extended
define(
'Utils.Extended'
, [
'Utils'
, 'Backbone'
, 'SC.Configuration'
, 'underscore'
]
, function (
@surferxo3
surferxo3 / suitecommerce.php
Created May 2, 2020 12:55
LiveOrder POC for `Login` and `Add to Cart with Promocode`
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Sr. SE
* Version: 1.0
*/#############################
class SuiteCommerce
{
protected $cookie;
@surferxo3
surferxo3 / mutation_observer.js
Last active July 26, 2020 11:40
Tracking newly added nodes in DOM using MutationObserver API
function observeNewsletterCCT() {
var target = $('.footer-newsletter:last')[0];
var config = {
childList: true,
subtree: true
};
var closeMsgBtn = '[data-action="close-message"]:first';
var headerLogo = $('.header-logo');
$.fn.observer = new MutationObserver(function(mutations) {
@surferxo3
surferxo3 / checksum.php
Created October 2, 2019 08:03
Encrypt/Decrypt using AES-256 openssl raw data, SHA-512 digest seed, and Null Bytes initialization vector
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Sr. SE
* Version: 1.0
*/#############################
// IMPLEMENTATION
function encrypt($requestId, $validationString) {
$digestSeed = hash('SHA512', $requestId, true);
@surferxo3
surferxo3 / checkbox_select_all.js
Last active July 26, 2020 11:41
Select / Deselect All Checkboxes
// change selection_all checkbox state
$("[name=\'selection[]\']").change(function() {
var state = true;
if ($("[name=\'selection[]\']:checked").length != $("[name=\'selection[]\']").length) {
state = false;
} else {
state = true;
}
@surferxo3
surferxo3 / datepicker.js
Created December 18, 2018 07:17
Enable specific dates in bootstrap datepicker widget
/*
Create case: you want to enable only the future dates and disable the past
Update case: you still want to enable future dates but enable only the the past date already stored in the db
*/
var now = moment(moment().format('DD/MM/YYYY'), 'DD/MM/YYYY');
$('#bulk-sms-form #start_date').datepicker({
format: 'dd/mm/yyyy',
beforeShowDay: function(date) {
var current = moment(date);
@surferxo3
surferxo3 / upload.php
Last active July 26, 2020 12:03
Csv file upload with support of handling files generated via Macintosh
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Sr. SE
* Version: 1.0
*/#############################
public static function processBulkImport($request)
{