Skip to content

Instantly share code, notes, and snippets.

View muzfr7's full-sized avatar
🎯
Knowledge is power..

Muzafar Ali muzfr7

🎯
Knowledge is power..
View GitHub Profile
@muzfr7
muzfr7 / template.go
Last active December 31, 2022 02:31
A Go package to pre-compiles and register all the templates in a directory and it's subdirectories. FYI – this won't be a suitable approach if you have same file names in subdirectories!
package template
import (
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"
"text/template"
@muzfr7
muzfr7 / ConvertMultidimensionalArrayToObject.php
Last active February 6, 2018 09:44
Converts given Multi-dimensional Array to Object, using Recursive Function Approach
<?php
// A multi-dimensional array
$user = [
'firstname'=>'Muzafar',
'lastname'=>'Jatoi',
'contacts'=>[
[
'mobile'=>'0500000000',
'email'=>'[email protected]',
@muzfr7
muzfr7 / 1-LoadWorkspaces.php
Last active August 17, 2017 17:34
Sample Doctrine Fixture to default load users in database!
<?php
namespace AppBundle\DataFixtures\ORM;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use AppBundle\Entity\Workspace;
/**
@muzfr7
muzfr7 / Homestead.yaml
Last active July 31, 2017 07:39
Sample Homestead.yml file
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
# VM Name in Virtual Box
name: Homestead
authorize: ~/.ssh/id_rsa.pub
@muzfr7
muzfr7 / Vagrantfile
Last active July 31, 2017 03:48
Sample Vagrant file
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |v|
@muzfr7
muzfr7 / main.js
Created May 20, 2017 07:43
Automatically logout user in 1 hour if he is not changing pages.
/*
* Automatically logout user in 1 hour on no activity
*/
setTimeout(function(){
window.open("http://www.yoursite.com/user/logout", "_self")
}, 1000*60*60); // logout in 1 hour
@muzfr7
muzfr7 / Symfony.gitignore
Created May 13, 2017 06:44
.gitignore file to be used with Symfony2 or 3
# Cache and logs (Symfony2)
/app/cache/*
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
# Email spool folder
/app/spool/*
# Cache, session files and logs (Symfony3)
@muzfr7
muzfr7 / Timestampable.php
Last active May 20, 2024 18:06
Timestampable Trait for doctrine entities to use in order to not to repeat them in individual entities.
<?php
namespace AppBundle\Entity\Traits;
use Doctrine\ORM\Mapping as ORM;
/**
* Adds created at and updated at timestamps to entities.
* Entities using this must have HasLifecycleCallbacks annotation.
*
@muzfr7
muzfr7 / index.html
Created May 6, 2017 07:27
Applying JQuery Plugins to dynamically generated elements
<script type="text/javascript">
jQuery(document).ready(
function() {
$(document).on("focus", ".dateInput", function() {
$(this).mask("99/99/9999");
});
}
);
</script>
@muzfr7
muzfr7 / index.html
Last active May 31, 2023 11:37
Restrict user from typing Non-Arabic characters in input fields using Javascript / JQuery
<html>
<head></head>
<body>
<form>
<input id="candidate_firstname" name="firstname" required="required" class="gui-input" dir="rtl" type="text" />
<input id="candidate_lastname" name="lastname" required="required" class="gui-input" dir="rtl" type="text" />
</form>
<script type="text/javascript">
function restrictInputOtherThanArabic($field)