Skip to content

Instantly share code, notes, and snippets.

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

Santos Junior Marte Marte SantosJMM

🏠
Working from home
View GitHub Profile
@kaedroho
kaedroho / superpage.py
Last active September 21, 2019 01:20
from django.http import Http404
from django.core.urlresolvers import RegexURLResolver
from django.conf.urls import url
from wagtail.wagtailcore.models import Page
class SuperPage(Page):
"""
This class extends Page by adding methods to allow urlconfs to be embedded inside pages
@languanghao
languanghao / left-bar.vue
Created December 22, 2016 06:56
element ui menu with vue-router
<template>
<el-menu :router="true" :default-active="activeLink">
<template v-for="rule in $router.options.routes">
<el-submenu v-if="rule.children && rule.children.length > 0"
:index="rule.path"
>
<template slot="title"><i :class="rule.icon"></i>{{ rule.title }}</template>
<el-menu-item v-for="child in rule.children" :index="rule.path + '/' + child.path">{{ child.title }}</el-menu-item>
</el-submenu>
<el-menu-item v-else
@thehesiod
thehesiod / async_worker_pool.py
Last active June 30, 2023 11:01
Asynchronous Worker Pool, allows for limiting number of concurrent tasks
import asyncio
from datetime import datetime, timezone
import os
def utc_now():
# utcnow returns a naive datetime, so we have to set the timezone manually <sigh>
return datetime.utcnow().replace(tzinfo=timezone.utc)
class Terminator:
pass
@AngeloAnolin
AngeloAnolin / web.config
Created March 11, 2017 02:56
Web Configuration for Vue Applications Hosted in IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
import logging
from concurrent.futures import Executor
from functools import partial
from multiprocessing.pool import ThreadPool as ThreadPoolBase
log = logging.getLogger()
class ThreadPool(ThreadPoolBase, Executor):
@kenwoodjw
kenwoodjw / asyncio-producer-consumer-task_done.py
Created May 30, 2018 06:05 — forked from tomschr/asyncio-producer-consumer-task_done.py
Producer/Consumer pattern for asyncio (Python >=3.4)
# Original source from http://asyncio.readthedocs.io/en/latest/producer_consumer.html
# Rewritten for Python >=3.4
import asyncio
import random
@asyncio.coroutine
def produce(queue, n):
for x in range(n):
@onecrayon
onecrayon / Pipfile
Last active July 25, 2021 09:32
async/await FastAPI with SQLAlchemy test
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pylint = "*"
[packages]
sqlalchemy = "*"
@danmana
danmana / example_model.py
Created August 16, 2021 15:08
Add support for custom json fields in Odoo
from odoo import models, fields, api
from json_field import JsonField
class Person(models.Model):
_name = 'example.person'
_description = 'Person with json details'
details = JsonField() # a json object represented as dict / list / python primitives