Instantly share code, notes, and snippets.

In fundraising crunch mode!

Nick Sweeting pirate

View GitHub Profile
NoneType = type(None)
JsonValue = Union[str, int, float, bool, NoneType]
SocketMessage = Dict[str, JsonValue]
socket_routes = {
'/table/<table_id>/': [PresenceManager, TimeSync, PokerTable],
'/tournament/<table_id>/': [PresenceManager, Tournament, PokerTable],
'/speedtest/': [SpeedTest],
"""Run some code after the response is returned to the user in django
Great for analytics or other slow tasks that you don't want to block the response
to the user for.
class HttpResponseWithCallback(HttpResponse):
def __init__(self, *args, **kwargs):
self.callback = kwargs.pop('callback')
super().__init__(*args, **kwargs)
pirate / full-page.js
Last active Jun 19, 2018
Requested behavior for --full-page CLI option for chrome --headless --screenshot.
View full-page.js
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({width: 1440, height: 1200});
await page.goto('', {waitUntil: 'networkidle2'});
await page.screenshot({path: 'screenshot.png', fullPage: true});
await browser.close();
Minimum amount of code to reproduce a strange mypy edge case where the order
of checking isinstance seems to matter to the type inference.
To test it uncomment one of the __add__ examples and run:
pip3 install mypy
from decimal import Decimal
View action-creators.js
import {reduxify} from 'reduxify'
import {action1, action2} from 'myActions'
const MyComponent = reduxify({
mapDispatchToProps: ({action1, action2}),
render: ({action1, action2}) =>
<button onClick={action1}>Do first action</button>
<button onClick={action2}>Do second action</button>
View reduxify.js
import {connect} from 'react-redux'
export const reduxify = (container) =>
View reduxify-testing.js
const mapStateToProps = (state) => ({
// some complex logic that needs to be tested
const Component = reduxify({
mapDispatchToProps: (dispatch) => ({...}),
render: (props) =>
View reduxify-example.js
const SomeComponent = reduxify({
mapStateToProps: (state) => ({...}),
mapDispatchToProps: (dispatch) => ({...}),
render: ({}) =>
View react-redux-normal-example.js
const mapStateToProps = (state}) => ({
const mapDispatchToProps = (dispatch) => ({
const Component = (props) =>