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 / 01-SkillType.php
Last active April 23, 2017 12:46
Symfony Prototype Rendering Macro
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@muzfr7
muzfr7 / php.ini
Created April 24, 2017 05:48
XDebug Configuration (XAMPP)
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
@muzfr7
muzfr7 / 01 - messages.en.yml
Last active April 24, 2017 07:43
Symfony Override System Errors on login page!
"Invalid credentials." : Invalid credentials.
@muzfr7
muzfr7 / 01 - parameters.yml
Last active April 24, 2017 11:42
Sending HTML Email in Symfony using SwiftMailer
parameters:
# ....
# working mailer
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: register@domain.com
mailer_password: passwordForEmail
@muzfr7
muzfr7 / main.js
Last active April 30, 2023 17:13
Saving form data in localStorage before page refreshes and load it back when page is loaded
/*
* Note:
* LocalStorage is kept indefinitely. Something to consider when data privacy is concern
*/
// Run on page load
window.onload = function()
{
// If sessionStorage is storing default values (ex. name), exit the function and do not restore data
if (sessionStorage.getItem('name') == "name") {
@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)
@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 / Timestampable.php
Last active February 8, 2024 09:14
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 / 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 / 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