This file contains hidden or 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
-----BEGIN PGP MESSAGE----- | |
Version: GnuPG v1 | |
owFtkntQVFUcx3fBlkDXHqJkjxm4ksC0Mufec5+rpLQgRZlpmdqg6z2Pu1wXdmF3 | |
AVEpS0lzoNBAEypzakrF0FEcKrFBS8sUFQwc0nEUmSmXt1MpitpdxiZrOv+c8zvn | |
8/ue3/f8ToU13BRmfjknzTy2vTnRfPwKMr3yaJWwgkFeUszYVzA4R6eeQGjlUXMp | |
Y2fctBipfpqse2M9XkKTl/pj7zI2ppD6/LrXY1AgWUwGTIkthIeSNd3jor48nx7S | |
YnhNEHlN42TCKSoEUFJlVmA1IkAR8zxgASUiJpxsSGZ7/YF/3cqMaDp1YuwavGOE | |
T08THWkjfMHIAdGoIiOk8FSVAMCKLCAZCywBnCGrAhAC/dR319JSFXsRz/KhenOp | |
z51DnT6vd8Q0DughhOVZFnAyJ7JGRao/20gSiQwQUEVZ0LAmQaSJGsCYYABlSiEv |
This file contains hidden or 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
# My alternative to `.first_or_404()` that can also handle ValueError's (common use case for me). | |
# could of course be made to check for more common errors, but for now this has been what I need. | |
from flask import abort | |
def vcoerce(validate_p): | |
"Sanitises the result of a function from ValueError's and empty results" | |
try: | |
return validate_p() or abort(404) | |
except ValueError: |
This file contains hidden or 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 path import path | |
import mimetypes | |
from flask import stream_with_context, Response | |
@app.route('/download/<id>') | |
def download(id): | |
# fp_as_string = my_source.get_a_file(id) | |
guessed, _ = mimetypes.guess_type(fp_as_string) | |
return Response(stream_with_context( | |
path(fp_as_string).chunks(2048, mode='rb')), mimetype=guessed) |
This file contains hidden or 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
"use strict"; | |
const qfApi = { | |
form: (src) => { | |
let form = new FormData() | |
for(let name in src) { | |
form.append(name, src[name]) | |
} | |
return form | |
}, |
This file contains hidden or 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
<div> | |
<AppBar title=”Quick proof-of-concept”/> | |
<List> | |
<ListItem primaryText=”Item 1" /> | |
<ListItem primaryText=”Item 2" /> | |
</List> | |
<img src={logo} className=”App-logo” alt=”logo”/> | |
</div> |
This file contains hidden or 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 myTheme from 'material-ui/styles/baseThemes/lightBaseTheme'; | |
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; | |
import getMuiTheme from 'material-ui/styles/getMuiTheme'; |
This file contains hidden or 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
<MuiThemeProvider muiTheme={getMuiTheme(myTheme)}> | |
<div> | |
<AppBar title="Quick proof-of-concept"/> | |
<List> | |
<ListItem primaryText="Item 1" /> | |
<ListItem primaryText="Item 2" /> | |
</List> | |
<img src={logo} className="App-logo" alt="logo"/> | |
</div> | |
</MuiThemeProvider> |
This file contains hidden or 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
npm i react-tap-event-plugin — save | |
npm i material-ui — save |
This file contains hidden or 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 injectTapEventPlugin from ‘react-tap-event-plugin’; | |
const tapInitOnce = once(() => injectTapEventPlugin()); |
This file contains hidden or 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
class _lm(object): | |
def __init__(self, msg): | |
self.msg = msg | |
def __str__(self): | |
return self.msg() | |
assert 1 == 1, _lm(lambda: 'lazy 1') | |
assert 1 == 2, _lm(lambda: 'lazy 2') |