Skip to content

Instantly share code, notes, and snippets.

View CryceTruly's full-sized avatar
🎯
Focusing

cryce truly CryceTruly

🎯
Focusing
View GitHub Profile
@CryceTruly
CryceTruly / flaskmail.py
Last active July 26, 2019 08:10
A basic flask mail snippet
from flask_mail import Mail, Message
from flask import Flask
app = Flask(__name__)
app.config.update(
DEBUG=True,
#EMAIL SETTINGS
MAIL_SERVER='smtp.gmail.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,
MAIL_USERNAME = 'your email',
@CryceTruly
CryceTruly / test_core.py
Last active February 14, 2019 13:11
Simple DJANGO rest api test
import json
from rest_framework.test import APIClient
class TestClass():
def setUp():
self.client = APIClient()
self.register_url=reverse('authentication:register')
def test_create_user(self):
"""Tests if a user can create an account"""
valid_register_data = {
'user': {
@CryceTruly
CryceTruly / pipenv.md
Last active February 25, 2019 05:29
pipenv cheetsheet

Pipenv Cheat Sheet

Install pipenv

pip3 install pipenv

Activate

pipenv shell

What does this PR do?

Description of Task to be completed?

How should this be manually tested?

Any background context you want to provide?

What are the relevant pivotal tracker stories?

@CryceTruly
CryceTruly / titles.ts
Last active July 26, 2019 08:07
Setting dynamic page titles in an angular 2+ app.
Step 1 #Provide a title in the route configuration,Usually in the app.module.ts
{ path: '', component: HomeComponent, data: { title: 'welcome' } },
Step 2 #import {ActivatedRoute } from '@angular/router';
Step 3 #Inject the ActivatedRoute interface in the constructor of your component:
constructor(private router:ActivatedRoute) { }
Step 4,#Subscribe to the data observable and pull out your data variables,use them for what you want.
ngOnInit() {
[
{
"name":"Afghanistan",
"code":"AF",
"continent":"Asia",
"filename":"afghanistan"
},
{
"name":"Åland Islands",
"continent":"Europe",
{
"AED": "United Arab Emirates Dirham",
"AFN": "Afghan Afghani",
"ALL": "Albanian Lek",
"AMD": "Armenian Dram",
"ANG": "Netherlands Antillean Guilder",
"AOA": "Angolan Kwanza",
"ARS": "Argentine Peso",
"AUD": "Australian Dollar",
"AWG": "Aruban Florin",
export default [
{
text: "Afghanistan (+93)",
value: "+93",
flag: "af",
key: "af",
},
{
text: "Aland Islands",
value: "",
import React, { useState } from "react";
import "./App.css";
function App() {
const [form, setForm] = useState([]);
const [submitted, setFormSubmitted] = useState(false);
const someEmpty = form.some(
(item) => item.Platform === "" || item.Username === ""
);
from rest_framework.views import exception_handler
from rest_framework import status
from django.http import Http404
def custom_exception_handler(exc, context):
"""
This function will handle errors that are returned by
the different views.
The `handlers` dictionary will map