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 | |
# | |
# Initial script to create users when launching an Ubuntu server EC2 instance | |
# | |
declare -A USERKEY | |
# | |
# Create one entry for every user who needs access. Be sure to change the key to their |
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
foo: bar |
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
#views.py | |
def events_index(request, year): | |
selected_year = Year.objects.get(title=year) | |
events_list = Event.objects.filter(year = selected_year.id).order_by('category','start_date') | |
return render_to_response('events_list.html', {"events_list": events_list}) | |
#events_list.html | |
{% regroup events_list by category.title as events_list_by_category %} |
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
upstream web { | |
ip_hash; | |
server web:8000; | |
} | |
server { | |
location /static/ { | |
autoindex on; | |
alias /src/static/; |
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
version: '2' | |
services: | |
nginx: | |
image: nginx:latest | |
container_name: nz01 | |
ports: | |
- "8000:8000" | |
volumes: | |
- ./src:/src | |
- ./config/nginx:/etc/nginx/conf.d |
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 datetime | |
import requests | |
import xml.etree.ElementTree as ET | |
POST_URI = 'http://116.212.108.236:802/PaymentServices.asmx?op=PaymentRequestFromECom' | |
user_id = 'ecomauser' | |
password = 'itreus#7102' | |
vendor_code = 'GP' | |
phone_number = '01989782605' | |
post_or_pre = 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
def foo(a, b): | |
return a+b | |
foo(1, 3) ---> 4 | |
foo ---------> <function foo at 0x7f71d73105f0> |
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
def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None): | |
""" | |
Decorator for views that checks that the user is logged in, redirecting | |
to the log-in page if necessary. | |
""" | |
actual_decorator = user_passes_test( | |
lambda u: u.is_authenticated, | |
login_url=login_url, | |
redirect_field_name=redirect_field_name | |
) |
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
class ProductPrice(models.Model): | |
product = models.ForeignKey('Product', on_delete=models.CASCADE,) | |
price = models.DecimalField(max_digits=10, decimal_places=2) | |
date = models.DateField() |
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 django.db import models | |
class Subject(models.Model): | |
name = models.CharField(max_length=128) | |
class Student(models.Model): | |
name = models.CharField(max_length=128) | |
subjects = models.ManyToManyField(Subject, through='StudentSubject') |
NewerOlder