Skip to content

Instantly share code, notes, and snippets.

View rg3915's full-sized avatar
🏠
Working from home

Regis Santos rg3915

🏠
Working from home
View GitHub Profile
@rg3915
rg3915 / Django + Ajax dynamic forms .py
Created March 23, 2017 18:14 — forked from goldhand/Django + Ajax dynamic forms .py
Django form with Ajax. A simple Task model that can be updated using a CBV with an AJAX mixin. The view sends post data with ajax then updates the view with a callback to a DetailView with a json mixin.There is an abstract CBV, AjaxableResponseMixin, based on the example form django docs, that is subclassed in the TaskUpdateView CBV. TaskUpdateV…
#models.py
class Task(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
def __unicode__(self):
return self.title
@rg3915
rg3915 / ftoggle.html
Created April 3, 2017 05:44
fadeToggle
<button class="btn btn-success mybtn">Ocultar</button>
<p>Com o comando <code>fadeToggle()</code> podemos ocultar ou mostrar um elemento.</p>
@rg3915
rg3915 / var-let-const.md
Last active April 4, 2017 23:25 — forked from vinicius73/var-let-const.md
var, let e const no JavaScript

var,let, const

Em JavaScript há uma comportamento chamado hoisting. O uso de var trazia algumas pegadinhas, como por exemplo, declarar a mesma variável 2x usando var

var abc = 25
// ...
// ...
var abc = 99
@rg3915
rg3915 / export_excel_xlwt.py
Created April 26, 2017 14:53
Export Excel with xlwt
import xlwt
def export_xls(model_='User', file_name='export.xls', queryset=None, columns_=None):
response = HttpResponse(content_type='application/ms-excel')
response['Content-Disposition'] = 'attachment; filename="%s"' % file_name
wb = xlwt.Workbook(encoding='utf-8')
ws = wb.add_sheet(model_)
@rg3915
rg3915 / .jsbeautifyrc
Last active June 21, 2022 13:45
Sublime Text 3 config + ajax_ snippet
// https://github.com/beautify-web/js-beautify#css--html
{
"html": {
"wrap-attributes": "force-expand-multiline"
},
"end_with_newline": true,
"indent_level": 2,
}
@rg3915
rg3915 / base.html
Last active August 21, 2019 04:59
Index base example
<!-- https://getbootstrap.com/docs/4.0/getting-started/introduction/#starter-template -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="https://www.djangoproject.com/favicon.ico">
<!-- <link rel="shortcut icon" href="http://html5-training-in-hyderabad.blogspot.com.br/favicon.ico"> -->
<title>Django Example</title>
<!-- Bootstrap core CSS -->
@rg3915
rg3915 / reorder.md
Last active December 22, 2017 19:12
Reordenando os itens e salvando no Django

Reordenando os itens e salvando no Django

  • HTML
<input id="hid_order" name="hid_order" type="hidden" />
<div id="sortable_items">
  {% for t in tasks %}
  <div class="row">
    <!-- O segredo está aqui, use {{ t.pk }} -->
@rg3915
rg3915 / edit.js
Created January 6, 2018 01:42
Percorrendo todos os tr de uma tabela e identificando o último elemento, e transformando a tabela em campos editáveis.
$(function() {
// Edit money
$('.money-edit').on('click', function() {
let obj = $(this).closest('tr').children('td')
// get the length of array (obj)
let totalLen = obj.length
obj.each(function(i, e) {
var item_v = $(this).text()
@rg3915
rg3915 / modal.js
Created January 22, 2018 00:53
Modal com HTML e CSS
<!-- Modal -->
<div id="myModal" class="mymodal">
<!-- Modal content -->
<div class="mymodal-content">
<div class="mymodal-header">
<h4>Título</h4>
</div>
<div class="mymodal-body">
...
</div>