Skip to content

Instantly share code, notes, and snippets.

View edelvalle's full-sized avatar
Loading...

Eddy Ernesto del Valle Pino edelvalle

Loading...
View GitHub Profile
$ xdg-mime default firefox.desktop x-scheme-handler/http
$ xdg-mime default firefox.desktop x-scheme-handler/https
@edelvalle
edelvalle / channels_pgsql.py
Created January 12, 2021 10:04
An attempt to use postgres pubsub for django-channels (NOT PROD READY and has potential bugs)
import time
import asyncio
import base64
import threading
from uuid import uuid4
from queue import SimpleQueue
from collections import defaultdict
import asyncpg
import msgpack
pluralize: (amount, singular, plural) ->
if not amount?
amount = 0
if _.isArray amount
amount = amount.length
if amount is 1 then singular else plural
@edelvalle
edelvalle / how-to-put-it-together.md
Last active June 28, 2017 11:47
How To Put The Monolyth Together

How To Put The Monolyth Together

Clarke's Space Odyssey, monoliths are machines built by an unseen alien variety. In the thread of novels (and the films based on these), three monoliths are discovered in the solar system by humans. (It is also revealed that thousands of others, if not more, exist elsewhere in the heliacal system.) The response of the handwriting to their disclosure strive the plat of the stream. It also influences the fictional annals of the series, particularly by encouraging Homo sapiens to circuit with technological educement and space travel.

The first monolith seem at the inception of the flat, adapt in prehistoric times. It is discovered by a group of hominids and somehow triggers a considerable shift in maneuver, starting with the address to employment weapon and weaponry.

The extraterrestrial species that build the monoliths improved intergalactic travail millions or perhaps billions of yonks before the propitious time. In the novels, Clarke refers to them as the "Firstborn" (

@edelvalle
edelvalle / settings.py
Created April 18, 2016 09:41
Log SQL in Django
LOGGING = {
'version': 1,
'filters': {
'require_debug_true': {
'()': 'django.utils.log.RequireDebugTrue',
}
},
'handlers': {
'console': {
@edelvalle
edelvalle / context_views.py
Last active October 10, 2015 14:45
context views....
import json
from inspect import signature
import xoutil.logger as log
from xoutil.functools import lru_cache
from xoutil.decorator import memoized_property
from xoutil.objects import metaclass
from xoutil.iterators import first_non_null as first
from django import http
@edelvalle
edelvalle / merge.py
Last active April 9, 2020 08:08
Merging model instances in Django 1.9
from django.db import transaction
from django.apps import apps
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db.models.fields.related import ManyToManyField
@transaction.atomic()
def merge(primary_object, *alias_objects):
"""Merge several model instances into one, the `primary_object`.
Use this function to merge model objects and migrate all of the related
@edelvalle
edelvalle / where.py
Created July 7, 2015 21:55
where prototype
from functools import wraps
class where(object):
def __init__(self, function, predicate):
self._alternatives = []
self.where(predicate)(function)
def where(self, predicate):