User:Jgreenemi

From Rust Community Wiki
Jump to navigation Jump to search

I Am...[edit | edit source]

https://www.jgreenemi.com/about

Find me on Discord as jgreenemi#8858

Handy Pages for Miraheze and MediaWiki[edit | edit source]

Handy Links[edit | edit source]

Handy Syntax References[edit | edit source]

Code Highlighting[edit | edit source]

import boto3
import json
import logging
import os
from pprint import pprint


def parse_training_config(training_config_path=''):
    """
    Pull in a training config and return its contents.
    :return:
    """
    try:
        # Default to the existing training config file in the Lambda function if a specific filename wasn't passed in.
        if not training_config_path:
            training_config_path = 'config/training-config.json'
            config = json.load(open(training_config_path))

        else:
            client_s3 = boto3.client('s3')
            s3_response = client_s3.get_object(
                Bucket=training_config_path,
                Key='training-config.json'
            )

            config = json.loads(s3_response['Body'].read().decode('utf-8'))

        return config

    except Exception as e:
        msg = 'parse_config failure: {}'.format(e)
        logging.error(msg)
        return False
pub mod findcrosses {
    use std::collections::{HashMap, HashSet};
    use std::iter::FromIterator;

    use num::range_step_inclusive;

    use crate::utils::vecutils::format_a_vec;

    pub fn interpet_step_as_instruction(instr_string: String) -> Instruction {
        let mut instr_string = instr_string;
        let direction_letter = instr_string.remove(0);
        let direction = match direction_letter {
            'U' => Ok(Direction::UP),
            'D' => Ok(Direction::DOWN),
            'L' => Ok(Direction::LEFT),
            'R' => Ok(Direction::RIGHT),
            _ => Err("Unexpected character?")
        };
        return Instruction {
            direction: direction.unwrap(),
            magnitude: instr_string.trim().parse().unwrap(),
        };
    }
}