Skip to content

Instantly share code, notes, and snippets.

@aziz-blr
aziz-blr / background-script.php
Created August 1, 2017 09:39
Execute php script in background
function execInBackground($cmd){
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start /B ". $cmd, "r"));
}else{
exec($cmd . " > /dev/null &");
}
}
// Pass parameter if you need
//$second_param = 1;
@aziz-blr
aziz-blr / dropzone.js
Created August 1, 2017 08:39
custom events for dropzone including server side rendering & max files upload limit
$(function () {
// Get the template HTML and remove it from the doumenthe template HTML and remove it from the doument
var previewNode = document.querySelector("#referenceTemplate");
previewNode.id = "";
var previewTemplate = previewNode.parentNode.innerHTML;
previewNode.parentNode.removeChild(previewNode);
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(".uploadReference", {// Make the whole body a dropzone
url: "ajax/upload-file.php", // Set the url
@aziz-blr
aziz-blr / active_menu_and_sub_menu.js
Created July 12, 2017 11:52
To make Menu or Sub Menu active according to URL of page
var path = window.location.href;
$('.sidebar-menu li a').each(function () {
// Account for home page with empty path
if (path == 'http://localhost/alshaheedpark/admin/') {
path = path + 'index.php';
}
if (this.href === path) {
$(this).parent().addClass('active');
@aziz-blr
aziz-blr / JQuery-Data-Table-Set-Up.js
Last active August 1, 2017 08:36
JQuery Data Table Set Up
var selected = [];
$(function () {
$('#emailTemplatesDataTable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
@aziz-blr
aziz-blr / stripUrl.php
Created February 6, 2017 12:37
Strip URL
public function StripUrl($title)
{
$title = str_replace("#", "sharp", $title);
$title = str_replace("/", "or", $title);
$title = str_replace("$", "-", $title);
$title = str_replace("&", "and", $title);
$title = str_replace("&", "and", $title);
$title = str_replace("+", "plus", $title);
$title = str_replace(",", "-", $title);
$title = str_replace(":", "-", $title);
@aziz-blr
aziz-blr / gist:b8ba3e7d6af0bc64f76c651778c44433
Created January 26, 2017 09:08
Bootstrap Date/Time Picker - Change Formate On Change Event
<!-- BOOTSTRAP DATE TIME PICKER -->
<script src="plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
$(function () {
$('#meetingdatetime').datetimepicker({format: 'DD-MM-YYYY, h:m a'}).on('dp.change',function(e){
var formatedValue = e.date.format("YYYY-MM-DD HH:mm:ss");
$("#datetime").val(formatedValue);
});
});
</script>
/**
* Sticky header
*/
if ( $body.hasClass( 'header-sticky' ) )
{
var $topbar = $( '#topbar' ),
offset = $topbar.length ? $topbar.height() : 0;
$window.scroll( function()
{ //alert(offset);
// Put this code in config.js file & then use jquery validation plugin with CkEditor
CKEDITOR.on('instanceReady', function (e) {
var instance = e.editor;
instance.on("change", function (evt) {
onCKEditorChange(evt.editor);
});
//key event handler is a hack, cause change event doesn't handle interaction with these keys
instance.on('key', function (evt) {
var backSpaceKeyCode = 8;
errorPlacement: function(error, $elem)
{
if ($elem.attr('id')=='#textarea') {
error.insertAfter($elem.next('#cke_message'));
}else{
error.insertAfter($elem);
}
}
<!-- Custom page script -->
<script>
var selected = [];
$(function () {
$('#emailTemplatesDataTable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,