Skip to content

Instantly share code, notes, and snippets.

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

Kevin Ramirez quevon24

🏠
Working from home
View GitHub Profile
@quevon24
quevon24 / signals.py
Created July 4, 2022 15:41 — forked from voldmar/signals.py
Show all signals receivers in Django project (quickfixed to work with Django 1.10)
# coding:utf-8
from sys import modules
import gc
import inspect
import six
from django.core.management.base import BaseCommand
from django.dispatch.dispatcher import Signal, WeakMethod
@quevon24
quevon24 / list_all_model_signals.py
Created July 4, 2022 15:41 — forked from runekaagaard/list_all_model_signals.py
List all signals by model and signal type. Tested with Django 1.7.
# coding:utf-8
import gc
import inspect
import ctypes
from collections import defaultdict
from django.core.management.base import BaseCommand
from django.db.models.signals import *
export const getThumbnail = (id, size = 300) =>
`https://drive.google.com/thumbnail?id=${id}&sz=${size}`;
export const getIcon = (mimeType) =>
`https://drive-thirdparty.googleusercontent.com/256/type/${mimeType}`;
export const getFile = (id) => `https://drive.google.com/uc?id=${id}`;
export const webViewerURL = (url) =>
@quevon24
quevon24 / embedded-file-viewer.md
Created November 5, 2021 18:07 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

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 October 13, 2021 22:30
Django management command that resets sequencing errors in Postgres which normally occur due to importing/restoring a DB
# 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 July 9, 2021 21:09 — forked from efrenfuentes/numero_letras.py
Numero a letras (Python)
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'efrenfuentes'
MONEDA_SINGULAR = 'bolivar'
MONEDA_PLURAL = 'bolivares'
CENTIMOS_SINGULAR = 'centimo'
@quevon24
quevon24 / random_color_array.js
Created June 8, 2021 02:06 — forked from mucar/random_color_array.js
Javascript Random Color Array
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 April 21, 2021 01:29 — forked from gladson/date_range.py
Date Range widget and field.
# -*- 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 April 21, 2021 01:07 — forked from strogonoff/combined-django-querysets.py
Combine two querysets from different models in Django
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 March 16, 2021 22:15 — forked from igniteflow/gist:335ffed5c7a3d909c61e
Hidden delete inline formset base class for Django.
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(