Skip to content

Instantly share code, notes, and snippets.

View iamshanto's full-sized avatar

Samiul Amin Shanto iamshanto

View GitHub Profile
### TWIG ###
Get current route in Symfony2 = app.request.get('_route')
### Other ###
Regenerate bootstap.php.cache = vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
@iamshanto
iamshanto / extend_widget.php
Last active August 29, 2015 14:02
Extend Wordpress Widget
<?php
class CustomExtentWidget
{
function in_widget_form($widget, $return, $instance)
{
if (!in_array($widget->id_base, array('text'))) {
return $instance;
}
if (!isset($instance['classes'])) $instance['classes'] = null;
@iamshanto
iamshanto / gist:4fa2cd5f79142ed8828a
Created January 20, 2015 03:00
Symfony2 Form Event
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
$data = $event->getData();
$data['expires_at'] = (empty($data['expires_at'])) ? null : new \DateTime($data['expires_at']);
$event->setData($data);
});
@iamshanto
iamshanto / gist:7eac27d86dff0dcd67e0
Created January 20, 2015 10:27
Wrodress multisite menu
$slot = 1;
function ra_wp_nav_menu_filter( $content, $args ) {
global $slot;
$locale = get_locale();
$registered = get_registered_nav_menus();
$current = array_slice( $registered, absint( $slot - 1 ), 1 );
if( empty( $current ) || empty( $current[$args->theme_location] ) ) {
return $content;
@iamshanto
iamshanto / example
Created January 20, 2015 10:56
KNPPaginator Bundle - Paging Status Example
{{ docs.getPaginationData.firstItemNumber }} - {{ docs.getPaginationData.lastItemNumber }}
{{ knp_pagination_render(docs) }}
@iamshanto
iamshanto / gist:731c4418e25cda795aaa
Created February 9, 2015 02:33
hinclude alternative
// <div data-callback="DocumentDashboard.showAlert2()" data-url="/welcome">Loading... Please wait</div>
jQuery('[data-url]').each(function(){
var _that = $(this);
var url = _that.attr('data-url');
var callback = _that.attr('data-callback');
$.get(url, function(html){
_that.html(html);
eval(callback);
}).error(function(){
_that.html('');
1. Delete composer.lock file in local env
2. run command: php composer.phar install --no-dev
3. copy new composer.lock file to server(dreamhost)
4. run command on project ditectory: SYMFONY_ENV=prod php composer.phar install --no-dev -o -n --no-scripts
<fieldset>
<!-- these will be affected by check all -->
<div><input type="checkbox" class="checkall"> Check all</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
<div><input type="checkbox"> Checkbox</div>
</fieldset>
<fieldset>
<!-- these won't be affected by check all; different field set -->
<div><input type="checkbox"> Checkbox</div>
Helpful Blog/Tuturials Sites
http://briancray.com/