Skip to content

Instantly share code, notes, and snippets.

View redleafar's full-sized avatar
🎯
Focusing

Rafael Bermúdez redleafar

🎯
Focusing
  • Globant
  • Bogotá, Colombia
View GitHub Profile
@redleafar
redleafar / MLRoundedImageView.java
Last active April 18, 2017 20:07 — forked from melanke/MLRoundedImageView.java
Android Rounded Image
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
@redleafar
redleafar / order_list_admin.md
Created March 2, 2017 12:45
Order list in sonata admin
public function __construct($code, $class, $baseControllerName)
	{
		parent::__construct($code, $class, $baseControllerName);
	
		if (!$this->hasRequest()) {
			$this->datagridValues = array(
					'_page'       => 1,
					'_sort_order' => 'DESC',      // sort direction
 '_sort_by' => 'id' // field name
@redleafar
redleafar / composer_update_killed.md
Created February 25, 2017 23:32
Composer update killed in VPS
@redleafar
redleafar / add_footer_navigation_drawer.md
Created February 25, 2017 01:17
Add footer to NavigationDrawer
@redleafar
redleafar / datetime_problem_sonata_admin.md
Created February 14, 2017 13:42
Problem with datetime and date in sonata admin

There was a problem in sonata admin, in list fields and in form fields (in this case when using sonata_type_datetime_picker), the hour was different from the hour of the uploaded element. It was fixed setting the configuration of the default time zone of sonata_intl:

sonata_intl:
    timezone:
        default: America/Bogota

This is a temporal fix. If the app has to be global it would be necessary to set several timezones, or to try another fix.

@redleafar
redleafar / justify_text_android.md
Created February 7, 2017 19:55
Justify text in Android

Use WebView:

<WebView
                android:id="@+id/terms_conditions"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

In strings.xml:

@redleafar
redleafar / set_form_name.md
Created November 20, 2016 02:04
Set the name of a form

Use createNamedBuilder, for instance:

$formplace = $this->get('form.factory')->createNamedBuilder('locationform', 'form', $place, array())
    	->setAction($this->generateUrl('booster_bici_reg_clubes'))
    	->setMethod('GET')
    	->add('place', 'auto_place', array('label' => 'Filtrar por ubicación'))
    	->add('submit','submit',array('label' => 'Buscar'))
    	->getForm();
@redleafar
redleafar / inject_current_route_class.md
Created November 19, 2016 21:37
Inject current route in custom class (Symfony 2.8)

Use request_stack, for instance:

services:
    app.service:
        class: AppBundle\Class
        arguments: ["@request_stack"]

And in the class:

@redleafar
redleafar / create_super_user_console.md
Created November 17, 2016 16:40
Create super user from console Symfony

$ php app/console fos:user:create adminuser –super-admin

@redleafar
redleafar / get_owner_acl_object.md
Last active December 9, 2016 16:58
Get owner from ACL object
public function rutaAction($id)
    {
    	$em = $this->getDoctrine()->getManager();
    
    	$ruta = $em->getRepository('BoosterBiciBundle:Ruta')->findOneById($id);
    	
    	$adminSecurityHandler = $this->container->get('sonata.admin.security.handler');

 $objectIdentity = ObjectIdentity::fromDomainObject($ruta);