- Create droplet with Ubuntu 18.10
ssh root@[DROPLET IP ADDRESS]
- Get password from your email
- Change password on first login
adduser laravel
- Enter password and other information
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
public static String getDate(long time) { | |
Calendar cal = Calendar.getInstance(Locale.ENGLISH); | |
cal.setTimeInMillis(time); | |
return DateFormat.format("EEE, dd/MM/yyyy", cal).toString(); // EEE is for day of the week | |
} |
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
import {withRouter} from 'react-router' | |
class Nav extends Component { | |
render () { | |
const { match, location, history } = this.props | |
return <h2>The Nav</h2> | |
} | |
} |
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
djangoapp/ | |
__init__.py | |
models.py | |
... | |
templatetags/ | |
__init__.py | |
custom_tags.py | |
Note:: After adding a new template tags module, you will need to restart | |
the Django development server in order to use the new template tags and filters. |
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
For python3 you would need to use | |
>>> exec(open('myscript.py').read()) | |
or | |
import os, django | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") | |
django.setup() | |
# now your code can go here... |
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
class Register(CreateView): | |
model = User | |
form_class = UserRegistrationForm | |
template_name = 'accounts/form.html' | |
success_url = '/' | |
extra_context = { | |
'title': 'Register' | |
} |
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
class Login(FormView): | |
""" | |
Provides the ability to login as a user with a username and password | |
""" | |
success_url = '/' | |
form_class = UserLoginForm | |
template_name = 'accounts/form.html' | |
extra_context = { | |
'title': 'Login' |
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
class LogoutView(RedirectView): | |
""" | |
Provides users the ability to logout | |
""" | |
url = '/login' | |
def get(self, request, *args, **kwargs): | |
auth.logout(request) | |
messages.success(request, 'You are now logged out') | |
return super(LogoutView, self).get(request, *args, **kwargs) |
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.urls import path | |
from . import views | |
app_name = 'accounts' | |
urlpatterns = [ | |
path('login', views.Login.as_view(), name='login'), | |
path('register', views.Register.as_view(), name='register'), | |
path('logout', views.LogoutView.as_view(), name='logout'), |
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
def format_code(code_name): | |
"""Format django error code to Circle Error code""" | |
if code_name == 'blank': | |
return "BLANK_FIELD" | |
elif code_name == 'invalid': | |
return "INVALID_DATA" | |
elif code_name == 'required': | |
return "KEY_ERROR" | |
else: |
OlderNewer