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 collections import OrderedDict | |
class MyForm(forms.Form): | |
def __init__(self, *args, **kwargs): | |
super(MyForm, self).__init__(*args, **kwargs) | |
original_fields = self.fields | |
new_order = OrderedDict() | |
for key in ['first', 'second', ... 'last']: | |
new_order[key] = original_fields[key] |
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
#!/bin/bash | |
# Set our local settings for this project | |
export DJANGO_SETTINGS_MODULE="myproject.settings.local" |
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
# Converts temperature from F to C | |
far = input('Enter the temp in F:') | |
cel = input('Enter the temp in C:') | |
def convertC(far): | |
# Get the temp | |
# far = input('Enter the temp in F:') |
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
while True: | |
try: | |
userInput = int(input('Enter an integer: ')) | |
print(str(userInput)) | |
break | |
except ValueError: | |
print('Not an integer') |
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
while True: | |
command = str(input('Close by typing q: ')) | |
command = command.lower() | |
if command == 'q': | |
break | |
else: | |
command = str(input('Incorrect command. Close by typing q: ')) |
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
for i in range(1, 51): | |
if i % 3 == 0: | |
continue | |
print(str(i)) | |
# Should result in a list of numbers from 1 to 50 excluding multiples of three |
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
# factors.py | |
# Get integer input from user | |
userInteger = int(input('Enter a positive integer: ')) | |
def findIntegers(userInteger): | |
""" | |
Find all factors of a number. | |
""" |
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
# invest.py | |
# Gather inputs from the user | |
amount = float(input('What is the amount you wish to invest? ')) | |
rate = float(input('What is the current rate? ')) | |
time = int(input('For what period of time would you like to hold your' | |
'investment (in years)? ')) | |
def invest(amount, rate, time): |
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
history > commands.log |
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
Options +FollowSymLinks | |
RewriteEngine on | |
RewriteCond %{HTTP_HOST} ^example.com$ [NC] | |
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] |