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
var arrayToFlatten = [1,[2,[],[3,4],5,[6,[7],[8],9,[[[0]]]]]]; | |
function RecursiveFlattener(thisArr){ | |
var arrayToReturn = []; | |
thisArr.forEach(function(item){ | |
if (typeof item == "number") | |
arrayToReturn.push(item); | |
else | |
arrayToReturn = arrayToReturn.concat(RecursiveFlattener(item)); | |
}); |
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
urlpatterns = patterns('', | |
# Api End Points | |
url(r'^', include(router.urls)), | |
url(r'^auth/',views.obtain_jwt_token ), | |
#url(r'^token/refresh/',views.RefreshTokenView.as_view() ), | |
#url(r'^user/me/',views.SelfView.as_view()), | |
) |
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 vocore.models import User | |
def authenticate(username=None, password=None, **kwargs): | |
try: | |
user = User.objects.get(email=username) | |
if user.check_password(password): | |
return user | |
except User.DoesNotExist: | |
return 'User does not Exist.' |
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 django import forms | |
from django.contrib import admin | |
from django.contrib.auth.forms import ReadOnlyPasswordHashField | |
from djcore.models import User | |
class UserCreationForm(forms.ModelForm): | |
password1 = forms.CharField(label="Password", widget=forms.PasswordInput) | |
password2 = forms.CharField(label="Password Confirmation", widget=forms.PasswordInput) | |
class Meta: |
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 django.db import models | |
from datetime import date, datetime | |
from django.contrib.auth.hashers import (check_password, make_password, is_password_usable) | |
# Create your models here. | |
class User(models.Model): | |
email = models.EmailField(max_length=254,unique=True) | |
first_name = models.CharField(max_length=254,blank=True) | |
last_name = models.CharField(max_length=254,blank=True) | |
password = models.CharField('password', max_length=128) |
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
su demoapi | |
cd /webapps/demoapi | |
source bin/activate | |
cd /demoapi | |
./manage.py startapp djcore |
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
su demoapi | |
cd /webapps/demoapi | |
mkdir static | |
source bin/activate | |
cd demoapi | |
./manage.py createsuperuser | |
#mine was called demoapi with pwd demoapi | |
./manage.py collectstatic |
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
sudo ln -s /etc/nginx/sites-available/demoapi /etc/nginx/sites-enabled/ | |
sudo service nginx restart |
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
upstream app_server { | |
server unix:/webapps/demoapi/sock/gunicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default; | |
client_max_body_size 4G; | |
server_name api.demoapi.dev; | |
keepalive_timeout 5; |
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
sudo groupadd supervisor | |
sudo adduser myname supervisor | |
#edit me in supervisord.conf | |
[unix_http_server] | |
file=/var/run/supervisor.sock ; (the path to the socket file) | |
chmod=0770 ; sockef file mode (default 0700) | |
chown=root:supervisor ;its annoying having to sudo |
NewerOlder