Skip to content

Instantly share code, notes, and snippets.

View pauleveritt's full-sized avatar

Paul Everitt pauleveritt

  • JetBrains
  • Fredericksburg, VA
View GitHub Profile
@pauleveritt
pauleveritt / app.component.ts
Created April 19, 2016 18:02
Async pipe on object
import {Component} from "angular2/core";
import {Store, Reducer} from "@ngrx/store";
import {Observable} from "rxjs/Observable";
interface AppState {
counter: number;
}
interface ICounter {
id: number,
```html+jinja
file:./some_file.py
```
@pauleveritt
pauleveritt / game.py
Created December 9, 2017 16:13
Mythical arcade @GAMe api
### In all of these cases, *we* make the pyglet window, store it
### "somewhere" (class variable, closure, thread local), and provide
### it as an argument to registered stuff that we (not pyglet) are
### responsible for calling.
### Imperative example. draw_point is an API which adds the arguments
### to a list of draw_point things to run. game.run() makes a window,
### starts render, and calls all the things queued up. In *theory* we
### could implicitly do batching.
from arcade import game, color
@pauleveritt
pauleveritt / navlink.jsx
Created March 8, 2018 22:29
Bloomer NavLink vs. others
@pauleveritt
pauleveritt / test_window.py
Created May 17, 2018 13:37
arcade/pyglet mock window
# I'm a contributor to Arcade: http://arcade.academy
# His tests are currently done as doctests: cumbersome and slow. I'm
# converting them to pytest. But they are...easy and slow. :) Because
# a pyglet GUI window is created/destroyed for every test. I'm pretty
# good at pytest and mediocre at pytest-mock.
# Here's an example of a test that make a window:
from arcade import Window
@pauleveritt
pauleveritt / reg_example.py
Created May 17, 2018 21:03
reg and custom views by docid
import reg
from examples.request import Request
class Document(object):
def __init__(self, docid, text):
self.docid = docid
self.text = text
@pauleveritt
pauleveritt / gist:26eced2697abbda2b0a73afb59b4a63e
Created May 23, 2018 13:54
HyperApp and recycleElement (hydration)
I have a system built on Sphinx (Python docs generation tool, used by ReadTheDocs.) It's a static-site generator,
like Jekyll. I'd like to retain the idea that all initial page views can be done WITHOUT js.
Fictional Scenario
=====================
Imagine a widget that shows one song at a time from an album. I'd like Sphinx to render a <div> showing the
song. Click a button, fetch some JSON, show the next. (What I actually want is faceted drilldown of a big
a thousand articles.)
@pauleveritt
pauleveritt / Actions.spec.tsx
Created June 4, 2018 15:16
HyperApp actions, TypeScript, Jest
import { ActionsType } from "hyperapp";
interface IState {
url: string;
}
/*
I'm trying to do Jest tests on actions without creating a document
and an app. But the first line in the test gives a TypeScript error:
$ .venv/bin/python ./main.py
Traceback (most recent call last):
File "./main.py", line 12, in <module>
player = sound.play()
File "/private/tmp/f2/.venv/src/pyglet/pyglet/media/codecs/base.py", line 273, in play
player.play()
File "/private/tmp/f2/.venv/src/pyglet/pyglet/media/player.py", line 238, in play
self._set_playing(True)
File "/private/tmp/f2/.venv/src/pyglet/pyglet/media/player.py", line 190, in _set_playing
self._create_audio_player()
@pauleveritt
pauleveritt / test.py
Created July 26, 2018 17:14
PyCharm fixture return vs. yield
class Person:
name = 'person'
@pytest.fixture()
def person_one():
return Person()
@pytest.fixture()