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 / postgresql-set-id-seq.sql
Created July 3, 2024 21:17 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@quevon24
quevon24 / fixtures.rake
Created April 13, 2024 15:27 — forked from ZachBeta/fixtures.rake
Rake task to create fixtures from test database in Rails 3.1
#put in lib/tasks/fixtures.rake
namespace :db do
namespace :fixtures do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_migrations"]
ActiveRecord::Base.establish_connection(:development)
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
@quevon24
quevon24 / rakefile_extract_fixtures.rb
Created March 28, 2024 23:50 — forked from deepak/rakefile_extract_fixtures.rb
generate fixtures from actual data in database
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
from django.contrib.admin import ModelAdmin, register, SimpleListFilter
from django.db.models.functions import Length, StrIndex, Substr, NullIf, Coalesce
from django.db.models import Value as V
from .models import Item
class AlphanumericSignatureFilter(SimpleListFilter):
title = 'Signature (alphanumeric)'
parameter_name = 'signature_alphanumeric'
@quevon24
quevon24 / admin.py
Created January 6, 2023 16:29 — forked from leisurelicht/admin.py
Make all fields readonly for Django Admin
class OpsIPInfoAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None):
# make all fields readonly
readonly_fields = list(
set([field.name for field in self.opts.local_fields] +
[field.name for field in self.opts.local_many_to_many])))
if 'is_submitted' in readonly_fields:
readonly_fields.remove('is_submitted')
@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 / 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'