Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Chris Brannen cbrannen9a

🏠
Working from home
Block or report user

Report or block cbrannen9a

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cbrannen9a
cbrannen9a / WTSEvents.sh
Created Jun 13, 2018
Curl for returning all WTS Events from API
View WTSEvents.sh
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 Jun 14, 2018
Example of test query to triathlon statistics API
View test.py
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 Jun 17, 2018
Example of test query for event result details
View test2.py
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 Jun 27, 2018
segement of code for reading request response into local file
View chunk.py
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 Jul 3, 2018
Test script for obtaining athlete data
View test3.py
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 Nov 8, 2018
Example render method for React Fragment
View Fragment_render_example1.js
render() {
return (
<Fragment>
<ChildA />
<ChildB />
<ChildC />
</Fragment>
);
}
@cbrannen9a
cbrannen9a / Fragment_render_example2.js
Created Nov 8, 2018
Example of render method for React Fragment 2
View Fragment_render_example2.js
render() {
return (
<React.Fragment>
<ChildA />
<ChildB />
<ChildC />
</React.Fragment>
);
}
View get_step_content.js
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 Nov 8, 2018
Portion of main Checkout.js with state
View partial_checkout.js
class Checkout extends Component {
state = {
activeStep: 0,
addressForm: {
firstName: '',
lastName: '',
address1: '',
address2: '',
city: '',
state: '',
@cbrannen9a
cbrannen9a / partial_checkout2.js
Created Nov 8, 2018
Partial Checkout.js with handleChange function
View partial_checkout2.js
handleChange = (name, area) => event => {
const value = event.target.value;
this.setState({
[area]: {
...this.state[area],
[name]: value
}
});
}
You can’t perform that action at this time.