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 Alamofire | |
func makeGetCallWithAlamofire() { | |
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1" | |
Alamofire.request(todoEndpoint) | |
.responseJSON { response in | |
// check for errors | |
guard response.result.error == nil else { | |
// got an error in getting the data, need to handle it | |
print("error calling GET on /todos/1") |
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 requests | |
@app.route('/form', methods=['GET', 'POST']) | |
def form(): | |
form = RebootForm() | |
ugly_messages = [] | |
if form.validate_on_submit(): | |
ip_addresses = form.available.data | |
for ip_address in ip_addresses: | |
requests.get('http://{}/rc.cgi?L=uirreboot.html&c=99'.format(ipaddress)) |
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 sqlalchemy import func | |
db.session.query( | |
Material.id, | |
Material.formula, | |
func.count().label('calculations') | |
).join( | |
Material.cell | |
).group_by( | |
Material.id, |
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
###FORM | |
def landscape_choices(): | |
return LandscapeFormOpt.query.all( | |
class ServerForm(NoCsrfForm): | |
landscape_name = QuerySelectField('Landscape nnname', query_factory=landscape_choices, get_label='landscape_name') | |
class LTestForm(Form): | |
server = FieldList(FormField(ServerForm, default=lambda: Server())) | |
submit = SubmitField('Submit') |
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
Traceback (most recent call last): File "C:\Python27\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "C:\Python27\lib\site-packages\flask\app.py", line 1461, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Python27\lib\site-packages\flask_login.py", line 658, in decorated_view return func(*args, **kwargs) File "C:\web\inno\innovate\views.py", line 207, in sites sites = query.paginate(1, 40, False) File "C:\Python27\lib\site-packages\flask_sqlalchemy\__init__.py", line 405, in paginate items = self.limit(per_page).offset((page - 1) * per_page).all() File "C:\Python27\lib\site-packages\sqlalchemy-0.9.7-py2.7-win32.egg\sqlalchemy\orm\query.py", line 2300, in all return list(self) File "C:\Python27\lib\site-packages\sqlalchemy-0.9.7-py2.7-win32.egg\sqlalchemy\orm\query.py", line 2412, in __iter__ return self._execute_and_instances(context) File "C:\Python27\lib\site-packages\sqlalchemy-0.9.7-py2.7-win32.egg\sqlalchemy\o |
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
"""Usage: | |
CheatSheeter.py <inputxml> | |
CheatSheeter.py -h | --help | |
""" | |
import lxml.etree as et | |
from docopt import docopt | |
from jinja2 import Environment, FileSystemLoader |
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
<form method="post"> | |
{{ form.hidden_tag() }} | |
{{ form.example }} | |
<input type="submit"> | |
</form> |