Skip to content

Instantly share code, notes, and snippets.

View dummerbd's full-sized avatar

Benjamin Dummer dummerbd

View GitHub Profile
@dummerbd
dummerbd / event_loop_executor.py
Last active February 29, 2024 02:37
Python asyncio event loop exectuor
import asyncio
import atexit
import logging
import queue
import threading
import weakref
from concurrent.futures import Executor, Future, InvalidStateError
from typing import Any, Callable, Mapping, Optional, Set, Tuple
@dummerbd
dummerbd / useExampleContext.js
Created January 27, 2020 18:34
Redux to Context
import React, { useContext, createContext } from 'react';
import useExampleModule from './useExampleModule';
const ExampleContext = createContext(null);
export function ExampleProvider({ children }) {
const value = useExampleModule();
return (
<ExampleContext.Provider value={value}>{children}</ExampleContext.Provider>
);
function logObjectAccess(target, name, depth = 1) {
const isProxied = new WeakSet();
return new Proxy(target, {
get(target, key, receiver) {
const value = Reflect.get(...arguments);
console.warn(`Get access to ${name}[${key}]`, value);
if (
typeof value === "object" &&
import React from "react";
import { parse } from "url";
import PropTypes from "prop-types";
import Router from "next/router";
export default class LegacyPageWrapper extends React.Component {
static propTypes = {
backendHost: PropTypes.string,
pageContents: PropTypes.string,
allowFollowingLinkToLocation: PropTypes.func,
@dummerbd
dummerbd / aioserial.py
Last active May 25, 2017 14:15
Asyncio compatible pyserial adapter
import asyncio
import threading
import queue
import serial
import logging
logger = logging.getLogger(__name__)
{
"predef": [
"jQuery", "Backbone", "_", "Handlebars", "window", "BIP", "module", "require",
"jasmine", "describe", "it", "expect", "fail", "beforeEach", "afterEach", "beforeAll", "afterAll", "spyOn", "xdescribe", "xit", "pending"
],
"bitwise": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"maxdepth": 5,
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_extra_width": 1,
"color_scheme": "Packages/User/SublimeLinter/Monokai Low-Profile Gray (SL).tmTheme",
"default_line_ending": "linux",
"enabled_telemetry": false,
"file_exclude_patterns":
[
"*.pyc",
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_extra_width": 1,
"color_scheme": "Packages/User/SublimeLinter/Monokai Low-Profile Gray (SL).tmTheme",
"default_line_ending": "linux",
"enabled_telemetry": false,
"file_exclude_patterns":
[
"db.sqlite3"