maumercado

RSS

… our deepest fear!

Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure. It is our light, not our darkness that most frightens us.

We ask ourselves, ‘Who am I to be brilliant, gorgeous, talented, fabulous?Actually, who are you not to be? You are a child of God. Your playing small does not serve the world. There is nothing enlightened about shrinking so that other people won’t feel insecure around you.

We are all meant to shine, as children do. We were born to make manifest the glory of God that is within us. It’s not just in some of us; it’s in everyone. And as we let our own light shine, we unconsciously give other people permission to do the same.

As we are liberated from our own fear, our presence automatically liberates others.

Marianne Williamson, Return to Love: Reflections on the Principles of “A Course in Miracles”

Package Manager for Sublime Text 2

This is one of those addons you just have to install!

First install Package Control from here. Restart Sublime Text and you are ready to go!

Shift + Command + P gives  you another handy drop-down. Write “install”and an option “Package Control: Install Package” appears. Select it by hitting “Enter” and wait for the package list to load. Browse through it or simply search for a specific package. Easy!

When you install a plugin through the Package Control, it is being automatically updated to the newest version. Restart the editor after you install plug-ins in order to start using the goodies.

Related articles
Enhanced by Zemanta
Jul 7

Making Coffee…

Bogotá, Colombia

image

image

image

image

For a few weeks, I’ve been having a craving for great coffee, and since I live in Colombia (not Columbia) you would think, “hey no problem go to any store, Im sure you’ll find some”, and sadly you’d be wrong, so I decided to buy a french press and a coffee grinder, and of course some medium toasted whole grain coffee, again you’d be wrong to think that since I’m in Colombia (again the country not the state!) that would be fairly easy, it is not, a lot of people drink coffee here, but the problem is they take it for granted, they just buy grinded coffee from who knows when and drink it, and they assume that;s all there is to know about coffee, and this is just sad. 

So let’s finish that small rant, and to the experience again, the coffee, I went home kind of excited, after getting the required equipment, and started thinking “now how do I make this work?”, and thats where I have to mention, this guy -> http://cachafla.com a good friend, and a less annoying version of Sheldon Cooper, who pointed out this video from http://www.jjbeancoffee.com/.

And after just following the instructions there, I got great coffee that can only be described as pure grains of coffee liquified, it was delicious.

Now I wait for the next morning to star to have another drink of what I called seriously delicious coffee, do try this at home.

Oh on a related note the coffee is medium toasted called Café San Alberto.

Feb 8

Stylizing Django messages on the frontend

I just like the way django messages framework work, but I hate it when theres no pretty way to show them to the user, so I found this, dont remember exactly where, so to the creator I owe you the copyright #SOPAsucks!

So anyways as I was saying or writing, I’ve been using the following instructions to show django.contrib.messages in the frontend to the user in a stackoverflow.com kind of way.

First of all you’ll have to use the google jquery library or download your own, (but I rather use the googleapis jquery, here’s why).

I’ve always placed this on the base.html template of my django projects:

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js”></script>

<script type=”text/javascript” src=”{% get_static_prefix %}js/lib/jquery.scrollTo-1.4.1-min.js”></script>

<script type=”text/javascript” src=”“{% get_static_prefix %}js/messages_flasher.js”></script>

The first line is the google jquery library, the second is a needed library which I downloaded from here, and the third is the script I found, which shows the messages sended in the request, in a stackoverflow.com kind of way.

I also created a messages.html template that looks like this:

{% if messages %}

    <script type=”text/javascript”>

    $(document).ready(function() {{% for msg in messages %}

   show_site_message(‘{{msg}}’);{% endfor %}

});

    </script>

{% endif %}

… and I added that to the base.html mentioned above, like this:

<div class=”container” id=”site_messages_container”>

       {% include “ui/fragments/messages.html” %}

</div>

… and this goes into the css file, you can make as many changes here as you want, after all is a css style:

#site_messages_container{

    line-height: 30px;

    padding: 0 10px;

}

#site_messages{

}

#site_messages h3{

font-size: 14px;

color: #FB1004;

}

… and heres whats in the messages_flasher.js, which is what does most of the functionality I wanted for my messages:

var site_message_timeout;

function show_site_message(msg) {

    clearTimeout(site_message_timeout);

    $(document).scrollTo(“#site_messages_container”, 800, function() {

        $(“#site_messages”).remove();

        $(“#site_messages_container”).prepend(“<div id=’site_messages’><h3>”+msg+”</h3></p>”);

        $(“#site_messages”).slideDown(“fast”);

        $(“#site_messages”).fadeIn(“fast”);

        site_message_timeout = setTimeout(hide_site_message, 3000);

    });

}

function hide_site_message() {

    $(“#site_messages”).slideUp(“fast”);

    $(“#site_messages”).fadeOut(“fast”, function() {

        $(“#site_messages”).remove();

    });

}

With all this in place just remember that django.contrib.messages must be in the installed_apps list, django.contrib.messages.middleware.MessageMiddleware must be set in your middleware_classes, and django.contrib.messages.context_processors.messages must be in your template_context_processors, in settings.py

Now with all this youll just have to import messages from django.contrib and then add a message to a request, whenever you feel like it.

For more information on the messages framework, take a look at the django documentation.

Feb 5

Changing input type=file tag!

Recently I had to change the form a file was submitted via forms in django, and found this link. Now thank to those guys I was able to change the input type=file to an image just like they show on their website.

All I had to do on the django templates was to add the jquery google library on the base template, like this:

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js”></script>

On the template extra head block, I just added the path to the filestyle.js library, like this:

<script src=”{{ MEDIA_URL }}js/jquery.filestyle.js” type=”text/javascript”></script>

And then added this little script at the end of the template I wanted to customize the input type=file tag! 

<script type=”text/javascript”>

$(document).ready(function() { 

    $(“input[type=file]”).filestyle({ 

        image: “/site_media/images/gnl/cambiar_imagen.png”,

        imageheight : 14,

        imagewidth : 125,

        width : 250

    });

});

</script>

And that was it, now I have an image instead of the ugly “choose file” button.

User Profile Image in Django Admin with Grappelli

I wanted to show the image chosen on the UserProfile inline section of the user model for the admin and also on the change list of the admin so heres what I did:

I changed the models.ImageField to sorl ImageField on the model.py of User profile like this

    from sorl.thumbnail import ImageField

    class UserProfile(BaseModel):

    […]

        photo = ImageField(max_length=255, upload_to=”profiles/”, 

            null=True, blank=True, default=”img/default_profile_image.png”)

Then on the admin all I had to do was add sorl’s AdminImageMixin on the UserProfileInline class, like this:

    from sorl.thumbnail.admin import AdminImageMixin

    class UserProfileInline(AdminImageMixin, admin.StackedInline):

        model = UserProfile

        verbose_name_plural = ‘User Profile’

And that way you get an image on the UserProfile Inline section on the admin for that user, now for the change_list.

For the change list I had to do a small callable function inside the admin.py file on the UserAdmin class, heres what I did, using sorl’s get_thumbnail:

    from sorl.thumbnail import get_thumbnail

    class MyUserAdmin(UserAdmin):

        def image_thumbnail(self, obj):

            im = get_thumbnail(obj.get_profile().photo, ‘80x80’, quality=99)

            return u”<img src=’/site_media/%s’ />” % im.url

        image_thumbnail.allow_tags = True

        list_display = (‘image_thumbnail’, ‘username’,’email’,’first_name’,’last_name’,’date_joined’,

        'last_login','is_staff', 'is_active',)

And now I have a change list image of the user profile and also on the UserProfile Inline section.

Hope this works for everyone out there…

You can see the more information about this post here.

Pudín

pudin o pudín.

(Del ingl. pudding).

1. m. Dulce que se prepara con bizcocho o pan deshecho en leche y con azúcar y frutas secas.

2. m. Plato semejante, no dulce.

 

Oct 3

Coya

coya.

1. f. Entre los antiguos incas, mujer del emperador, señora soberana o princesa.

Como han cambiado los significados de las palabras!

Paila

paila.

(Del lat. patella, padilla).

1. f. Vasija grande de metal, redonda y poco profunda.

2. f. Dispositivo metálico que permite calentar el agua en las cocinas de carbón.

3. f. Am. Sartén, vasija.

4. f. Cuba. cazo (‖ recipiente de cocina).

5. f. Ec. caja (‖ espacio destinado a la carga en un vehículo).

6. f. Nic. Machete de hoja ancha y delgada, con mango de un pie de longitud, que emplean los operarios para cortar la caña de azúcar.

Moving In
So im finally moving out of my cousins apartment here in bogota, and things are going well, got a lot to do, new web apps projects are happening and even got a call from a few interesting companies who are interested in what I have to offer as a Sysadmin / junior developer.
A hard part of moving is Making your new place somewhere ypu wanna be and so far, thanks to both my parents for their support I have made it so.
Check out the living room and Study/Office room.
No pics of my dorm. Well I like my privacy.
I changed the title from moving out to moving in, thanks to cachafla for pointing that out.

Moving In

So im finally moving out of my cousins apartment here in bogota, and things are going well, got a lot to do, new web apps projects are happening and even got a call from a few interesting companies who are interested in what I have to offer as a Sysadmin / junior developer.

A hard part of moving is Making your new place somewhere ypu wanna be and so far, thanks to both my parents for their support I have made it so.

Check out the living room and Study/Office room.

No pics of my dorm. Well I like my privacy.

I changed the title from moving out to moving in, thanks to cachafla for pointing that out.