This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto list fields from django models - from https://djangosnippets.org/snippets/2533/#c5977 | |
import inspect | |
from django.utils.html import strip_tags | |
from django.utils.encoding import force_text | |
def process_docstring(app, what, name, obj, options, lines): | |
# This causes import errors if left outside the function | |
from django.db import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<!--In Electron, this is the correct way to include jQuery--> | |
<script>window.$ = window.jQuery = require('https://code.jquery.com/jquery-3.3.1.slim.min.js');</script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.db import connection | |
import logging | |
import time | |
from django.utils.deprecation import MiddlewareMixin | |
log = logging.getLogger(__name__) | |
class RequestLoggingMiddleware(MiddlewareMixin): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { app, BrowserWindow, Menu, MenuItem, globalShortcut } from 'electron'; | |
const {ipcMain} = require('electron'); // do not use ipcRenderer in main process, use ipcMain | |
const path = require('path') | |
const url = require('url') | |
const log = require('electron-log'); // https://www.npmjs.com/package/electron-log | |
const sh = require("shelljs"); // https://github.com/shelljs/shelljs | |
log.transports.file.level = 'debug'; // transports: console and file, levels: error, warn, info, verbose, debug, silly | |
log.transports.console.level = 'warn'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import aiohttp | |
from async_lru import alru_cache | |
@alru_cache(maxsize=32) | |
async def url_to_data(url): | |
timeout = aiohttp.ClientTimeout(total=60) | |
async with aiohttp.ClientSession(timeout=timeout) as session: | |
async with session.get(url) as response: | |
return await response.read(), response.status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wx | |
from wxasync import AsyncBind, WxAsyncApp, StartCoroutine | |
import asyncio | |
from asyncio.events import get_event_loop | |
import time | |
import wx.lib.newevent | |
SomeNewEvent, EVT_SOME_NEW_EVENT = wx.lib.newevent.NewEvent() | |
SomeNewEventAsync, EVT_SOME_NEW_EVENT_ASYNC = wx.lib.newevent.NewEvent() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define custom event | |
SomeNewEventAsync, EVT_SOME_NEW_EVENT_ASYNC = wx.lib.newevent.NewEvent() | |
# define which async function to call when the event happens | |
AsyncBind(EVT_SOME_NEW_EVENT_ASYNC, self.async_callback, self) | |
# Create and post the event | |
evt = SomeNewEventAsync(attr1="hello", attr2=654) | |
wx.PostEvent(self, evt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wx | |
import time | |
from wxasync import AsyncBind, WxAsyncApp, StartCoroutine | |
import asyncio | |
from asyncio.events import get_event_loop | |
ASYNC_VERSION = True | |
class SelectableFrame(wx.Frame): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python-packages: | |
- https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.4-cp36-cp36m-linux_x86_64.whl | |
- wxasync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desktop-gtk3: | |
build-packages: | |
- build-essential | |
- libgtk-3-dev | |
make-parameters: | |
- FLAVOR=gtk3 | |
plugin: make | |
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git | |
source-subdir: gtk | |
stage-packages: |
OlderNewer