Skip to content

Instantly share code, notes, and snippets.

@sascari
sascari / cw
Last active January 1, 2016 11:19
# ===== _form.html.erb =====
<%= form_for @test, :html => {:multipart => true} do |f| %>
# ----- other form fields -----
<div class="field">
<%= f.label :img %><br>
<%= f.text_field :remote_img_url %>
</div>
@sascari
sascari / gist:6557324
Created September 13, 2013 23:26
Override Blocks
# -- in nav-base.html --
<ul class="nav pull-right">
<li>{% block item-home %} <a href="{% url 'shortener:create' %}">{% trans "HOME" %}</a> {% endblock %}</li>
<li>{% block item-about %} <a href="#">{% trans "ABOUT US" %}</a> {% endblock %}</li>
<li>{% block item-info %} <a href="{% url 'staticpages:detail' %}">{% trans "INFO" %}</a> {% endblock %}</li>
# -- in home.html --
{% extends 'nav-base.html' %}
@sascari
sascari / gist:6251933
Last active December 21, 2015 04:48
python-qrcode
# coding: utf-8
import qrcode
import os
def generate_qr_code(content, name_img):
qr = qrcode.QRCode(version=1, box_size=10, border=4)
qr.add_data(content)
qr.make(fit=True)