Skip to content

Instantly share code, notes, and snippets.

@quevon24
quevon24 / embedded-file-viewer.md
Created Nov 5, 2021 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive
View embedded-file-viewer.md

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@quevon24
quevon24 / reset_sequences.py
Created Oct 13, 2021
Django management command that resets sequencing errors in Postgres which normally occur due to importing/restoring a DB
View reset_sequences.py
# From https://stackoverflow.com/questions/14589634/how-to-reset-the-sequence-for-ids-on-postgresql-tables
import psycopg2
from django.conf import settings
from django.core.management.base import BaseCommand
from django.db import connections
def dictfetchall(cursor):
"""Return all rows from a cursor as a dict"""
@quevon24
quevon24 / numero_letras.py
Created Jul 9, 2021 — forked from efrenfuentes/numero_letras.py
Numero a letras (Python)
View numero_letras.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'efrenfuentes'
MONEDA_SINGULAR = 'bolivar'
MONEDA_PLURAL = 'bolivares'
CENTIMOS_SINGULAR = 'centimo'
@quevon24
quevon24 / random_color_array.js
Created Jun 8, 2021 — forked from mucar/random_color_array.js
Javascript Random Color Array
View random_color_array.js
var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6',
'#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D',
'#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A',
'#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC',
'#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC',
'#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399',
'#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680',
'#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933',
'#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3',
'#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF'];
@quevon24
quevon24 / date_range.py
Created Apr 21, 2021 — forked from gladson/date_range.py
Date Range widget and field.
View date_range.py
# -*- coding: utf-8 -*-
#
# This code have contributions of Augusto Men (https://github.com/augustomen)
# and Nando Florestan (https://github.com/nandoflorestan)
#
from __future__ import (absolute_import, division, unicode_literals)
from datetime import date
@quevon24
quevon24 / combined-django-querysets.py
Created Apr 21, 2021 — forked from strogonoff/combined-django-querysets.py
Combine two querysets from different models in Django
View combined-django-querysets.py
import datetime
from blog.models import BlogEntry
from news.models import NewsEntry
def get_fresh_news_and_blog_entries():
u"""Returns a list containing published news entries and blog posts mixed,
sorted by publish date. Suitable for template context of, say, landing page.
"""
news = list(NewsEntry.objects.
@quevon24
quevon24 / gist:92fdbcc722217f4aeeec99001cbdacff
Created Mar 16, 2021 — forked from igniteflow/gist:335ffed5c7a3d909c61e
Hidden delete inline formset base class for Django.
View gist:92fdbcc722217f4aeeec99001cbdacff
class HiddenDeleteBaseInlineFormSet(BaseInlineFormSet):
"""
Makes the delete field a hidden input rather than the default checkbox
inlineformset_factory(Book, Page, formset=HiddenDeleteBaseInlineFormSet, can_delete=True)
"""
def add_fields(self, form, index):
super(HiddenDeleteBaseInlineFormSet, self).add_fields(form, index)
if self.can_delete:
form.fields[DELETION_FIELD_NAME] = forms.BooleanField(
@quevon24
quevon24 / chartjs_jquery_ajax_example.html
Created Mar 1, 2021 — forked from msdzero/chartjs_jquery_ajax_example.html
Chart.js example using Jquery Ajax to populate labels and data
View chartjs_jquery_ajax_example.html
<canvas id="myChart" width="400" height="100"></canvas>
<script src="/js/Chart.min.js"></script>
<script>
$(function () {
var ctx = document.getElementById("myChart").getContext("2d");
// examine example_data.json for expected response data
var json_url = "example_data.json";
// draw empty chart
@quevon24
quevon24 / gist:1accef381ba263c31330b165d3dc49b9
Created Dec 19, 2020 — forked from ChrisLTD/gist:957014
Django Nested Regroup Example (Group by category foreign key, then month of start date)
View gist:1accef381ba263c31330b165d3dc49b9
#views.py
def events_index(request, year):
selected_year = Year.objects.get(title=year)
events_list = Event.objects.filter(year = selected_year.id).order_by('category','start_date')
return render_to_response('events_list.html', {"events_list": events_list})
#events_list.html
{% regroup events_list by category.title as events_list_by_category %}
@quevon24
quevon24 / mixins.py
Created Nov 19, 2020 — forked from ceolson01/mixins.py
Django Group Required Mixin
View mixins.py
from django.core.exceptions import PermissionDenied
class GroupRequiredMixin(object):
"""
group_required - list of strings, required param
"""
group_required = None