Skip to content

Instantly share code, notes, and snippets.

View cbrannen9a's full-sized avatar

Chris Brannen cbrannen9a

View GitHub Profile
@cbrannen9a
cbrannen9a / WTSEvents.sh
Created June 13, 2018 11:59
Curl for returning all WTS Events from API
curl - header "apikey: YOUR_APP_KEY" "https://api.triathlon.org/v1/statistics/results?analysis=count_unique&target_property=event.name&group_by=event.name|program.id|program.name"
@cbrannen9a
cbrannen9a / test.py
Last active June 14, 2018 19:59
Example of test query to triathlon statistics API
import requests
import json
from pprint import pprint
#replace YOUR_API_KEY with your key
apikey = 'YOUR_API_KEY'
url = 'https://api.triathlon.org/v1/statistics/results?'
query = 'analysis=count_unique&target_property=event.name&group_by=event.name|program.id|program.name'
local_filename = 'test.txt'
@cbrannen9a
cbrannen9a / test2.py
Created June 17, 2018 15:04
Example of test query for event result details
import requests
import json
from pprint import pprint
apikey = 'YOUR_API_KEY'
url = 'https://api.triathlon.org/v1/statistics/results?'
query = "analysis=minimum&target_property=position&filters=program.id,eq,{0}&group_by=athlete.name|athlete.id|program.start_time|program.wetsuit|splits.swim|splits.swim_distance|splits.bike|splits.bike_distance|splits.run|splits.run_distance|splits.t1|splits.t2|temperature.air|temperature.water|format|event.id|event.country|event.venue|finish_time"
local_filename = 'test.txt'
params = {}
@cbrannen9a
cbrannen9a / chunk.py
Created June 27, 2018 19:28
segement of code for reading request response into local file
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
@cbrannen9a
cbrannen9a / test3.py
Created July 3, 2018 11:47
Test script for obtaining athlete data
import requests
import json
from pprint import pprint
apikey = 'YOUR_API_KEY'
url = 'https://api.triathlon.org/v1/athletes/'
query = '{0}?output=basic'
local_filename = 'test.txt'
params = {}
@cbrannen9a
cbrannen9a / Fragment_render_example1.js
Created November 8, 2018 09:46
Example render method for React Fragment
render() {
return (
<Fragment>
<ChildA />
<ChildB />
<ChildC />
</Fragment>
);
}
@cbrannen9a
cbrannen9a / Fragment_render_example2.js
Created November 8, 2018 09:48
Example of render method for React Fragment 2
render() {
return (
<React.Fragment>
<ChildA />
<ChildB />
<ChildC />
</React.Fragment>
);
}
@cbrannen9a
cbrannen9a / partial_checkout4.js
Last active November 8, 2018 11:54
The handle Change function with second argument in setState call and handleValidation
handleChange = (name, area) => event => {
const value = event.target.value;
this.setState({
[area]: {
...this.state[area],
[name]: value
}
}, () => { this.handleValidation(name, value); });
}
@cbrannen9a
cbrannen9a / .eslintrc
Created November 12, 2018 15:57
Example eslint file for react-hooks
{
"extends": "react-app",
"plugins": [
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error"
}
}
@cbrannen9a
cbrannen9a / App.js
Created November 12, 2018 16:49
Example App.js
import React, { Component } from 'react';
import './App.css';
import Example from './Example';
class App extends Component {
render() {
return (
<div className="App">
<Example />
</div>