Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / build.gradle (app)
Last active May 30, 2020 16:56
Networking Dependencies
android {
...
}
dependencies {
// ADD THESE
implementation 'com.squareup.retrofit2:retrofit:2.6.3'
implementation 'com.squareup.retrofit2:converter-gson:2.6.3'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"
...
@chelseatroy
chelseatroy / AndroidManifest.xml
Created May 30, 2020 16:38
Adding Permissions
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.chelseatroy.canary">
<application
...
</application>
// ADD THESE TWO LINES
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
@chelseatroy
chelseatroy / MoodEntryFragment.kt
Last active May 20, 2020 19:27
Setting a Default Weather
class MoodEntryFragment : DialogFragment() {
var weather = Weather.UNKNOWN
...
override fun onResume() {
super.onResume()
...
@chelseatroy
chelseatroy / MoodEntryFragment.kt
Created May 20, 2020 05:59
Exclusive Selection Less Code
...
for ((index, button) in moodButtonCollection.withIndex()) {
button?.setOnClickListener({ view ->
for (button in moodButtonCollection) button?.setBackgroundColor(unselectedColor);
view.setBackgroundColor(selectedColor);
currentMood = Mood.values()[index]
})
}
...
@chelseatroy
chelseatroy / MoodEntryFragment.kt
Created May 20, 2020 05:54
Exclusive Selection View Collection
...
var moods = arrayListOf<String>(
"UNSELECTED",
"UNSELECTED",
"UNSELECTED",
"UNSELECTED",
"UNSELECTED"
)
for ((index, button) in moodButtonCollection.withIndex()) {
val thisButtonIndex = index
@chelseatroy
chelseatroy / UIColor+Brand.swift
Created April 20, 2020 20:47
Extending UIColor
extension UIColor {
static let brandedBlue = UIColor(netHex: 0x5CADCF)
}
@chelseatroy
chelseatroy / upload_subject.py
Created January 4, 2020 20:51
Original Code
from os import getenv
from ..abstract_operation import AbstractOperation
from panoptes_client import Panoptes, Project, Subject, SubjectSet
from theia.utils import PanoptesUtils
class UploadSubject(AbstractOperation):
def apply(self, filenames):
if self.pipeline.multiple_subject_sets:
@chelseatroy
chelseatroy / pipeline_stages.json
Created January 4, 2020 20:39
Pipeline To Run
{
"data": [
{
"type": "PipelineStage",
"id": "2",
"attributes": {
"sort_order": 1,
"output_format": null,
"operation": "image_operations.remap_image",
"select_images": [
@chelseatroy
chelseatroy / key_value_store.py
Last active December 24, 2019 15:38
Ignoring Empty Strings
class KeyValueStore:
...
def execute(self, string_operation, term_absent, write=True, path_to_logs=''):
if len(string_operation) == 0:
return
...
@chelseatroy
chelseatroy / key_value_store.py
Created December 24, 2019 15:32
Reading the File
class KeyValueStore:
...
def catch_up(self, path_to_logs=''):
if path_to_logs == '':
path_to_logs = "logs/" + self.server_name + "_log.txt"
if os.path.exists(path_to_logs):
f = open(path_to_logs, "r")