Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / models.py
Created August 28, 2018 18:17
Example of Proxy Model Visualization
from django.db import models
class Visualization(models.Model):
name = models.CharField(primary_key=True, max_length=200)
description = models.TextField()
position = models.IntegerField(default=200)
def __repr__ (self):
return self.name
@chelseatroy
chelseatroy / models.py
Created August 28, 2018 16:32
Example of Giant Conditional in Django Model
from __future__ import unicode_literals
from django.conf import settings
from django.db import models
from django.utils import timezone
import numpy as np
from calendar import Calendar
from charts import HeatMap, PieChart
@chelseatroy
chelseatroy / views.py
Created August 28, 2018 16:42
Example of Calling Giant Conditional in View
from __future__ import unicode_literals
from django.shortcuts import render
from models import Visualization
from exceptions import IncompleteDataException
from .forms import VisualizationForm
from django.contrib.auth.decorators import login_required
@login_required
def transform(request):
@chelseatroy
chelseatroy / MockyAPIImplementation
Last active November 29, 2020 01:13
Implementing the API
package com.chelseatroy.canary.api
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
class MockyAPIImplementation {
private val service: LoginService
companion object {
const val BASE_URL = "http://www.mocky.io/"
//
// BlogPost.swift
// ScottishGaelicTattooHandbook
//
// Created by Chelsea Troy on 7/26/20.
// Copyright © 2020 Chelsea Troy. All rights reserved.
//
import Foundation
@chelseatroy
chelseatroy / BlogPostService.swift
Created July 26, 2020 20:44
Blog Post Service
//
// BlogPostService.swift
// ScottishGaelicTattooHandbook
//
// Created by Chelsea Troy on 7/26/20.
// Copyright © 2020 Chelsea Troy. All rights reserved.
//
import Foundation
@chelseatroy
chelseatroy / BlogPostServiceTests.swift
Created July 26, 2020 20:43
Service Integration Test
//
// BlogPostServiceTests.swift
// ScottishGaelicTattooHandbookTests
//
// Created by Chelsea Troy on 7/26/20.
// Copyright © 2020 Chelsea Troy. All rights reserved.
//
import XCTest
...
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="24dp"
android:paddingBottom="20dp"
android:textColor="@color/black"
android:text="@string/hot_flashes_flushes_in_the_last_7_days"
android:textStyle="bold"
android:textSize="26sp" />
@chelseatroy
chelseatroy / WeeklySurveyFragment.java
Created July 26, 2020 15:45
Extracting Responses
...
private String extractResponseFor(View view) {
RadioGroup options = (RadioGroup) view.findViewById(R.id.radio_group);
int selection = options.getCheckedRadioButtonId();
if (selection == -1) {
options.setBackgroundColor(getActivity().getResources().getColor(R.color.form_validation));
isFormValid = false;
return getString(R.string.unknown);
} else {
public class WeeklySurveyFragment extends SmartFragment implements WeeklySurveyView, OnWebserviceResponse {
...
@Override
public void onResume() {
super.onResume();
appetiteDecreaseSeverityResponse = getView().findViewById(R.id.appetite_decrease_severity_response);
appetiteDecreaseInterferenceResponse = getView().findViewById(R.id.appetite_decrease_interference_response);
nauseaFrequencyResponse = getView().findViewById(R.id.nausea_frequency_response);
nauseaSeverityResponse = getView().findViewById(R.id.nausea_severity_response);