Install Python
$ brew install readline sqlite gdbm --universal
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
| from random import randint | |
| board = [] | |
| for x in range(5): | |
| board.append(["O"] * 5) | |
| def print_board(board): | |
| for row in board: | |
| print " ".join(row) |
| import django | |
| import os | |
| DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__)) | |
| SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) | |
| ''' | |
| Example usage: | |
| STATIC_ROOT = os.path.join(SITE_ROOT, 'static'), |
| import markdown as mkdn | |
| from django import template | |
| from django.utils.safestring import mark_safe | |
| register = template.Library() | |
| @register.filter() | |
| def markdown(value): |
Install Python
$ brew install readline sqlite gdbm --universal
$ brew install python --universal --framework
$ python --version
Python 2.7
Symlinks...
| from django import forms | |
| from django.forms import ModelForm | |
| from django.contrib.auth.models import User | |
| class RegistrationForm(ModelForm): | |
| password_1 = forms.CharField(label=(u'Verify Password'), widget=forms.PasswordInput()) | |
| class Meta: | |
| model = User | |
| fields = ('username', 'password') |
| { | |
| init: function(elevators, floors) { | |
| var waitingFloors = []; | |
| _.each(elevators, function(elevator) { | |
| elevator.on("floor_button_pressed", function(floorNum) { | |
| elevator.goToFloor(floorNum); | |
| }); | |
| elevator.on("up_button_pressed", function(floorNum) { | |
| elevator.goToFloor(floorNum); | |
| }); |
| // dependencies | |
| var async = require('async'); | |
| var path = require('path'); | |
| var AWS = require('aws-sdk'); | |
| var gm = require('gm').subClass({ | |
| imageMagick: true | |
| }); | |
| var util = require('util'); | |
| // get reference to S3 client | |
| var s3 = new AWS.S3(); |
| """ | |
| Fix for some issues with the original code from Heroku: | |
| https://devcenter.heroku.com/articles/s3-upload-python | |
| This example is also designed for use with Django, not Flask as in the original. | |
| """ | |
| import base64 | |
| import hashlib | |
| import hmac |
| import functools | |
| from channels.handler import AsgiRequest | |
| from rest_framework.exceptions import AuthenticationFailed | |
| from rest_framework.settings import api_settings | |
| authenticators = [auth() for auth in api_settings.DEFAULT_AUTHENTICATION_CLASSES] | |
| import os, boto3 | |
| from botocore.client import Config | |
| from django.conf import settings | |
| from rest_framework import parsers | |
| from rest_framework.permissions import IsAuthenticated | |
| from rest_framework.views import APIView | |
| from rest_framework.response import Response | |
| from rest_framework.renderers import JSONRenderer |