Skip to content

Instantly share code, notes, and snippets.

View sebdah's full-sized avatar
:shipit:
Trust the source

Sebastian Dahlgren sebdah

:shipit:
Trust the source
View GitHub Profile
@sebdah
sebdah / forms.py
Created June 24, 2014 13:25
Handling unique_together errors in Django forms
class MyModelForm(ModelForm):
class Meta:
model = MyModel
fields = ('field2', 'field3', 'field4', 'field5')
def clean(self):
"""
Clean MyModel
"""
# Get the cleaned data
@sebdah
sebdah / forms.py
Created June 24, 2014 13:01
Password confirmation in WTForms
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')
@sebdah
sebdah / client.css
Created June 24, 2014 12:55
Tutorial: Writing your first Meteor application - Add user authentication
html {
padding: 10px;
font-family: Verdana, sans-serif;
}
.login-buttons-dropdown-align-right {
float: right;
}
@sebdah
sebdah / client.html
Created June 24, 2014 12:53
Tutorial: Writing your first Meteor application - Sending messages
<template name="input">
<p>Message: <input type="text" id="message"></p>
</template>
@sebdah
sebdah / client.html
Last active August 29, 2015 14:02
Tutorial: Writing your first Meteor application - Implementing simple chat functions
<template name="messages">
{{#each messages}}
<strong>{{name}}:</strong> {{message}}<br>
{{/each}}
</template>
@sebdah
sebdah / client.html
Created June 24, 2014 12:51
Tutorial: Writing your first Meteor application - Writing the HTML template
<head>
<title>Chat app</title>
</head>
<body>
<h1>Chatapp</h1>
{{> welcome }}
</body>
<template name="welcome">
@sebdah
sebdah / gist:6c07f113654c6e5e341f
Created June 24, 2014 12:46
Accessing GitHub user data in Meteor client
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
user.profile = options.profile;
}
user.profile.github = {};
user.profile.github.accessToken = user.services.github.accessToken;
user.profile.github.email = user.services.github.email;
user.profile.github.username = user.services.github.username;
@sebdah
sebdah / example-update.py
Created June 24, 2014 12:43
Updating throughput in DynamoDB global secondary indexes with boto
connection.update_table(
table_name='MailPostsExperimet',
global_secondary_index_updates=[
{
"Update": {
"IndexName": "gsiPosts",
"ProvisionedThroughput": {
"ReadCapacityUnits": 2,
"WriteCapacityUnits": 2
}
@sebdah
sebdah / client.html
Last active August 29, 2015 14:02
Accessing parent data in MeteorJS
<template name="garage">
<h1>Garage: </h1>
Cars in the garage:<br/>
<ul>
{{#each cars}}
<li>{{registrationNumber}} {{owner}} - <button class="removeCar"></li>
{{/each}}
</ul>
</template>
@sebdah
sebdah / template.json
Created June 24, 2014 12:38
EC2 Windows - Joining a domain via cfn-init
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"<powershell>\n",
"pip install -U cumulus-bundle-handler\n",
"# Join the AD domain\n",
"$password = \"MyPassW0rd\" | ConvertTo-SecureString -asPlainText -Force\n",
"$username = \"example.com\\username\"\n",
"$credential = New-Object System.Management.Automation.PSCredential($username,$password)\n",
"Add-Computer -domainname example.com -OUPath \"OU=Servers,OU=Resources,OU=ORGANIZATION,DC=example,DC=com\" -Credential $credential -passthru \n",