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
| <head> | |
| <title>Chat app</title> | |
| </head> | |
| <body> | |
| <h1>Chatapp</h1> | |
| {{> welcome }} | |
| </body> | |
| <template name="welcome"> |
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
| <template name="messages"> | |
| {{#each messages}} | |
| <strong>{{name}}:</strong> {{message}}<br> | |
| {{/each}} | |
| </template> |
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
| <template name="input"> | |
| <p>Message: <input type="text" id="message"></p> | |
| </template> |
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
| html { | |
| padding: 10px; | |
| font-family: Verdana, sans-serif; | |
| } | |
| .login-buttons-dropdown-align-right { | |
| float: right; | |
| } |
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 UserForm(model_form(models.User)): | |
| """ Extend the ModelForm from MongoEngine """ | |
| password = wtf.PasswordField( | |
| 'Password', | |
| [ | |
| wtf.validators.Length(min=2), | |
| wtf.Required(), | |
| wtf.EqualTo('confirm', message='Passwords must match') | |
| ]) | |
| confirm = wtf.PasswordField('Repeat password') |
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 MyModelForm(ModelForm): | |
| class Meta: | |
| model = MyModel | |
| fields = ('field2', 'field3', 'field4', 'field5') | |
| def clean(self): | |
| """ | |
| Clean MyModel | |
| """ | |
| # Get the cleaned data |
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 boto.dynamodb2.layer1 import DynamoDBConnection | |
| connection = DynamoDBConnection( | |
| aws_access_key_id='foo', # Dummy access key | |
| aws_secret_access_key='bar', # Dummy secret key | |
| host='localhost', # Host where DynamoDB Local resides | |
| port=8000, # DynamoDB Local port (8000 is the default) | |
| is_secure=False) # Disable secure connections |
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 threading | |
| import time | |
| class ThreadingExample(object): | |
| """ Threading example class | |
| The run() method will be started and it will run in the background | |
| until the application exits. | |
| """ |
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
| """ Quicksort implementation """ | |
| def quicksort(arr): | |
| """ Quicksort a list | |
| :type arr: list | |
| :param arr: List to sort | |
| :returns: list -- Sorted list | |
| """ |
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
| def fibonacci(): | |
| """ Generator yielding Fibonacci numbers | |
| :returns: int -- Fibonacci number as an integer | |
| """ | |
| x, y = 0, 1 | |
| while True: | |
| yield x | |
| x, y = y, x + y |