Skip to content

Instantly share code, notes, and snippets.

View cbrannen9a's full-sized avatar

Chris Brannen cbrannen9a

View GitHub Profile
@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 / 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 / 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>
);
}
function getStepContent(step) {
switch (step) {
case 0:
return <AddressForm />;
case 1:
return <PaymentForm />;
case 2:
return <Review />;
default:
throw new Error('Unknown step');
@cbrannen9a
cbrannen9a / partial_checkout.js
Created November 8, 2018 11:34
Portion of main Checkout.js with state
class Checkout extends Component {
state = {
activeStep: 0,
addressForm: {
firstName: '',
lastName: '',
address1: '',
address2: '',
city: '',
state: '',
@cbrannen9a
cbrannen9a / partial_checkout2.js
Created November 8, 2018 11:38
Partial Checkout.js with handleChange function
handleChange = (name, area) => event => {
const value = event.target.value;
this.setState({
[area]: {
...this.state[area],
[name]: value
}
});
}